aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn
diff options
context:
space:
mode:
authorUlf Möller <ulf@openssl.org>1999-04-06 15:22:55 +0000
committerUlf Möller <ulf@openssl.org>1999-04-06 15:22:55 +0000
commite8d628156ff5fc354e309b51bfbf909a9f75e60f (patch)
tree1ebaa19551c564364105319621527e4398a55c66 /crypto/bn
parent121bd68d1c62b0b6f73839c47f529afc1db32f2b (diff)
downloadopenssl-e8d628156ff5fc354e309b51bfbf909a9f75e60f.tar.gz
Remove obsolete files from SSLeay 0.8.
Diffstat (limited to 'crypto/bn')
-rw-r--r--crypto/bn/asm/x86-bsdi.s272
-rw-r--r--crypto/bn/asm/x86-lnx.s282
-rw-r--r--crypto/bn/asm/x86-lnxa.s282
-rw-r--r--crypto/bn/asm/x86-sol.s224
-rw-r--r--crypto/bn/asm/x86nt32.asm288
-rw-r--r--crypto/bn/bn_bld.c144
-rw-r--r--crypto/bn/bn_mod.c97
-rw-r--r--crypto/bn/bn_sub.c180
-rw-r--r--crypto/bn/m.pl32
-rw-r--r--crypto/bn/stuff/bn_knuth.c378
-rw-r--r--crypto/bn/stuff/div.c340
-rw-r--r--crypto/bn/stuff/mont.doc17
-rw-r--r--crypto/bn/stuff/wei_mulw.c410
13 files changed, 0 insertions, 2946 deletions
diff --git a/crypto/bn/asm/x86-bsdi.s b/crypto/bn/asm/x86-bsdi.s
deleted file mode 100644
index ca6687648e..0000000000
--- a/crypto/bn/asm/x86-bsdi.s
+++ /dev/null
@@ -1,272 +0,0 @@
- .file "bn_mulw.c"
- .version "01.01"
-gcc2_compiled.:
-.text
- .align 4
-.globl _bn_mul_add_word
-_bn_mul_add_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # si c
- # bp num
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 32(%esp),%ecx # w => ecx
- movl 28(%esp),%ebp # num => ebp
-
- shrl $2,%ebp # num/4
- je .L910
-
-# .align 4
-.L110:
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 4
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl 12(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- decl %ebp # --num
- je .L910
- jmp .L110
-# .align 4
-.L910:
- movl 28(%esp),%ebp # num => ebp
- andl $3,%ebp
- je .L111
-
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
-# .align 4
-.L111:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe1:
- .align 4
-.globl _bn_mul_word
-_bn_mul_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # num bp
- # si c
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 28(%esp),%ebp # num => bp
- movl 32(%esp),%ecx # w => ecx
-
-# .align 4
-.L210:
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- jmp .L210
-# .align 4
-.L211:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe2:
- .align 4
-.globl _bn_sqr_words
-_bn_sqr_words:
- pushl %edi
- pushl %esi
- pushl %ebx
- movl 16(%esp),%esi # r
- movl 20(%esp),%edi # a
- movl 24(%esp),%ebx # n
-# .align 4
- shrl $2,%ebx
- jz .L99
-.L28:
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
-
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
-
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
- movl 12(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,24(%esi) # put low into return addr
- movl %edx,28(%esi) # put high into return addr
-
- addl $16,%edi
- addl $32,%esi
- decl %ebx # n-=4;
- jz .L99
- jmp .L28
-# .align 4
-.L99:
- movl 24(%esp),%ebx # n
- andl $3,%ebx
- jz .L29
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
-.L29:
- popl %ebx
- popl %esi
- popl %edi
- ret
-.Lfe3:
- .align 4
-.globl _bn_div64
-_bn_div64:
- movl 4(%esp),%edx # a
- movl 8(%esp),%eax # b
- divl 12(%esp) # ab/c
- ret
-.Lfe4:
- .ident "GCC: (GNU) 2.6.3"
diff --git a/crypto/bn/asm/x86-lnx.s b/crypto/bn/asm/x86-lnx.s
deleted file mode 100644
index 5123867440..0000000000
--- a/crypto/bn/asm/x86-lnx.s
+++ /dev/null
@@ -1,282 +0,0 @@
- .file "bn_mulw.c"
- .version "01.01"
-gcc2_compiled.:
-.text
- .align 16
-.globl bn_mul_add_word
- .type bn_mul_add_word,@function
-bn_mul_add_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # si c
- # bp num
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 32(%esp),%ecx # w => ecx
- movl 28(%esp),%ebp # num => ebp
-
- shrl $2,%ebp # num/4
- je .L910
-
- .align 4
-.L110:
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 4
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl 12(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- decl %ebp # --num
- je .L910
- jmp .L110
- .align 4
-.L910:
- movl 28(%esp),%ebp # num => ebp
- andl $3,%ebp
- je .L111
-
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- .align 4
-.L111:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe1:
- .size bn_mul_add_word,.Lfe1-bn_mul_add_word
- .align 16
-.globl bn_mul_word
- .type bn_mul_word,@function
-bn_mul_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # num bp
- # si c
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 28(%esp),%ebp # num => bp
- movl 32(%esp),%ecx # w => ecx
-
- .align 4
-.L210:
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- jmp .L210
- .align 16
-.L211:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe2:
- .size bn_mul_word,.Lfe2-bn_mul_word
-
- .align 16
-.globl bn_sqr_words
- .type bn_sqr_words,@function
-bn_sqr_words:
- pushl %edi
- pushl %esi
- pushl %ebx
- movl 16(%esp),%esi # r
- movl 20(%esp),%edi # a
- movl 24(%esp),%ebx # n
- .align 4
- shrl $2,%ebx
- jz .L99
-.L28:
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
-
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
-
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
- movl 12(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,24(%esi) # put low into return addr
- movl %edx,28(%esi) # put high into return addr
-
- addl $16,%edi
- addl $32,%esi
- decl %ebx # n-=4;
- jz .L99
- jmp .L28
- .align 16
-.L99:
- movl 24(%esp),%ebx # n
- andl $3,%ebx
- jz .L29
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
-.L29:
- popl %ebx
- popl %esi
- popl %edi
- ret
-.Lfe3:
- .size bn_sqr_words,.Lfe3-bn_sqr_words
-
- .align 16
-.globl bn_div64
- .type bn_div64,@function
-bn_div64:
- movl 4(%esp),%edx # a
- movl 8(%esp),%eax # b
- divl 12(%esp) # ab/c
- ret
-.Lfe4:
- .size bn_div64,.Lfe4-bn_div64
- .ident "GCC: (GNU) 2.6.3"
diff --git a/crypto/bn/asm/x86-lnxa.s b/crypto/bn/asm/x86-lnxa.s
deleted file mode 100644
index 74855dc74d..0000000000
--- a/crypto/bn/asm/x86-lnxa.s
+++ /dev/null
@@ -1,282 +0,0 @@
- .file "bn_mulw.c"
- .version "01.01"
-gcc2_compiled.:
-.text
- .align 4
-.globl _bn_mul_add_word
- .type _bn_mul_add_word,@function
-_bn_mul_add_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # si c
- # bp num
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 32(%esp),%ecx # w => ecx
- movl 28(%esp),%ebp # num => ebp
-
- shrl $2,%ebp # num/4
- je .L910
-
-# .align 4
-.L110:
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+= carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- # Round 4
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl 12(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- decl %ebp # --num
- je .L910
- jmp .L110
-# .align 4
-.L910:
- movl 28(%esp),%ebp # num => ebp
- andl $3,%ebp
- je .L111
-
- # Round 1
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl (%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 2
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl 4(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L111
-
- # Round 3
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl 8(%edi),%eax # *r+=L(t)
- adcl $0,%edx # H(t)+=carry
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r+=L(t)
- movl %edx,%esi # c=H(t)
-
-# .align 4
-.L111:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe1:
- .size _bn_mul_add_word,.Lfe1-_bn_mul_add_word
- .align 4
-.globl _bn_mul_word
- .type _bn_mul_word,@function
-_bn_mul_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- # ax L(t)
- # dx H(t)
- # bx a
- # cx w
- # di r
- # num bp
- # si c
- xorl %esi,%esi # c=0
- movl 20(%esp),%edi # r => edi
- movl 24(%esp),%ebx # a => exb
- movl 28(%esp),%ebp # num => bp
- movl 32(%esp),%ecx # w => ecx
-
-# .align 4
-.L210:
- movl %ecx,%eax # w => eax
- mull (%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 4(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,4(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 8(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,8(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- movl %ecx,%eax # w => eax
- mull 12(%ebx) # w * *a
- addl %esi,%eax # L(t)+=c
- adcl $0,%edx # H(t)+=carry
- movl %eax,12(%edi) # *r=L(t)
- movl %edx,%esi # c=H(t)
- decl %ebp # --num
- je .L211
-
- addl $16,%ebx # a+=4 (4 words)
- addl $16,%edi # r+=4 (4 words)
-
- jmp .L210
-# .align 4
-.L211:
- movl %esi,%eax # return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe2:
- .size _bn_mul_word,.Lfe2-_bn_mul_word
-
- .align 4
-.globl _bn_sqr_words
- .type _bn_sqr_words,@function
-_bn_sqr_words:
- pushl %edi
- pushl %esi
- pushl %ebx
- movl 16(%esp),%esi # r
- movl 20(%esp),%edi # a
- movl 24(%esp),%ebx # n
-# .align 4
- shrl $2,%ebx
- jz .L99
-.L28:
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
-
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
-
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
- movl 12(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,24(%esi) # put low into return addr
- movl %edx,28(%esi) # put high into return addr
-
- addl $16,%edi
- addl $32,%esi
- decl %ebx # n-=4;
- jz .L99
- jmp .L28
-# .align 4
-.L99:
- movl 24(%esp),%ebx # n
- andl $3,%ebx
- jz .L29
- movl (%edi),%eax # get a
- mull %eax # a*a
- movl %eax,(%esi) # put low into return addr
- movl %edx,4(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 4(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,8(%esi) # put low into return addr
- movl %edx,12(%esi) # put high into return addr
- decl %ebx # n--;
- jz .L29
- movl 8(%edi),%eax # get a
- mull %eax # a*a
- movl %eax,16(%esi) # put low into return addr
- movl %edx,20(%esi) # put high into return addr
-
-.L29:
- popl %ebx
- popl %esi
- popl %edi
- ret
-.Lfe3:
- .size _bn_sqr_words,.Lfe3-_bn_sqr_words
-
- .align 4
-.globl _bn_div64
- .type _bn_div64,@function
-_bn_div64:
- movl 4(%esp),%edx # a
- movl 8(%esp),%eax # b
- divl 12(%esp) # ab/c
- ret
-.Lfe4:
- .size _bn_div64,.Lfe4-_bn_div64
- .ident "GCC: (GNU) 2.6.3"
diff --git a/crypto/bn/asm/x86-sol.s b/crypto/bn/asm/x86-sol.s
deleted file mode 100644
index c961e64fa0..0000000000
--- a/crypto/bn/asm/x86-sol.s
+++ /dev/null
@@ -1,224 +0,0 @@
- .file "bn_mulw.c"
- .version "01.01"
-gcc2_compiled.:
-.text
- .align 16
-.globl bn_mul_add_word
- .type bn_mul_add_word,@function
-bn_mul_add_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- / ax L(t)
- / dx H(t)
- / bx a
- / cx w
- / di r
- / si c
- / bp num
- xorl %esi,%esi / c=0
- movl 20(%esp),%edi / r => edi
- movl 24(%esp),%ebx / a => exb
- movl 28(%esp),%ebp / num => ebp
- movl 32(%esp),%ecx / w => ecx
-
- .align 4
-.L110:
- movl %ecx,%eax / w => eax
- mull (%ebx) / w * *a
- addl (%edi),%eax / L(t)+= *r
- adcl $0,%edx / H(t)+= carry
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L111
-
- movl %ecx,%eax / w => eax
- mull 4(%ebx) / w * *a
- addl 4(%edi),%eax / L(t)+= *r
- adcl $0,%edx / H(t)+= carry
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,4(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L111
-
- movl %ecx,%eax / w => eax
- mull 8(%ebx) / w * *a
- addl 8(%edi),%eax / L(t)+= *r
- adcl $0,%edx / H(t)+= carry
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,8(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L111
-
- movl %ecx,%eax / w => eax
- mull 12(%ebx) / w * *a
- addl 12(%edi),%eax / L(t)+= *r
- adcl $0,%edx / H(t)+= carry
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,12(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L111
-
- addl $16,%ebx / a+=4 (4 words)
- addl $16,%edi / r+=4 (4 words)
-
- jmp .L110
- .align 16
-.L111:
- movl %esi,%eax / return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe1:
- .size bn_mul_add_word,.Lfe1-bn_mul_add_word
- .align 16
-.globl bn_mul_word
- .type bn_mul_word,@function
-bn_mul_word:
- pushl %ebp
- pushl %edi
- pushl %esi
- pushl %ebx
-
- / ax L(t)
- / dx H(t)
- / bx a
- / cx w
- / di r
- / num bp
- / si c
- xorl %esi,%esi / c=0
- movl 20(%esp),%edi / r => edi
- movl 24(%esp),%ebx / a => exb
- movl 28(%esp),%ebp / num => ebp
- movl 32(%esp),%ecx / w => ecx
-
- .align 4
-.L210:
- movl %ecx,%eax / w => eax
- mull (%ebx) / w * *a
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L211
-
- movl %ecx,%eax / w => eax
- mull 4(%ebx) / w * *a
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,4(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L211
-
- movl %ecx,%eax / w => eax
- mull 8(%ebx) / w * *a
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,8(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L211
-
- movl %ecx,%eax / w => eax
- mull 12(%ebx) / w * *a
- addl %esi,%eax / L(t)+=c
- adcl $0,%edx / H(t)+=carry
- movl %eax,12(%edi) / *r=L(t)
- movl %edx,%esi / c=H(t)
- decl %ebp / --num
- je .L211
-
- addl $16,%ebx / a+=4 (4 words)
- addl $16,%edi / r+=4 (4 words)
-
- jmp .L210
- .align 16
-.L211:
- movl %esi,%eax / return(c)
- popl %ebx
- popl %esi
- popl %edi
- popl %ebp
- ret
-.Lfe2:
- .size bn_mul_word,.Lfe2-bn_mul_word
-
- .align 16
-.globl bn_sqr_words
- .type bn_sqr_words,@function
-bn_sqr_words:
- pushl %edi
- pushl %esi
- pushl %ebx
- movl 16(%esp),%esi / r
- movl 20(%esp),%edi / a
- movl 24(%esp),%ebx / n
- .align 4
-.L28:
- movl (%edi),%eax / get a
- mull %eax / a*a
- movl %eax,(%esi) / put low into return addr
- movl %edx,4(%esi) / put high into return addr
- decl %ebx / n--;
- je .L29
-
- movl 4(%edi),%eax / get a
- mull %eax / a*a
- movl %eax,8(%esi) / put low into return addr
- movl %edx,12(%esi) / put high into return addr
- decl %ebx / n--;
- je .L29
-
- movl 8(%edi),%eax / get a
- mull %eax / a*a
- movl %eax,16(%esi) / put low into return addr
- movl %edx,20(%esi) / put high into return addr
- decl %ebx / n--;
- je .L29
-
- movl 12(%edi),%eax / get a
- mull %eax / a*a
- movl %eax,24(%esi) / put low into return addr
- movl %edx,28(%esi) / put high into return addr
- decl %ebx / n--;
- je .L29
-
- addl $16,%edi
- addl $32,%esi
- jmp .L28
- .align 16
-.L29:
- popl %ebx
- popl %esi
- popl %edi
- ret
-.Lfe3:
- .size bn_sqr_words,.Lfe3-bn_sqr_words
-
- .align 16
-.globl bn_div64
- .type bn_div64,@function
-bn_div64:
- movl 4(%esp),%edx / a
- movl 8(%esp),%eax / b
- divl 12(%esp) / ab/c
- ret
-.Lfe4:
- .size bn_div64,.Lfe4-bn_div64
- .ident "GCC: (GNU) 2.6.3"
diff --git a/crypto/bn/asm/x86nt32.asm b/crypto/bn/asm/x86nt32.asm
deleted file mode 100644
index 0198c2c583..0000000000
--- a/crypto/bn/asm/x86nt32.asm
+++ /dev/null
@@ -1,288 +0,0 @@
- TITLE bn_mulw.c
- .386P
-.model FLAT
-PUBLIC _bn_mul_add_word
-_TEXT SEGMENT
-; File bn_mulw.c
-_bn_mul_add_word PROC NEAR
- push ebp
- push ebx
- push esi
- push edi
- mov edi,DWORD PTR 20[esp] ; r
- mov ebx,DWORD PTR 24[esp] ; a
- mov ecx,DWORD PTR 32[esp] ; w
- xor esi,esi ; c=0
-
- mov ebp,DWORD PTR 28[esp] ; num
- shr ebp,2 ; num/4
- jz $L666
-
-$L546:
- ; Round one
- mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR [edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR [edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
-
- ; Round two
- mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR 4[edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR 4[edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
-
- ; Round three
- mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR 8[edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR 8[edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
-
- ; Round four
- mov eax,DWORD PTR 12[ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR 12[edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR 12[edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
-
- add ebx,16
- add edi,16
-
- dec ebp
- jz $L666
- jmp $L546
-$L666:
- mov ebp,DWORD PTR 28[esp] ; num
- and ebp,3 ; num%4
- jz $L547
-
- ; Round one
- mov eax,DWORD PTR [ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR [edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR [edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
- dec ebp
- jz $L547
- ; Round two
- mov eax,DWORD PTR 4[ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR 4[edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR 4[edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
- dec ebp
- jz $L547
- ; Round three
- mov eax,DWORD PTR 8[ebx] ; edx:eax = *a * w
- mul ecx
- add eax,DWORD PTR 8[edi] ; *r+=ax
- adc edx,0
- add eax,esi ; edx:eax += c
- adc edx,0
- mov DWORD PTR 8[edi],eax ; *r+=ax
- mov esi,edx ; c = overflow
-
-$L547:
- mov eax,esi
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-_bn_mul_add_word ENDP
-_TEXT ENDS
-PUBLIC _bn_mul_word
-_TEXT SEGMENT
-_bn_mul_word PROC NEAR
- push ebp
- push ebx
- push esi
- push edi
-
- mov edi,DWORD PTR 20[esp] ; r
- mov ebx,DWORD PTR 24[esp] ; a
- mov ebp,DWORD PTR 28[esp] ; num
- mov ecx,DWORD PTR 32[esp] ; w
- xor esi,esi ; c=0
-
- shr ebp,2 ; num/4
- jz $L266
-
-$L593:
- ; Round one
- mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR [edi],eax ; *r=eax
- mov esi,edx ; c=edx
- ; Round two
- mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR 4[edi],eax ; *r=eax
- mov esi,edx ; c=edx
- ; Round three
- mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR 8[edi],eax ; *r=eax
- mov esi,edx ; c=edx
- ; Round four
- mov eax,DWORD PTR 12[ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR 12[edi],eax ; *r=eax
- mov esi,edx ; c=edx
-
- add ebx,16
- add edi,16
-
- dec ebp
- jz $L266
- jmp $L593
-$L266:
- mov ebp,DWORD PTR 28[esp] ; num
- and ebp,3
- jz $L601
-
- ; Round one
- mov eax,DWORD PTR [ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR [edi],eax ; *r=eax
- mov esi,edx ; c=edx
- dec ebp
- jz $L601
- ; Round two
- mov eax,DWORD PTR 4[ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR 4[edi],eax ; *r=eax
- mov esi,edx ; c=edx
- dec ebp
- jz $L601
- ; Round three
- mov eax,DWORD PTR 8[ebx] ; edx:eax= w * *a
- mul ecx
- add eax,esi ; edx:eax+=c
- adc edx,0
- mov DWORD PTR 8[edi],eax ; *r=eax
- mov esi,edx ; c=edx
-
-$L601:
- mov eax,esi
- pop edi
- pop esi
- pop ebx
- pop ebp
- ret
-_bn_mul_word ENDP
-_TEXT ENDS
-PUBLIC _bn_sqr_words
-_TEXT SEGMENT
-_bn_sqr_words PROC NEAR
- push ebx
- push esi
- push edi
- mov esi,DWORD PTR 16[esp] ; r
- mov edi,DWORD PTR 20[esp] ; a
- mov ebx,DWORD PTR 24[esp] ; num
-
- shr ebx,2 ; num/4
- jz $L111
-$L640:
- ; Round 1
- mov eax, DWORD PTR [edi]
- mul eax ; *a * *a
- mov DWORD PTR [esi],eax
- mov DWORD PTR 4[esi],edx
- ; Round 2
- mov eax, DWORD PTR 4[edi]
- mul eax ; *a * *a
- mov DWORD PTR 8[esi],eax
- mov DWORD PTR 12[esi],edx
- ; Round 3
- mov eax, DWORD PTR 8[edi]
- mul eax ; *a * *a
- mov DWORD PTR 16[esi],eax
- mov DWORD PTR 20[esi],edx
- ; Round 4
- mov eax, DWORD PTR 12[edi]
- mul eax ; *a * *a
- mov DWORD PTR 24[esi],eax
- mov DWORD PTR 28[esi],edx
-
- add edi,16
- add esi,32
-
- dec ebx
- jz $L111
- jmp $L640
-$L111:
- mov ebx,DWORD PTR 24[esp] ; num
- and ebx,3 ; num%3
- jz $L645
-
- ; Round 1
- mov eax, DWORD PTR [edi]
- mul eax ; *a * *a
- mov DWORD PTR [esi],eax
- mov DWORD PTR 4[esi],edx
- dec ebx
- jz $L645
- ; Round 2
- mov eax, DWORD PTR 4[edi]
- mul eax ; *a * *a
- mov DWORD PTR 8[esi],eax
- mov DWORD PTR 12[esi],edx
- dec ebx
- jz $L645
- ; Round 3
- mov eax, DWORD PTR 8[edi]
- mul eax ; *a * *a
- mov DWORD PTR 16[esi],eax
- mov DWORD PTR 20[esi],edx
-
-$L645:
- pop edi
- pop esi
- pop ebx
- ret
-_bn_sqr_words ENDP
-_TEXT ENDS
-PUBLIC _bn_div64
-_TEXT SEGMENT
-_bn_div64 PROC NEAR
- mov edx, DWORD PTR 4[esp]
- mov eax, DWORD PTR 8[esp]
- div DWORD PTR 12[esp]
- ret
-_bn_div64 ENDP
-_TEXT ENDS
-END
diff --git a/crypto/bn/bn_bld.c b/crypto/bn/bn_bld.c
deleted file mode 100644
index 966db43962..0000000000
--- a/crypto/bn/bn_bld.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/* crypto/bn/bn_bld.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn_lcl.h"
-
-BN_BL_CTX *BN_BL_CTX_new()
- {
- BN_BL_CTX *ret;
-
- if ((ret=(BN_BL_CTX *)Malloc(sizeof(BN_BL_CTX))) == NULL)
- {
- BNerr(BN_F_BN_BL_CTX_NEW,ERR_R_MALLOC_FAILURE);
- return(NULL);
- }
- if ((ret->num=BN_new()) == NULL) goto err;
- if ((ret->mod=BN_new()) == NULL) goto err;
- ret->inum=NULL;
- ret->count=16;
- ret->count=1;
- return(ret);
- }
-
-int BN_BL_CTX_Init(a,mod)
-BN_BL_CTX *a;
-BIGNUM *mod;
- {
- int i;
- BN_CTX *ctx;
-
- if ((ctx=BN_CTX_new()) == NULL) goto m_err;
-
- if (BN_copy(a->mod,mod) == NULL) goto err;
- i=BN_num_bits(mod);
- if (!BN_rand(a->num,i,1,0)) goto err;
-
- if (a->inum != NULL) BN_clear_free(a->inum);
- a->inum=BN_mod_inverse(a->num,a->mod,ctx)
- ret->count=16;
- return(1);
-m_err:
- BNerr(BN_F_BN_BL_CTX_INIT,ERR_R_MALLOC_FAILURE);
-err:
- return(0);
- }
-
-BN_BL_CTX *BN_BL_CTX_Update(a)
-BN_BL_CTX *a;
- {
- BN_CTX *ctx;
- BN_BL_CTX *new;
-
- if (--a->count > 0)
- return(1);
-
- new=BN_BL_CTX_new();
- /* set/get lock */
- if ((ctx=BN_CTX_new()) == NULL)
- return(NULL);
- new->inum=BN_new();
-
- BN_mod_mul(new->num,a->num,a->num,a->mod,ctx);
- BN_mod_mul(new->inum,a->inum,a->inum,a->mod,ctx);
- BN_copy(new->mod,a->mod);
- BN_BL_CTX_free(a);
- return(new);
- }
-
-void BN_BL_CTX_free(a)
-BN_BL_CTX *a;
- {
- int i;
-
- if (a == NULL) return;
-
- i=CRYPTO_add(&a->references,-1,CRYPTO_LOCK_RSA);
- if (i > 0) return;
-#ifdef REF_CHECK
- if (i < 0)
- {
- fprintf(stderr,"BN_BL_CTX_free, bad reference count\n");
- abort();
- }
-#endif
- if (a->num == NULL) BN_clear_free(a->num);
- if (a->inum == NULL) BN_clear_free(a->inum);
- if (a->mod == NULL) BN_clear_free(a->mod);
- }
diff --git a/crypto/bn/bn_mod.c b/crypto/bn/bn_mod.c
deleted file mode 100644
index c351aac14f..0000000000
--- a/crypto/bn/bn_mod.c
+++ /dev/null
@@ -1,97 +0,0 @@
-/* crypto/bn/bn_mod.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn_lcl.h"
-
-/* rem != m */
-int BN_mod(rem, m, d,ctx)
-BIGNUM *rem;
-BIGNUM *m;
-BIGNUM *d;
-BN_CTX *ctx;
- {
-#if 0 /* The old slow way */
- int i,nm,nd;
- BIGNUM *dv;
-
- if (BN_ucmp(m,d) < 0)
- return((BN_copy(rem,m) == NULL)?0:1);
-
- dv=ctx->bn[ctx->tos];
-
- if (!BN_copy(rem,m)) return(0);
-
- nm=BN_num_bits(rem);
- nd=BN_num_bits(d);
- if (!BN_lshift(dv,d,nm-nd)) return(0);
- for (i=nm-nd; i>=0; i--)
- {
- if (BN_cmp(rem,dv) >= 0)
- {
- if (!BN_sub(rem,rem,dv)) return(0);
- }
- if (!BN_rshift1(dv,dv)) return(0);
- }
- return(1);
-#else
- return(BN_div(NULL,rem,m,d,ctx));
-#endif
- }
-
diff --git a/crypto/bn/bn_sub.c b/crypto/bn/bn_sub.c
deleted file mode 100644
index bba80f8afb..0000000000
--- a/crypto/bn/bn_sub.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/* crypto/bn/bn_sub.c */
-/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
- * All rights reserved.
- *
- * This package is an SSL implementation written
- * by Eric Young (eay@cryptsoft.com).
- * The implementation was written so as to conform with Netscapes SSL.
- *
- * This library is free for commercial and non-commercial use as long as
- * the following conditions are aheared to. The following conditions
- * apply to all code found in this distribution, be it the RC4, RSA,
- * lhash, DES, etc., code; not just the SSL code. The SSL documentation
- * included with this distribution is covered by the same copyright terms
- * except that the holder is Tim Hudson (tjh@cryptsoft.com).
- *
- * Copyright remains Eric Young's, and as such any Copyright notices in
- * the code are not to be removed.
- * If this package is used in a product, Eric Young should be given attribution
- * as the author of the parts of the library used.
- * This can be in the form of a textual message at program startup or
- * in documentation (online or textual) provided with the package.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * "This product includes cryptographic software written by
- * Eric Young (eay@cryptsoft.com)"
- * The word 'cryptographic' can be left out if the rouines from the library
- * being used are not cryptographic related :-).
- * 4. If you include any Windows specific code (or a derivative thereof) from
- * the apps directory (application code) you must include an acknowledgement:
- * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
- *
- * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * The licence and distribution terms for any publically available version or
- * derivative of this code cannot be changed. i.e. this code cannot simply be
- * copied and put under another distribution licence
- * [including the GNU Public Licence.]
- */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn_lcl.h"
-
-/* unsigned subtraction of b from a, a must be larger than b. */
-void bn_qsub(r, a, b)
-BIGNUM *r;
-BIGNUM *a;
-BIGNUM *b;
- {
- int max,min;
- register BN_ULONG t1,t2,*ap,*bp,*rp;
- int i,carry;
-#if defined(IRIX_CC_BUG) && !defined(LINT)
- int dummy;
-#endif
-
- max=a->top;
- min=b->top;
- ap=a->d;
- bp=b->d;
- rp=r->d;
-
- carry=0;
- for (i=0; i<min; i++)
- {
- t1= *(ap++);
- t2= *(bp++);
- if (carry)
- {
- carry=(t1 <= t2);
- t1=(t1-t2-1)&BN_MASK2;
- }
- else
- {
- carry=(t1 < t2);
- t1=(t1-t2)&BN_MASK2;
- }
-#if defined(IRIX_CC_BUG) && !defined(LINT)
- dummy=t1;
-#endif
- *(rp++)=t1&BN_MASK2;
- }
- if (carry) /* subtracted */
- {
- while (i < max)
- {
- i++;
- t1= *(ap++);
- t2=(t1-1)&BN_MASK2;
- *(rp++)=t2;
- if (t1 > t2) break;
- }
- }
-#if 0
- memcpy(rp,ap,sizeof(*rp)*(max-i));
-#else
- for (; i<max; i++)
- *(rp++)= *(ap++);
-#endif
-
- r->top=max;
- bn_fix_top(r);
- }
-
-int BN_sub(r, a, b)
-BIGNUM *r;
-BIGNUM *a;
-BIGNUM *b;
- {
- int max,i;
- int add=0,neg=0;
- BIGNUM *tmp;
-
- /* a - b a-b
- * a - -b a+b
- * -a - b -(a+b)
- * -a - -b b-a
- */
- if (a->neg)
- {
- if (b->neg)
- { tmp=a; a=b; b=tmp; }
- else
- { add=1; neg=1; }
- }
- else
- {
- if (b->neg) { add=1; neg=0; }
- }
-
- if (add)
- {
- /* As a fast max size, do a a->top | b->top */
- i=(a->top | b->top)+1;
- if (bn_wexpand(r,i) == NULL)
- return(0);
- if (i)
- bn_qadd(r,a,b);
- else
- bn_qadd(r,b,a);
- r->neg=neg;
- return(1);
- }
-
- /* We are actually doing a - b :-) */
-
- max=(a->top > b->top)?a->top:b->top;
- if (bn_wexpand(r,max) == NULL) return(0);
- if (BN_ucmp(a,b) < 0)
- {
- bn_qsub(r,b,a);
- r->neg=1;
- }
- else
- {
- bn_qsub(r,a,b);
- r->neg=0;
- }
- return(1);
- }
-
diff --git a/crypto/bn/m.pl b/crypto/bn/m.pl
deleted file mode 100644
index f69b036666..0000000000
--- a/crypto/bn/m.pl
+++ /dev/null
@@ -1,32 +0,0 @@
-#!/usr/local/bin/perl
-
-
-for ($i=0; $i<256; $i++)
- {
- for ($j=0; $j<256; $j++)
- {
- $a0=$i&0x0f;
- $a1=($i>>4)&0x0f;
- $b0=$j&0x0f;
- $b1=($j>>4)&0x0f;
-
- $a0b0=$a0*$b0;
- $a1b1=$a1*$b1;
-
- $a01=$a0-$a1;
- $b10=$b1-$b0;
- $a01b10=$a01*$b10;
-
- if ($a01b10 < 0)
- {
- $neg=1;
- $a01b10= -$a01b10;
- }
- $t=($a0b0>>4)+($a0b0&0x0f)+($a1b1&0x0f);
- if ($neg)
- { $t-=($a01b10&0x0f); }
- else { $t+=($a01b10&0x0f); }
- printf("%02X %s%02X %02X\n",$a1b1,($neg)?"-":" ",$a01b10,$a0b0)
- if ($t < 0)
- }
- }
diff --git a/crypto/bn/stuff/bn_knuth.c b/crypto/bn/stuff/bn_knuth.c
deleted file mode 100644
index 9a3f4130ed..0000000000
--- a/crypto/bn/stuff/bn_knuth.c
+++ /dev/null
@@ -1,378 +0,0 @@
-/* crypto/bn/bn_knuth.c */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn.h"
-
-/* This is just a test implementation, it has not been modified for
- * speed and it still has memory leaks. */
-
-int BN_mask_bits(BIGNUM *a,int n);
-
-#undef DEBUG
-#define MAIN
-
-/* r must be different to a and b
- * Toom-Cook multiplication algorithm, taken from
- * The Art Of Computer Programming, Volume 2, Donald Knuth
- */
-
-#define CODE1 ((BIGNUM *)0x01)
-#define CODE2 ((BIGNUM *)0x02)
-#define CODE3 ((BIGNUM *)0x03)
-#define MAXK (30+1)
-
-#define C3 3
-#define C4 4
-#define C5 5
-#define C6 6
-#define C7 7
-#define C8 8
-#define C9 9
-#define C10 10
-#define DONE 11
-
-int new_total=0;
-int Free_total=0;
-int max=0,max_total=0;
-
-BIGNUM *LBN_new(void );
-BIGNUM *LBN_dup(BIGNUM *a);
-void LBN_free(BIGNUM *a);
-
-int BN_mul_knuth(w, a, b)
-BIGNUM *w;
-BIGNUM *a;
-BIGNUM *b;
- {
- int ret=1;
- int i,j,n,an,bn,y,z;
- BIGNUM *U[MAXK],*V[MAXK],*T[MAXK];
- BIGNUM *C[(MAXK*2*3)];
- BIGNUM *W[(MAXK*2)],*t1,*t2,*t3,*t4;
- int Utos,Vtos,Ctos,Wtos,Ttos;
- unsigned int k,Q,R;
- unsigned int q[MAXK];
- unsigned int r[MAXK];
- int state;
-
- /* C1 */
- Utos=Vtos=Ctos=Wtos=Ttos=0;
- k=1;
- q[0]=q[1]=64;
- r[0]=r[1]=4;
- Q=6;
- R=2;
-
- if (!bn_expand(w,BN_BITS2*2)) goto err;
- an=BN_num_bits(a);
- bn=BN_num_bits(b);
- n=(an > bn)?an:bn;
- while ((q[k-1]+q[k]) < n)
- {
- k++;
- Q+=R;
- i=R+1;
- if ((i*i) <= Q) R=i;
- q[k]=(1<<Q);
- r[k]=(1<<R);
- }
-#ifdef DEBUG
- printf("k =");
- for (i=0; i<=k; i++) printf("%7d",i);
- printf("\nq[k]=");
- for (i=0; i<=k; i++) printf("%7d",q[i]);
- printf("\nr[k]=");
- for (i=0; i<=k; i++) printf("%7d",r[i]);
- printf("\n");
-#endif
-
- /* C2 */
- C[Ctos++]=CODE1;
- if ((t1=LBN_dup(a)) == NULL) goto err;
- C[Ctos++]=t1;
- if ((t1=LBN_dup(b)) == NULL) goto err;
- C[Ctos++]=t1;
-
- state=C3;
- for (;;)
- {
-#ifdef DEBUG
- printf("state=C%d, Ctos=%d Wtos=%d\n",state,Ctos,Wtos);
-#endif
- switch (state)
- {
- int lr,lq,lp;
- case C3:
- k--;
- if (k == 0)
- {
- t1=C[--Ctos];
- t2=C[--Ctos];
-#ifdef DEBUG
- printf("Ctos=%d poped %d\n",Ctos,2);
-#endif
- if ((t2->top == 0) || (t1->top == 0))
- w->top=0;
- else
- BN_mul(w,t1,t2);
-
- LBN_free(t1); /* FREE */
- LBN_free(t2); /* FREE */
- state=C10;
- }
- else
- {
- lr=r[k];
- lq=q[k];
- lp=q[k-1]+q[k];
- state=C4;
- }
- break;
- case C4:
- for (z=0; z<2; z++) /* do for u and v */
- {
- /* break the item at C[Ctos-1]
- * into lr+1 parts of lq bits each
- * for j=0; j<=2r; j++
- */
- t1=C[--Ctos]; /* pop off u */
-#ifdef DEBUG
- printf("Ctos=%d poped %d\n",Ctos,1);
-#endif
- if ((t2=LBN_dup(t1)) == NULL) goto err;
- BN_mask_bits(t2,lq);
- T[Ttos++]=t2;
-#ifdef DEBUG
- printf("C4 r=0 bits=%d\n",BN_num_bits(t2));
-#endif
- for (i=1; i<=lr; i++)
- {
- if (!BN_rshift(t1,t1,lq)) goto err;
- if ((t2=LBN_dup(t1)) == NULL) goto err;
- BN_mask_bits(t2,lq);
- T[Ttos++]=t2;
-#ifdef DEBUG
- printf("C4 r=%d bits=%d\n",i,
- BN_num_bits(t2));
-#endif
- }
- LBN_free(t1);
-
- if ((t2=LBN_new()) == NULL) goto err;
- if ((t3=LBN_new()) == NULL) goto err;
- for (j=0; j<=2*lr; j++)
- {
- if ((t1=LBN_new()) == NULL) goto err;
-
- if (!BN_set_word(t3,j)) goto err;
- for (i=lr; i>=0; i--)
- {
- if (!BN_mul(t2,t1,t3)) goto err;
- if (!BN_add(t1,t2,T[i])) goto err;
- }
- /* t1 is U(j) */
- if (z == 0)
- U[Utos++]=t1;
- else
- V[Vtos++]=t1;
- }
- LBN_free(t2);
- LBN_free(t3);
- while (Ttos) LBN_free(T[--Ttos]);
- }
-#ifdef DEBUG
- for (i=0; i<Utos; i++)
- printf("U[%2d]=%4d bits\n",i,BN_num_bits(U[i]));
- for (i=0; i<Vtos; i++)
- printf("V[%2d]=%4d bits\n",i,BN_num_bits(V[i]));
-#endif
- /* C5 */
-#ifdef DEBUG
- printf("PUSH CODE2 and %d CODE3 onto stack\n",2*lr);
-#endif
- C[Ctos++]=CODE2;
- for (i=2*lr; i>0; i--)
- {
- C[Ctos++]=V[i];
- C[Ctos++]=U[i];
- C[Ctos++]=CODE3;
- }
- C[Ctos++]=V[0];
- C[Ctos++]=U[0];
-#ifdef DEBUG
- printf("Ctos=%d pushed %d\n",Ctos,2*lr*3+3);
-#endif
- Vtos=Utos=0;
- state=C3;
- break;
- case C6:
- if ((t1=LBN_dup(w)) == NULL) goto err;
- W[Wtos++]=t1;
-#ifdef DEBUG
- printf("put %d bit number onto w\n",BN_num_bits(t1));
-#endif
- state=C3;
- break;
- case C7:
- lr=r[k];
- lq=q[k];
- lp=q[k]+q[k-1];
- z=Wtos-2*lr-1;
- for (j=1; j<=2*lr; j++)
- {
- for (i=2*lr; i>=j; i--)
- {
- if (!BN_sub(W[z+i],W[z+i],W[z+i-1])) goto err;
- BN_div_word(W[z+i],j);
- }
- }
- state=C8;
- break;
- case C8:
- y=2*lr-1;
- if ((t1=LBN_new()) == NULL) goto err;
- if ((t3=LBN_new()) == NULL) goto err;
-
- for (j=y; j>0; j--)
- {
- if (!BN_set_word(t3,j)) goto err;
- for (i=j; i<=y; i++)
- {
- if (!BN_mul(t1,W[z+i+1],t3)) goto err;
- if (!BN_sub(W[z+i],W[z+i],t1)) goto err;
- }
- }
- LBN_free(t1);
- LBN_free(t3);
- state=C9;
- break;
- case C9:
- BN_zero(w);
-#ifdef DEBUG
- printf("lq=%d\n",lq);
-#endif
- for (i=lr*2; i>=0; i--)
- {
- BN_lshift(w,w,lq);
- BN_add(w,w,W[z+i]);
- }
- for (i=0; i<=lr*2; i++)
- LBN_free(W[--Wtos]);
- state=C10;
- break;
- case C10:
- k++;
- t1=C[--Ctos];
-#ifdef DEBUG
- printf("Ctos=%d poped %d\n",Ctos,1);
- printf("code= CODE%d\n",t1);
-#endif
- if (t1 == CODE3)
- state=C6;
- else if (t1 == CODE2)
- {
- if ((t2=LBN_dup(w)) == NULL) goto err;
- W[Wtos++]=t2;
- state=C7;
- }
- else if (t1 == CODE1)
- {
- state=DONE;
- }
- else
- {
- printf("BAD ERROR\n");
- goto err;
- }
- break;
- default:
- printf("bad state\n");
- goto err;
- break;
- }
- if (state == DONE) break;
- }
- ret=1;
-err:
- if (ret == 0) printf("ERROR\n");
- return(ret);
- }
-
-#ifdef MAIN
-main()
- {
- BIGNUM *a,*b,*r;
- int i;
-
- if ((a=LBN_new()) == NULL) goto err;
- if ((b=LBN_new()) == NULL) goto err;
- if ((r=LBN_new()) == NULL) goto err;
-
- if (!BN_rand(a,1024*2,0,0)) goto err;
- if (!BN_rand(b,1024*2,0,0)) goto err;
-
- for (i=0; i<10; i++)
- {
- if (!BN_mul_knuth(r,a,b)) goto err; /**/
- /*if (!BN_mul(r,a,b)) goto err; /**/
- }
-BN_print(stdout,a); printf(" * ");
-BN_print(stdout,b); printf(" =\n");
-BN_print(stdout,r); printf("\n");
-
-printf("BN_new() =%d\nBN_free()=%d max=%d\n",new_total,Free_total,max);
-
-
- exit(0);
-err:
- ERR_load_crypto_strings();
- ERR_print_errors(stderr);
- exit(1);
- }
-#endif
-
-int BN_mask_bits(a,n)
-BIGNUM *a;
-int n;
- {
- int b,w;
-
- w=n/BN_BITS2;
- b=n%BN_BITS2;
- if (w >= a->top) return(0);
- if (b == 0)
- a->top=w;
- else
- {
- a->top=w+1;
- a->d[w]&= ~(BN_MASK2<<b);
- }
- return(1);
- }
-
-BIGNUM *LBN_dup(a)
-BIGNUM *a;
- {
- new_total++;
- max_total++;
- if (max_total > max) max=max_total;
- return(BN_dup(a));
- }
-
-BIGNUM *LBN_new()
- {
- new_total++;
- max_total++;
- if (max_total > max) max=max_total;
- return(BN_new());
- }
-
-void LBN_free(a)
-BIGNUM *a;
- {
- max_total--;
- if (max_total > max) max=max_total;
- Free_total++;
- BN_free(a);
- }
diff --git a/crypto/bn/stuff/div.c b/crypto/bn/stuff/div.c
deleted file mode 100644
index 3d6e08622d..0000000000
--- a/crypto/bn/stuff/div.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/* crypto/bn/div.c */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn.h"
-
-BN_ULONG bn_div_2word();
-
-int BN_div2(dv, rm, num, div,ctx)
-BIGNUM *dv;
-BIGNUM *rm;
-BIGNUM *num;
-BIGNUM *div;
-BN_CTX *ctx;
- {
- int norm_shift,i,j,nm,nd,loop;
- BIGNUM *tmp,wnum,*snum,*sdiv,*res;
- BN_ULONG *resp,*wnump;
- BN_ULONG d0,d1;
- int num_n,div_n;
-
-#ifdef DEBUG
-BN_print(stdout,num); printf(" number\n");
-BN_print(stdout,div); printf(" divisor\n");
-#endif
- if (BN_is_zero(num))
- {
- BNerr(BN_F_BN_DIV,BN_R_DIV_BY_ZERO);
- return(0);
- }
-
- if (BN_cmp(num,div) < 0)
- {
- if (rm != NULL)
- { if (BN_copy(rm,num) == NULL) return(0); }
- if (dv != NULL) BN_zero(dv);
- return(1);
- }
-
- tmp=ctx->bn[ctx->tos];
- snum=ctx->bn[ctx->tos+1];
- sdiv=ctx->bn[ctx->tos+2];
- if (dv == NULL)
- res=ctx->bn[ctx->tos+3];
- else res=dv;
-
- /* First we normalise the numbers */
- norm_shift=BN_BITS2-((BN_num_bits(div))%BN_BITS2);
- BN_lshift(sdiv,div,norm_shift);
- norm_shift+=BN_BITS2;
- BN_lshift(snum,num,norm_shift);
- div_n=sdiv->top;
- num_n=snum->top;
- loop=num_n-div_n;
-#ifdef DEBUG
-BN_print(stdout,snum); printf(" shifted num, forget last word\n");
-BN_print(stdout,sdiv); printf(" shifted div\n");
-#endif
-
- /* Lets setup a 'win'dow into snum
- * This is the part that corresponds to the current
- * 'area' being divided */
- wnum.d= &(snum->d[loop]);
- wnum.top= div_n;
- wnum.max= snum->max; /* a bit of a lie */
- wnum.neg= 0;
-
- /* Get the top 2 words of sdiv */
- i=sdiv->top;
- d0=sdiv->d[div_n-1];
- d1=sdiv->d[div_n-2];
-
- /* pointer to the 'top' of snum */
- wnump= &(snum->d[num_n-1]);
-
- /* Setup to 'res' */
- res->neg=0;
- res->top=loop;
- resp= &(res->d[loop-1]);
- bn_expand(res,(loop+1)*BN_BITS2);
-
- /* space for temp */
- bn_expand(tmp,(div_n+1)*BN_BITS2);
-
-#ifdef DEBUG
-printf("wnum="); BN_print(stdout,&wnum); printf(" initial sub check\n");
-printf("div ="); BN_print(stdout,sdiv); printf(" loop=%d\n",loop);
-#endif
- if (BN_cmp(&wnum,sdiv) >= 0)
- {
- BN_sub(&wnum,&wnum,sdiv);
- *resp=1;
- res->d[res->top-1]=1;
- }
- else
- res->top--;
- resp--;
-#ifdef DEBUG
-BN_print(stdout,res); printf(" initial result\n");
-BN_print(stdout,&wnum); printf(" wnum\n");
-#endif
-
- for (i=0; i<loop-1; i++)
- {
- BN_ULONG q,n0;
- BN_ULLONG t1,t2,t3;
- BN_ULONG l0;
-
- wnum.d--;
- wnum.top++;
-
-#ifdef DEBUG
-BN_print(stderr,&wnum); printf(" to divide\n");
-#endif
-
- q=0;
- n0=wnump[0];
- t1=((BN_ULLONG)n0<<BN_BITS2)|wnump[-1];
- if (n0 == d0)
- q=BN_MASK2;
- else
- {
- t2=(t1/d0);
- q=(t2&BN_MASK2);
-#ifdef DEBUG
-printf("t1=%08X / d0=%08X = %X (%X)\n",t1,d0,q,t2);
-#endif
- }
- for (;;)
- {
- t2=(BN_ULLONG)d1*q;
- t3=t1-(BN_ULLONG)q*d0;
-#ifdef DEBUG
-printf("d1*q= %X n01-q*d0 = %X\n",t2,t3);
-#endif
- if ((t3>>BN_BITS2) ||
- (t2 <= ((t3<<BN_BITS2)+wnump[-2])))
- break;
-#ifdef DEBUG
-printf("reduce q\n");
-#endif
- q--;
- }
- l0=bn_mul_word(tmp->d,sdiv->d,div_n,q);
- if (l0)
- tmp->d[div_n]=l0;
- else
- tmp->d[div_n]=0;
- for (j=div_n+1; j>0; j--)
- if (tmp->d[j-1]) break;
- tmp->top=j;
-
-#ifdef DEBUG
-printf("q=%08X\n",q);
-BN_print(stdout,&wnum); printf(" number\n");
-BN_print(stdout,tmp); printf(" subtract\n");
-
-BN_print(stdout,snum); printf(" shifted number before\n");
-BN_print(stdout,&wnum); printf(" wnum before\n");
-#endif
- j=wnum.top;
- BN_sub(&wnum,&wnum,tmp);
- snum->top=snum->top+wnum.top-j;
-
-#ifdef DEBUG
-BN_print(stdout,&wnum); printf(" wnum after\n");
-BN_print(stdout,snum); printf(" shifted number after\n");
-#endif
-
- if (wnum.neg)
- {
- q--;
- j=wnum.top;
- BN_add(&wnum,&wnum,sdiv);
- snum->top+=wnum.top-j;
- fprintf(stderr,"addback\n");
-#ifdef DEBUG
-BN_print(stdout,snum); printf("after addback************************:\n");
-#endif
- }
- *(resp--)=q;
-#ifdef DEBUG
-BN_print(stdout,res); printf(" result\n");
-#endif
- wnump--;
- }
- if (rm != NULL)
- BN_rshift(rm,snum,norm_shift);
- return(1);
- }
-
-main()
- {
- BIGNUM *a,*b,*c,*d;
- BIGNUM *cc,*dd;
- BN_CTX *ctx;
- int i,x;
-
- a=BN_new();
- b=BN_new();
- c=BN_new();
- d=BN_new();
- cc=BN_new();
- dd=BN_new();
- ctx=BN_CTX_new();
-
-for (i=0; i<10240; i++)
- {
- BN_rand(a,80,0,0);
- BN_rand(b,60,0,0);
-
- BN_div2(d,c,a,b,ctx);
- BN_div(dd,cc,a,b,ctx);
- if ((BN_cmp(d,dd) != 0) || (BN_cmp(c,cc) != 0))
- {
- BN_print(stderr,a); fprintf(stderr," / ");
- BN_print(stderr,b); fprintf(stderr," d=");
- BN_print(stderr,d); fprintf(stderr," r= ");
- BN_print(stderr,c); fprintf(stderr,"\nd=");
- BN_print(stderr,dd); fprintf(stderr," r= ");
- BN_print(stderr,cc); fprintf(stderr,"\n");
- }
-
- }
-
-#ifdef undef
-/*
- BN_rand(a,600,0,0);
- BN_rand(b,400,0,0);
- for (i=0; i<2000000; i++)
- {
- BN_div2(d,c,a,b,ctx);
- }
-*/
-/* for (i=0;;) */
-/* for (i=0; i<0xffffffff; i++)
- {
- BN_ULONG rr,r,a,b,c;
- BN_ULLONG l;
-
- a=rand()&BN_MASK2;
- b=rand()&BN_MASK2;
- for (;;)
- {
- c=rand()&BN_MASK2;
- if (c) break;
- }
-/* for (x=1; x<256*256; x++) */
- {
- c=x;
- a=i>>8;
- b=i&0xff;
- a&= ~(0xFFFFFF<<(BN_num_bits_word(c)));
-
- r=bn_div_2word(a,b,c);
-
- rr=(BN_ULONG)((((BN_ULLONG)a<<BN_BITS2)|b)/c);
-
- if ((i & 0xfffff) == 0) fprintf(stderr,"%d\n",i,r,rr);
-/*if (x == 255)
- fprintf(stderr,"%6d/%3d = %4d %4d\n",(a<<8)|b,c,r,rr); */
- if (rr != r)
- {
- fprintf(stderr,"%8d %02X%02X / %02X = %02X %02X\n",
- i,a,b,c,rr,r);
- abort();
- }
- }
- }
-#endif
- }
-
-/* Divide h-l by d and return the result. */
-BN_ULONG bn_div_2word(l,h,d)
-BN_ULONG l,h,d;
- {
- BN_ULONG dh,dl,q,ret=0,th,tl,t,top;
- int i,count=2;
-
- if (d == 0) return(-1);
-
- i=BN_num_bits_word(d);
- if ((i != BN_BITS2) && (h > 1<<i))
- {
- fprintf(stderr,"Division would overflow\n");
- abort();
- }
- i=BN_BITS2-i;
- if (h >= d) h-=d;
-
- if (i)
- {
- d<<=i;
- h=(h<<i)|(l>>(BN_BITS2-i));
- l<<=i;
- }
- dh=(d&BN_MASK2h)>>BN_BITS4;
- dl=(d&BN_MASK2l);
- for (;;)
- {
- if ((h>>BN_BITS4) == dh)
- q=BN_MASK2l;
- else
- q=h/dh;
-
- for (;;)
- {
- t=(h-q*dh);
- if ((t&BN_MASK2h) ||
- ((dl*q) <= (
- (t<<BN_BITS4)+
- ((l&BN_MASK2h)>>BN_BITS4))))
- break;
- q--;
- }
- th=q*dh;
- tl=q*dl;
- t=(tl>>BN_BITS4);
- tl=(tl<<BN_BITS4)&BN_MASK2h;
- th+=t;
-
- if (l < tl) th++;
- l-=tl;
- if (h < th)
- {
- fprintf(stderr,"add back\n");
- h+=d;
- q--;
- }
- h-=th;
-
- if (--count == 0) break;
-
- ret=q<<BN_BITS4;
- h=((h<<BN_BITS4)|(l>>BN_BITS4))&BN_MASK2;
- l=(l&BN_MASK2l)<<BN_BITS4;
- }
- ret|=q;
- return(ret);
- }
diff --git a/crypto/bn/stuff/mont.doc b/crypto/bn/stuff/mont.doc
deleted file mode 100644
index 55d1d79312..0000000000
--- a/crypto/bn/stuff/mont.doc
+++ /dev/null
@@ -1,17 +0,0 @@
-All numbers (a) are stored aR mod N (except abRR)
-
-RR = REDC(R*R) /* RR mod N */
-
-
-convert a -> aR
-convert b -> bR
-
- {
- abRR = aR * bR
- abR = REDC(abRR); /* mod N */
- }
-
-ab = REDC(abR); /* mod N */
-
-
-REDC strips off a multiplicaion by R mod N
diff --git a/crypto/bn/stuff/wei_mulw.c b/crypto/bn/stuff/wei_mulw.c
deleted file mode 100644
index 7f8a1e58fe..0000000000
--- a/crypto/bn/stuff/wei_mulw.c
+++ /dev/null
@@ -1,410 +0,0 @@
-/* crypto/bn/wei_mulw.c */
-
-#include <stdio.h>
-#include "cryptlib.h"
-#include "bn.h"
-#include "bn_lcl.h"
-
-BN_ULONG bn_add_word(BN_ULONG *a,BN_ULONG c,int num);
-BN_ULONG bn_add_words(BN_ULONG *ret,BN_ULONG *a,BN_ULONG *b,int num);
-BN_ULONG bn_sub_words(BN_ULONG *ret,BN_ULONG *a,BN_ULONG *b,int num);
-
-void BN_mul_4words(BN_ULONG *ret,BN_ULONG a0,BN_ULONG a1,
- BN_ULONG b0,BN_ULONG b1);
-
-void pr(a,n,s)
-BN_ULONG *a;
-int n;
- {
- while (n--)
- fprintf(stdout,"%02X",a[n]);
- fprintf(stdout,"%s",s);
- }
-
-
-BN_ULONG bn_add_word(a,w,num)
-BN_ULONG *a;
-BN_ULONG w;
-int num;
- {
- BN_ULONG t;
-
-#ifdef DEBUG
-{ BN_ULONG *aa=a; int i; for (i=num; i>0; i--) fprintf(stdout,"%02X",aa[i-1]);
-fprintf(stdout," + %X - ",w); i=num;
-#endif
-
-loop:
- t= *a;
- t=(t+w)&BN_MASK2;
- *(a++)=t;
- w=(t < w);
- if (w && --num) goto loop;
-
-#ifdef DEBUG
-for (; i>0; i--) fprintf(stdout,"%02X",aa[i-1]);
-fprintf(stdout,"\n");
-}
-#endif
-
- return(w);
- }
-
-BN_ULONG bn_add_words(r,a,b,num)
-BN_ULONG *r;
-BN_ULONG *a;
-BN_ULONG *b;
-int num;
- {
-#if defined(BN_LLONG)
- BN_ULLONG t;
- BN_ULONG c=0;
- int i;
-
- if (num&1) abort();
-
- for (i=0; i<num; i+=2)
- {
- t=(BN_ULLONG)a[i]+b[i]+c;
- r[i+0]=L(t);
- t=(BN_ULLONG) H(t)+a[i+1]+b[i+1];
- r[i+1]=L(t);
- c=H(t);
- }
- return(c);
-#else
- BN_ULONG c=0,t1,t2;
-
- for ( ; num; num--)
- {
- t1= *(a++);
- t2= *(b++);
-
- if (c)
- {
- c=(t2 >= ((~t1)&BN_MASK2));
- (*r++)=(t1+t2+1)&BN_MASK2;
- }
- else
- {
- t2=(t1+t2)&BN_MASK2;
- c=(t2 < t1);
- (*r++)=t2;
- }
- }
- return(c);
-#endif
- }
-
-BN_ULONG bn_sub_words(r,a,b,num)
-BN_ULONG *r;
-BN_ULONG *a;
-BN_ULONG *b;
-int num;
- {
-#if defined(BN_LLONG)
- BN_ULLONG t;
- BN_ULONG c=0;
- int i;
-
- if (num&1) abort();
-
- for (i=0; i<num; i+=2)
- {
- t=(BN_ULLONG)a[i]-b[i]-c;
- r[i+0]=L(t);
- t=(BN_ULLONG)a[i+1]-b[i+1]-(0-H(t))&BN_MASK2;
- r[i+1]=L(t);
- c=H(t);
- }
- return(c);
-#else
- BN_ULONG c=0,t1,t2;
-
- for ( ; num; num--)
- {
- t1= *(a++);
- t2= *(b++);
-
- if (c)
- {
- c=(t1 <= t2);
- t1=(t1-t2-1);
- }
- else
- {
- c=(t1 < t2);
- t1=(t1-t2);
- }
- (*r++)=t1&BN_MASK2;
- }
- return(c);
-#endif
- }
-
-
-/* ret[3,2,1,0] = a1,a0 * b1,b0 */
-void BN_mul_4words(ret,a0,a1,b0,b1)
-BN_ULONG *ret;
-BN_ULONG a0,a1,b0,b1;
- {
- BN_ULONG s,u;
- BN_ULLONG fix,a0b0,a1b1,tmp;
-
- if (a1 >= a0)
- {
- s=(a1-a0);
- u=(b0-b1);
- fix=(BN_ULLONG)s*u;
- if (b0 >= b1) s=0;
- }
- else
- {
- BN_ULONG u;
-
- if (b0 > b1)
- {
- s=(b0-b1);
- u=(a1-a0);
- fix=(BN_ULLONG)s*u;
- }
- else
- {
- u=(a0-a1);
- s=(b1-b0);
- fix=(BN_ULLONG)s*u;
- s=0;
- }
- }
-
- a0b0=(BN_ULLONG)a0*b0;
- ret[0]=L(a0b0);
-
- a1b1=(BN_ULLONG)a1*b1;
- tmp=(BN_ULLONG) H(a0b0) + L(a0b0) + L(fix) + L(a1b1);
- ret[1]=L(tmp);
-
- tmp=(BN_ULLONG) a1b1 + H(tmp) + H(a0b0) + H(fix) + H(a1b1) - s;
- ret[2]=L(tmp);
- ret[3]=H(tmp);
- }
-
-/* ret[3,2,1,0] += a1,a0 * b1,b0 */
-BN_ULONG BN_mul_add_4words(ret,a0,a1,b0,b1)
-BN_ULONG *ret;
-BN_ULONG a0,a1,b0,b1;
- {
- BN_ULONG s,u;
- BN_ULLONG fix,a0b0,a1b1,tmp;
-
-#ifdef DEBUG
-fprintf(stdout,"%02X%02X%02X%02X",ret[3],ret[2],ret[1],ret[0]);
-fprintf(stdout," + ( %02X%02X * %02X%02X ) - ",a1,a0,b1,b0);
-#endif
- if (a1 >= a0)
- {
- s=(a1-a0);
- u=(b0-b1);
- fix=(BN_ULLONG)s*u;
- if (b0 >= b1) s=0;
- }
- else
- {
- if (b0 > b1)
- {
- s=(b0-b1);
- u=(a1-a0);
- fix=(BN_ULLONG)s*u;
- }
- else
- {
- u=(a0-a1);
- s=(b1-b0);
- fix=(BN_ULLONG)s*u;
- s=0;
- }
- }
-
- a0b0=(BN_ULLONG)a0*b0;
- tmp=a0b0+ret[0];
- ret[0]=L(tmp);
-
- a1b1=(BN_ULLONG)a1*b1;
- tmp=(BN_ULLONG) H(tmp) + L(a0b0) + L(fix) + L(a1b1) + ret[1];
- ret[1]=L(tmp);
-
- tmp=(BN_ULLONG) H(tmp) + L(a1b1) + H(a0b0) +
- H(fix) + H(a1b1) -s + ret[2];
- ret[2]=L(tmp);
-
- tmp=(BN_ULLONG) H(tmp) + H(a1b1) + ret[3];
- ret[3]=L(tmp);
-#ifdef DEBUG
-fprintf(stdout,"%02X%02X%02X%02X%02X\n",H(tmp),ret[3],ret[2],ret[1],ret[0]);
-#endif
- return(H(tmp));
- }
-
-/* ret[3,2,1,0] += a1,a0 * a1,a0 */
-void BN_sqr_4words(ret,a0,a1)
-BN_ULONG *ret;
-BN_ULONG a0,a1;
- {
- BN_ULONG s,u;
- BN_ULLONG tmp,tmp2;
-
- tmp=(BN_ULLONG)a0*a0;
- ret[0]=L(tmp);
-
- tmp2=(BN_ULLONG)a0*a1;
- tmp=(BN_ULLONG)H(tmp)+L(tmp2)*2;
- ret[1]=L(tmp);
-
- tmp=(BN_ULLONG)a1*a1+H(tmp)+H(tmp2)*2;
- ret[2]=L(tmp);
- ret[3]=L(tmp);
- }
-
-#define N0 (0)
-#define N1 (half)
-#define N2 (num)
-#define N3 (num+half)
-
-#define word_cmp(r,a,b,num) \
- { \
- int n=num; \
-\
- (r)=0; \
- while (n--) \
- { \
- if ((a)[(n)] > (b)[(n)]) \
- { (r)=1; break; } \
- else if ((a)[(n)] < (b)[(n)]) \
- { (r)= -1; break; } \
- } \
- }
-
-
-/* (a->top == b->top) && (a->top >= 2) && !(a->top & 1) */
-void bn_recursize_mul(r,t,a,b,num)
-BN_ULONG *r,*t,*a,*b;
-int num;
- {
- if ((num < 2) || (num&1))
- abort();
-
-/* fprintf(stderr,"num=%d half=%d\n",num,num/2);*/
- if (num == 2)
- BN_mul_4words(r,a[0],a[1],b[0],b[1]);
- else if (num == 4)
- {
- BN_ULONG c,tmp;
-
- BN_mul_4words(&(r[0]),a[0],a[1],b[0],b[1]);
- BN_mul_4words(&(r[4]),a[2],a[3],b[2],b[3]);
-
- c =BN_mul_add_4words(&(r[2]),a[0],a[1],b[2],b[3]);
- c+=BN_mul_add_4words(&(r[2]),a[2],a[3],b[0],b[1]);
-
- bn_add_word(&(r[6]),c,2);
- }
- else
- {
- int half=num/2;
- int carry,cmp_a,cmp_b;
-
- word_cmp(cmp_a,&(a[0]),&(a[half]),half);
- word_cmp(cmp_b,&(b[0]),&(b[half]),half);
-
- switch (cmp_a*2+cmp_a+cmp_b)
- {
- case -4:
- bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
- bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
- bn_recursize_mul(&(r[N1]),&(t[N2]),
- &(t[N0]),&(t[N1]),half);
- bn_sub_words(&(r[N2]),&(r[N2]),&(t[N0]),half);
- carry= -1;
- break;
- case -2:
- bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
- bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
- bn_recursize_mul(&(r[N1]),&(t[N2]),
- &(t[N0]),&(t[N1]),half);
- carry=0;
- break;
- case 2:
- bn_sub_words(&(t[N0]),&(a[N0]),&(a[N1]),half);
- bn_sub_words(&(t[N1]),&(b[N1]),&(b[N0]),half);
- bn_recursize_mul(&(r[N1]),&(t[N2]),
- &(t[N0]),&(t[N1]),half);
- carry=0;
- break;
- case 4:
- bn_sub_words(&(t[N0]),&(a[N1]),&(a[N0]),half);
- bn_sub_words(&(t[N1]),&(b[N0]),&(b[N1]),half);
- bn_recursize_mul(&(r[N1]),&(t[N2]),
- &(t[N0]),&(t[N1]),half);
- bn_sub_words(&(r[N2]),&(r[N2]),&(t[N1]),half);
- carry= -1;
- break;
- default:
- memset(&(r[N1]),0,sizeof(BN_ULONG)*num);
- break;
- }
-
- bn_recursize_mul(&(t[N0]),&(t[N2]),&(a[N0]),&(b[N0]),half);
-#ifdef DEBUG
- pr(a,half," * ");
- pr(b,half," - ");
- pr(t,num," - 0\n");
-#endif
- memcpy(&(r[N0]),&(t[N0]),half*sizeof(BN_ULONG));
- if (bn_add_words(&(r[N1]),&(r[N1]),&(t[N1]),half))
- { bn_add_word(&(t[N1]),1,half); }
-
- carry+=bn_add_words(&(r[N1]),&(r[N1]),&(t[N0]),num);
-
- bn_recursize_mul(&(t[N0]),&(t[N2]),&(a[N1]),&(b[N1]),half);
-
- carry+=bn_add_words(&(r[N1]),&(r[N1]),&(t[N0]),num);
- carry+=bn_add_words(&(r[N2]),&(r[N2]),&(t[N0]),half);
- memcpy(&(r[N3]),&(t[N1]),half*sizeof(BN_ULONG));
-
- bn_add_word(&(r[N3]),carry,half);
- }
- }
-
-main()
- {
- BIGNUM *a,*b,*r,*t;
- int i,j;
-
- a=BN_new();
- b=BN_new();
- r=BN_new();
- t=BN_new();
-
-#define BITS 1024
- bn_expand(r,BITS*2);
- bn_expand(t,BITS*2);
- fprintf(stdout,"obase=16\n");
- fprintf(stdout,"ibase=16\n");
- for (i=0; i<10; i++)
- {
- BN_rand(a,BITS,0,0);
- BN_rand(b,BITS,0,0);
- r->top=(BITS*2)/BN_BITS2;
- memset(r->d,0,sizeof(r->top)*sizeof(BN_ULONG));
- memset(t->d,0,sizeof(r->top)*sizeof(BN_ULONG));
- for (j=0; j<1000; j++)
- {
-
-/* BN_mul(r,a,b); /**/
- bn_recursize_mul(r->d,t->d,a->d,b->d,a->top); /**/
- }
- BN_print(stdout,a); fprintf(stdout," * ");
- BN_print(stdout,b); fprintf(stdout," - ");
- BN_print(stdout,r); fprintf(stdout,"\n");
- }
- }