summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_mul.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_mul.c')
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index 12e5be80eb..a0e9ec3b46 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -551,7 +551,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
551 int tna, int tnb, BN_ULONG *t) 551 int tna, int tnb, BN_ULONG *t)
552 { 552 {
553 int i,j,n2=n*2; 553 int i,j,n2=n*2;
554 int c1,c2,neg; 554 int c1,c2,neg,zero;
555 BN_ULONG ln,lo,*p; 555 BN_ULONG ln,lo,*p;
556 556
557# ifdef BN_COUNT 557# ifdef BN_COUNT
@@ -567,7 +567,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
567 /* r=(a[0]-a[1])*(b[1]-b[0]) */ 567 /* r=(a[0]-a[1])*(b[1]-b[0]) */
568 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna); 568 c1=bn_cmp_part_words(a,&(a[n]),tna,n-tna);
569 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n); 569 c2=bn_cmp_part_words(&(b[n]),b,tnb,tnb-n);
570 neg=0; 570 zero=neg=0;
571 switch (c1*3+c2) 571 switch (c1*3+c2)
572 { 572 {
573 case -4: 573 case -4:
@@ -575,6 +575,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
575 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */ 575 bn_sub_part_words(&(t[n]),b, &(b[n]),tnb,n-tnb); /* - */
576 break; 576 break;
577 case -3: 577 case -3:
578 zero=1;
578 /* break; */ 579 /* break; */
579 case -2: 580 case -2:
580 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */ 581 bn_sub_part_words(t, &(a[n]),a, tna,tna-n); /* - */
@@ -584,6 +585,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
584 case -1: 585 case -1:
585 case 0: 586 case 0:
586 case 1: 587 case 1:
588 zero=1;
587 /* break; */ 589 /* break; */
588 case 2: 590 case 2:
589 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */ 591 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); /* + */
@@ -591,6 +593,7 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
591 neg=1; 593 neg=1;
592 break; 594 break;
593 case 3: 595 case 3:
596 zero=1;
594 /* break; */ 597 /* break; */
595 case 4: 598 case 4:
596 bn_sub_part_words(t, a, &(a[n]),tna,n-tna); 599 bn_sub_part_words(t, a, &(a[n]),tna,n-tna);
@@ -1009,6 +1012,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1009 { 1012 {
1010 if (i >= -1 && i <= 1) 1013 if (i >= -1 && i <= 1)
1011 { 1014 {
1015 int sav_j =0;
1012 /* Find out the power of two lower or equal 1016 /* Find out the power of two lower or equal
1013 to the longest of the two numbers */ 1017 to the longest of the two numbers */
1014 if (i >= 0) 1018 if (i >= 0)
@@ -1019,6 +1023,7 @@ int BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
1019 { 1023 {
1020 j = BN_num_bits_word((BN_ULONG)bl); 1024 j = BN_num_bits_word((BN_ULONG)bl);
1021 } 1025 }
1026 sav_j = j;
1022 j = 1<<(j-1); 1027 j = 1<<(j-1);
1023 assert(j <= al || j <= bl); 1028 assert(j <= al || j <= bl);
1024 k = j+j; 1029 k = j+j;