bn_mul_recursive doesn't handle all cases correctly, which results in
authorAndy Polyakov <appro@openssl.org>
Sun, 8 Jul 2007 18:53:03 +0000 (18:53 +0000)
committerAndy Polyakov <appro@openssl.org>
Sun, 8 Jul 2007 18:53:03 +0000 (18:53 +0000)
BN_mul failures at certain key-length mixes.
PR: 1427

crypto/bn/bn_mul.c

index aec1eafc65fbb25a8fbeda30f8f6025129a3c716..312b467645e8bb20d13375ca3ceebc04bc5ed963 100644 (file)
@@ -655,16 +655,16 @@ void bn_mul_part_recursive(BN_ULONG *r, BN_ULONG *a, BN_ULONG *b, int n,
                                for (;;)
                                        {
                                        i/=2;
-                                       if (i < tna && i < tnb)
+                                       if (i <= tna && tna == tnb)
                                                {
-                                               bn_mul_part_recursive(&(r[n2]),
+                                               bn_mul_recursive(&(r[n2]),
                                                        &(a[n]),&(b[n]),
                                                        i,tna-i,tnb-i,p);
                                                break;
                                                }
-                                       else if (i <= tna && i <= tnb)
+                                       else if (i < tna || i < tnb)
                                                {
-                                               bn_mul_recursive(&(r[n2]),
+                                               bn_mul_part_recursive(&(r[n2]),
                                                        &(a[n]),&(b[n]),
                                                        i,tna-i,tnb-i,p);
                                                break;