summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/asm/bn86unix.cpp
diff options
context:
space:
mode:
authorryker <>1998-10-05 20:13:16 +0000
committerryker <>1998-10-05 20:13:16 +0000
commit9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4 (patch)
tree51ff319f3510104698e541954d10ad98f9125f36 /src/lib/libcrypto/bn/asm/bn86unix.cpp
parent9e77c62555877f9a64805c49d0dcd7dbfbb40f4e (diff)
downloadopenbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.gz
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.tar.bz2
openbsd-9e43e2ac1373d5be5c6500c1bc3b1dd6ee9584b4.zip
Import of SSLeay-0.9.0b with RSA and IDEA stubbed + OpenBSD build
functionality for shared libs. Note that routines such as sslv2_init and friends that use RSA will not work due to lack of RSA in this library. Needs documentation and help from ports for easy upgrade to full functionality where legally possible.
Diffstat (limited to 'src/lib/libcrypto/bn/asm/bn86unix.cpp')
-rw-r--r--src/lib/libcrypto/bn/asm/bn86unix.cpp752
1 files changed, 752 insertions, 0 deletions
diff --git a/src/lib/libcrypto/bn/asm/bn86unix.cpp b/src/lib/libcrypto/bn/asm/bn86unix.cpp
new file mode 100644
index 0000000000..64702201ea
--- /dev/null
+++ b/src/lib/libcrypto/bn/asm/bn86unix.cpp
@@ -0,0 +1,752 @@
1/* Run the C pre-processor over this file with one of the following defined
2 * ELF - elf object files,
3 * OUT - a.out object files,
4 * BSDI - BSDI style a.out object files
5 * SOL - Solaris style elf
6 */
7
8#define TYPE(a,b) .type a,b
9#define SIZE(a,b) .size a,b
10
11#if defined(OUT) || defined(BSDI)
12#define bn_mul_add_words _bn_mul_add_words
13#define bn_mul_words _bn_mul_words
14#define bn_sqr_words _bn_sqr_words
15#define bn_div64 _bn_div64
16#define bn_add_words _bn_add_words
17
18#endif
19
20#ifdef OUT
21#define OK 1
22#define ALIGN 4
23#endif
24
25#ifdef BSDI
26#define OK 1
27#define ALIGN 4
28#undef SIZE
29#undef TYPE
30#define SIZE(a,b)
31#define TYPE(a,b)
32#endif
33
34#if defined(ELF) || defined(SOL)
35#define OK 1
36#define ALIGN 16
37#endif
38
39#ifndef OK
40You need to define one of
41ELF - elf systems - linux-elf, NetBSD and DG-UX
42OUT - a.out systems - linux-a.out and FreeBSD
43SOL - solaris systems, which are elf with strange comment lines
44BSDI - a.out with a very primative version of as.
45#endif
46
47/* Let the Assembler begin :-) */
48 /* Don't even think of reading this code */
49 /* It was automatically generated by bn-586.pl */
50 /* Which is a perl program used to generate the x86 assember for */
51 /* any of elf, a.out, BSDI,Win32, or Solaris */
52 /* eric <eay@cryptsoft.com> */
53
54 .file "bn-586.s"
55 .version "01.01"
56gcc2_compiled.:
57.text
58 .align ALIGN
59.globl bn_mul_add_words
60 TYPE(bn_mul_add_words,@function)
61bn_mul_add_words:
62 pushl %ebp
63 pushl %ebx
64 pushl %esi
65 pushl %edi
66
67
68 xorl %esi, %esi
69 movl 20(%esp), %edi
70 movl 28(%esp), %ecx
71 movl 24(%esp), %ebx
72 andl $4294967288, %ecx
73 movl 32(%esp), %ebp
74 pushl %ecx
75 jz .L000maw_finish
76.L001maw_loop:
77 movl %ecx, (%esp)
78 /* Round 0 */
79 movl (%ebx), %eax
80 mull %ebp
81 addl %esi, %eax
82 movl (%edi), %esi
83 adcl $0, %edx
84 addl %esi, %eax
85 adcl $0, %edx
86 movl %eax, (%edi)
87 movl %edx, %esi
88 /* Round 4 */
89 movl 4(%ebx), %eax
90 mull %ebp
91 addl %esi, %eax
92 movl 4(%edi), %esi
93 adcl $0, %edx
94 addl %esi, %eax
95 adcl $0, %edx
96 movl %eax, 4(%edi)
97 movl %edx, %esi
98 /* Round 8 */
99 movl 8(%ebx), %eax
100 mull %ebp
101 addl %esi, %eax
102 movl 8(%edi), %esi
103 adcl $0, %edx
104 addl %esi, %eax
105 adcl $0, %edx
106 movl %eax, 8(%edi)
107 movl %edx, %esi
108 /* Round 12 */
109 movl 12(%ebx), %eax
110 mull %ebp
111 addl %esi, %eax
112 movl 12(%edi), %esi
113 adcl $0, %edx
114 addl %esi, %eax
115 adcl $0, %edx
116 movl %eax, 12(%edi)
117 movl %edx, %esi
118 /* Round 16 */
119 movl 16(%ebx), %eax
120 mull %ebp
121 addl %esi, %eax
122 movl 16(%edi), %esi
123 adcl $0, %edx
124 addl %esi, %eax
125 adcl $0, %edx
126 movl %eax, 16(%edi)
127 movl %edx, %esi
128 /* Round 20 */
129 movl 20(%ebx), %eax
130 mull %ebp
131 addl %esi, %eax
132 movl 20(%edi), %esi
133 adcl $0, %edx
134 addl %esi, %eax
135 adcl $0, %edx
136 movl %eax, 20(%edi)
137 movl %edx, %esi
138 /* Round 24 */
139 movl 24(%ebx), %eax
140 mull %ebp
141 addl %esi, %eax
142 movl 24(%edi), %esi
143 adcl $0, %edx
144 addl %esi, %eax
145 adcl $0, %edx
146 movl %eax, 24(%edi)
147 movl %edx, %esi
148 /* Round 28 */
149 movl 28(%ebx), %eax
150 mull %ebp
151 addl %esi, %eax
152 movl 28(%edi), %esi
153 adcl $0, %edx
154 addl %esi, %eax
155 adcl $0, %edx
156 movl %eax, 28(%edi)
157 movl %edx, %esi
158
159 movl (%esp), %ecx
160 addl $32, %ebx
161 addl $32, %edi
162 subl $8, %ecx
163 jnz .L001maw_loop
164.L000maw_finish:
165 movl 32(%esp), %ecx
166 andl $7, %ecx
167 jnz .L002maw_finish2
168 jmp .L003maw_end
169.align ALIGN
170.L002maw_finish2:
171 /* Tail Round 0 */
172 movl (%ebx), %eax
173 mull %ebp
174 addl %esi, %eax
175 movl (%edi), %esi
176 adcl $0, %edx
177 addl %esi, %eax
178 adcl $0, %edx
179 decl %ecx
180 movl %eax, (%edi)
181 movl %edx, %esi
182 jz .L003maw_end
183 /* Tail Round 1 */
184 movl 4(%ebx), %eax
185 mull %ebp
186 addl %esi, %eax
187 movl 4(%edi), %esi
188 adcl $0, %edx
189 addl %esi, %eax
190 adcl $0, %edx
191 decl %ecx
192 movl %eax, 4(%edi)
193 movl %edx, %esi
194 jz .L003maw_end
195 /* Tail Round 2 */
196 movl 8(%ebx), %eax
197 mull %ebp
198 addl %esi, %eax
199 movl 8(%edi), %esi
200 adcl $0, %edx
201 addl %esi, %eax
202 adcl $0, %edx
203 decl %ecx
204 movl %eax, 8(%edi)
205 movl %edx, %esi
206 jz .L003maw_end
207 /* Tail Round 3 */
208 movl 12(%ebx), %eax
209 mull %ebp
210 addl %esi, %eax
211 movl 12(%edi), %esi
212 adcl $0, %edx
213 addl %esi, %eax
214 adcl $0, %edx
215 decl %ecx
216 movl %eax, 12(%edi)
217 movl %edx, %esi
218 jz .L003maw_end
219 /* Tail Round 4 */
220 movl 16(%ebx), %eax
221 mull %ebp
222 addl %esi, %eax
223 movl 16(%edi), %esi
224 adcl $0, %edx
225 addl %esi, %eax
226 adcl $0, %edx
227 decl %ecx
228 movl %eax, 16(%edi)
229 movl %edx, %esi
230 jz .L003maw_end
231 /* Tail Round 5 */
232 movl 20(%ebx), %eax
233 mull %ebp
234 addl %esi, %eax
235 movl 20(%edi), %esi
236 adcl $0, %edx
237 addl %esi, %eax
238 adcl $0, %edx
239 decl %ecx
240 movl %eax, 20(%edi)
241 movl %edx, %esi
242 jz .L003maw_end
243 /* Tail Round 6 */
244 movl 24(%ebx), %eax
245 mull %ebp
246 addl %esi, %eax
247 movl 24(%edi), %esi
248 adcl $0, %edx
249 addl %esi, %eax
250 adcl $0, %edx
251 movl %eax, 24(%edi)
252 movl %edx, %esi
253.L003maw_end:
254 movl %esi, %eax
255 popl %ecx
256 popl %edi
257 popl %esi
258 popl %ebx
259 popl %ebp
260 ret
261.bn_mul_add_words_end:
262 SIZE(bn_mul_add_words,.bn_mul_add_words_end-bn_mul_add_words)
263.ident "bn_mul_add_words"
264.text
265 .align ALIGN
266.globl bn_mul_words
267 TYPE(bn_mul_words,@function)
268bn_mul_words:
269 pushl %ebp
270 pushl %ebx
271 pushl %esi
272 pushl %edi
273
274
275 xorl %esi, %esi
276 movl 20(%esp), %edi
277 movl 24(%esp), %ebx
278 movl 28(%esp), %ebp
279 movl 32(%esp), %ecx
280 andl $4294967288, %ebp
281 jz .L004mw_finish
282.L005mw_loop:
283 /* Round 0 */
284 movl (%ebx), %eax
285 mull %ecx
286 addl %esi, %eax
287 adcl $0, %edx
288 movl %eax, (%edi)
289 movl %edx, %esi
290 /* Round 4 */
291 movl 4(%ebx), %eax
292 mull %ecx
293 addl %esi, %eax
294 adcl $0, %edx
295 movl %eax, 4(%edi)
296 movl %edx, %esi
297 /* Round 8 */
298 movl 8(%ebx), %eax
299 mull %ecx
300 addl %esi, %eax
301 adcl $0, %edx
302 movl %eax, 8(%edi)
303 movl %edx, %esi
304 /* Round 12 */
305 movl 12(%ebx), %eax
306 mull %ecx
307 addl %esi, %eax
308 adcl $0, %edx
309 movl %eax, 12(%edi)
310 movl %edx, %esi
311 /* Round 16 */
312 movl 16(%ebx), %eax
313 mull %ecx
314 addl %esi, %eax
315 adcl $0, %edx
316 movl %eax, 16(%edi)
317 movl %edx, %esi
318 /* Round 20 */
319 movl 20(%ebx), %eax
320 mull %ecx
321 addl %esi, %eax
322 adcl $0, %edx
323 movl %eax, 20(%edi)
324 movl %edx, %esi
325 /* Round 24 */
326 movl 24(%ebx), %eax
327 mull %ecx
328 addl %esi, %eax
329 adcl $0, %edx
330 movl %eax, 24(%edi)
331 movl %edx, %esi
332 /* Round 28 */
333 movl 28(%ebx), %eax
334 mull %ecx
335 addl %esi, %eax
336 adcl $0, %edx
337 movl %eax, 28(%edi)
338 movl %edx, %esi
339
340 addl $32, %ebx
341 addl $32, %edi
342 subl $8, %ebp
343 jz .L004mw_finish
344 jmp .L005mw_loop
345.L004mw_finish:
346 movl 28(%esp), %ebp
347 andl $7, %ebp
348 jnz .L006mw_finish2
349 jmp .L007mw_end
350.align ALIGN
351.L006mw_finish2:
352 /* Tail Round 0 */
353 movl (%ebx), %eax
354 mull %ecx
355 addl %esi, %eax
356 adcl $0, %edx
357 movl %eax, (%edi)
358 movl %edx, %esi
359 decl %ebp
360 jz .L007mw_end
361 /* Tail Round 1 */
362 movl 4(%ebx), %eax
363 mull %ecx
364 addl %esi, %eax
365 adcl $0, %edx
366 movl %eax, 4(%edi)
367 movl %edx, %esi
368 decl %ebp
369 jz .L007mw_end
370 /* Tail Round 2 */
371 movl 8(%ebx), %eax
372 mull %ecx
373 addl %esi, %eax
374 adcl $0, %edx
375 movl %eax, 8(%edi)
376 movl %edx, %esi
377 decl %ebp
378 jz .L007mw_end
379 /* Tail Round 3 */
380 movl 12(%ebx), %eax
381 mull %ecx
382 addl %esi, %eax
383 adcl $0, %edx
384 movl %eax, 12(%edi)
385 movl %edx, %esi
386 decl %ebp
387 jz .L007mw_end
388 /* Tail Round 4 */
389 movl 16(%ebx), %eax
390 mull %ecx
391 addl %esi, %eax
392 adcl $0, %edx
393 movl %eax, 16(%edi)
394 movl %edx, %esi
395 decl %ebp
396 jz .L007mw_end
397 /* Tail Round 5 */
398 movl 20(%ebx), %eax
399 mull %ecx
400 addl %esi, %eax
401 adcl $0, %edx
402 movl %eax, 20(%edi)
403 movl %edx, %esi
404 decl %ebp
405 jz .L007mw_end
406 /* Tail Round 6 */
407 movl 24(%ebx), %eax
408 mull %ecx
409 addl %esi, %eax
410 adcl $0, %edx
411 movl %eax, 24(%edi)
412 movl %edx, %esi
413.L007mw_end:
414 movl %esi, %eax
415 popl %edi
416 popl %esi
417 popl %ebx
418 popl %ebp
419 ret
420.bn_mul_words_end:
421 SIZE(bn_mul_words,.bn_mul_words_end-bn_mul_words)
422.ident "bn_mul_words"
423.text
424 .align ALIGN
425.globl bn_sqr_words
426 TYPE(bn_sqr_words,@function)
427bn_sqr_words:
428 pushl %ebp
429 pushl %ebx
430 pushl %esi
431 pushl %edi
432
433
434 movl 20(%esp), %esi
435 movl 24(%esp), %edi
436 movl 28(%esp), %ebx
437 andl $4294967288, %ebx
438 jz .L008sw_finish
439.L009sw_loop:
440 /* Round 0 */
441 movl (%edi), %eax
442 mull %eax
443 movl %eax, (%esi)
444 movl %edx, 4(%esi)
445 /* Round 4 */
446 movl 4(%edi), %eax
447 mull %eax
448 movl %eax, 8(%esi)
449 movl %edx, 12(%esi)
450 /* Round 8 */
451 movl 8(%edi), %eax
452 mull %eax
453 movl %eax, 16(%esi)
454 movl %edx, 20(%esi)
455 /* Round 12 */
456 movl 12(%edi), %eax
457 mull %eax
458 movl %eax, 24(%esi)
459 movl %edx, 28(%esi)
460 /* Round 16 */
461 movl 16(%edi), %eax
462 mull %eax
463 movl %eax, 32(%esi)
464 movl %edx, 36(%esi)
465 /* Round 20 */
466 movl 20(%edi), %eax
467 mull %eax
468 movl %eax, 40(%esi)
469 movl %edx, 44(%esi)
470 /* Round 24 */
471 movl 24(%edi), %eax
472 mull %eax
473 movl %eax, 48(%esi)
474 movl %edx, 52(%esi)
475 /* Round 28 */
476 movl 28(%edi), %eax
477 mull %eax
478 movl %eax, 56(%esi)
479 movl %edx, 60(%esi)
480
481 addl $32, %edi
482 addl $64, %esi
483 subl $8, %ebx
484 jnz .L009sw_loop
485.L008sw_finish:
486 movl 28(%esp), %ebx
487 andl $7, %ebx
488 jz .L010sw_end
489 /* Tail Round 0 */
490 movl (%edi), %eax
491 mull %eax
492 movl %eax, (%esi)
493 decl %ebx
494 movl %edx, 4(%esi)
495 jz .L010sw_end
496 /* Tail Round 1 */
497 movl 4(%edi), %eax
498 mull %eax
499 movl %eax, 8(%esi)
500 decl %ebx
501 movl %edx, 12(%esi)
502 jz .L010sw_end
503 /* Tail Round 2 */
504 movl 8(%edi), %eax
505 mull %eax
506 movl %eax, 16(%esi)
507 decl %ebx
508 movl %edx, 20(%esi)
509 jz .L010sw_end
510 /* Tail Round 3 */
511 movl 12(%edi), %eax
512 mull %eax
513 movl %eax, 24(%esi)
514 decl %ebx
515 movl %edx, 28(%esi)
516 jz .L010sw_end
517 /* Tail Round 4 */
518 movl 16(%edi), %eax
519 mull %eax
520 movl %eax, 32(%esi)
521 decl %ebx
522 movl %edx, 36(%esi)
523 jz .L010sw_end
524 /* Tail Round 5 */
525 movl 20(%edi), %eax
526 mull %eax
527 movl %eax, 40(%esi)
528 decl %ebx
529 movl %edx, 44(%esi)
530 jz .L010sw_end
531 /* Tail Round 6 */
532 movl 24(%edi), %eax
533 mull %eax
534 movl %eax, 48(%esi)
535 movl %edx, 52(%esi)
536.L010sw_end:
537 popl %edi
538 popl %esi
539 popl %ebx
540 popl %ebp
541 ret
542.bn_sqr_words_end:
543 SIZE(bn_sqr_words,.bn_sqr_words_end-bn_sqr_words)
544.ident "bn_sqr_words"
545.text
546 .align ALIGN
547.globl bn_div64
548 TYPE(bn_div64,@function)
549bn_div64:
550 pushl %ebp
551 pushl %ebx
552 pushl %esi
553 pushl %edi
554
555 movl 20(%esp), %edx
556 movl 24(%esp), %eax
557 movl 28(%esp), %ebx
558 divl %ebx
559 popl %edi
560 popl %esi
561 popl %ebx
562 popl %ebp
563 ret
564.bn_div64_end:
565 SIZE(bn_div64,.bn_div64_end-bn_div64)
566.ident "bn_div64"
567.text
568 .align ALIGN
569.globl bn_add_words
570 TYPE(bn_add_words,@function)
571bn_add_words:
572 pushl %ebp
573 pushl %ebx
574 pushl %esi
575 pushl %edi
576
577
578 movl 20(%esp), %ebx
579 movl 24(%esp), %esi
580 movl 28(%esp), %edi
581 movl 32(%esp), %ebp
582 xorl %eax, %eax
583 andl $4294967288, %ebp
584 jz .L011aw_finish
585.L012aw_loop:
586 /* Round 0 */
587 movl (%esi), %ecx
588 movl (%edi), %edx
589 addl %eax, %ecx
590 movl $0, %eax
591 adcl %eax, %eax
592 addl %edx, %ecx
593 adcl $0, %eax
594 movl %ecx, (%ebx)
595 /* Round 1 */
596 movl 4(%esi), %ecx
597 movl 4(%edi), %edx
598 addl %eax, %ecx
599 movl $0, %eax
600 adcl %eax, %eax
601 addl %edx, %ecx
602 adcl $0, %eax
603 movl %ecx, 4(%ebx)
604 /* Round 2 */
605 movl 8(%esi), %ecx
606 movl 8(%edi), %edx
607 addl %eax, %ecx
608 movl $0, %eax
609 adcl %eax, %eax
610 addl %edx, %ecx
611 adcl $0, %eax
612 movl %ecx, 8(%ebx)
613 /* Round 3 */
614 movl 12(%esi), %ecx
615 movl 12(%edi), %edx
616 addl %eax, %ecx
617 movl $0, %eax
618 adcl %eax, %eax
619 addl %edx, %ecx
620 adcl $0, %eax
621 movl %ecx, 12(%ebx)
622 /* Round 4 */
623 movl 16(%esi), %ecx
624 movl 16(%edi), %edx
625 addl %eax, %ecx
626 movl $0, %eax
627 adcl %eax, %eax
628 addl %edx, %ecx
629 adcl $0, %eax
630 movl %ecx, 16(%ebx)
631 /* Round 5 */
632 movl 20(%esi), %ecx
633 movl 20(%edi), %edx
634 addl %eax, %ecx
635 movl $0, %eax
636 adcl %eax, %eax
637 addl %edx, %ecx
638 adcl $0, %eax
639 movl %ecx, 20(%ebx)
640 /* Round 6 */
641 movl 24(%esi), %ecx
642 movl 24(%edi), %edx
643 addl %eax, %ecx
644 movl $0, %eax
645 adcl %eax, %eax
646 addl %edx, %ecx
647 adcl $0, %eax
648 movl %ecx, 24(%ebx)
649 /* Round 7 */
650 movl 28(%esi), %ecx
651 movl 28(%edi), %edx
652 addl %eax, %ecx
653 movl $0, %eax
654 adcl %eax, %eax
655 addl %edx, %ecx
656 adcl $0, %eax
657 movl %ecx, 28(%ebx)
658
659 addl $32, %esi
660 addl $32, %edi
661 addl $32, %ebx
662 subl $8, %ebp
663 jnz .L012aw_loop
664.L011aw_finish:
665 movl 32(%esp), %ebp
666 andl $7, %ebp
667 jz .L013aw_end
668 /* Tail Round 0 */
669 movl (%esi), %ecx
670 movl (%edi), %edx
671 addl %eax, %ecx
672 movl $0, %eax
673 adcl %eax, %eax
674 addl %edx, %ecx
675 adcl $0, %eax
676 decl %ebp
677 movl %ecx, (%ebx)
678 jz .L013aw_end
679 /* Tail Round 1 */
680 movl 4(%esi), %ecx
681 movl 4(%edi), %edx
682 addl %eax, %ecx
683 movl $0, %eax
684 adcl %eax, %eax
685 addl %edx, %ecx
686 adcl $0, %eax
687 decl %ebp
688 movl %ecx, 4(%ebx)
689 jz .L013aw_end
690 /* Tail Round 2 */
691 movl 8(%esi), %ecx
692 movl 8(%edi), %edx
693 addl %eax, %ecx
694 movl $0, %eax
695 adcl %eax, %eax
696 addl %edx, %ecx
697 adcl $0, %eax
698 decl %ebp
699 movl %ecx, 8(%ebx)
700 jz .L013aw_end
701 /* Tail Round 3 */
702 movl 12(%esi), %ecx
703 movl 12(%edi), %edx
704 addl %eax, %ecx
705 movl $0, %eax
706 adcl %eax, %eax
707 addl %edx, %ecx
708 adcl $0, %eax
709 decl %ebp
710 movl %ecx, 12(%ebx)
711 jz .L013aw_end
712 /* Tail Round 4 */
713 movl 16(%esi), %ecx
714 movl 16(%edi), %edx
715 addl %eax, %ecx
716 movl $0, %eax
717 adcl %eax, %eax
718 addl %edx, %ecx
719 adcl $0, %eax
720 decl %ebp
721 movl %ecx, 16(%ebx)
722 jz .L013aw_end
723 /* Tail Round 5 */
724 movl 20(%esi), %ecx
725 movl 20(%edi), %edx
726 addl %eax, %ecx
727 movl $0, %eax
728 adcl %eax, %eax
729 addl %edx, %ecx
730 adcl $0, %eax
731 decl %ebp
732 movl %ecx, 20(%ebx)
733 jz .L013aw_end
734 /* Tail Round 6 */
735 movl 24(%esi), %ecx
736 movl 24(%edi), %edx
737 addl %eax, %ecx
738 movl $0, %eax
739 adcl %eax, %eax
740 addl %edx, %ecx
741 adcl $0, %eax
742 movl %ecx, 24(%ebx)
743.L013aw_end:
744 movl %eax, %eax
745 popl %edi
746 popl %esi
747 popl %ebx
748 popl %ebp
749 ret
750.bn_add_words_end:
751 SIZE(bn_add_words,.bn_add_words_end-bn_add_words)
752.ident "bn_add_words"