Corrections to the comments in BN_mod_inverse.
[oweals/openssl.git] / crypto / bn / bn_lib.c
index f0dc7d52dc257ef84abebb5619402a76d9bd7adf..a63c031216947fc94ee8caff98a06204878fd1ce 100644 (file)
@@ -357,6 +357,7 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words)
                }
 
        /* Now need to zero any data between b->top and b->max */
+       /* XXX Why? */
 
        A= &(a[b->top]);
        for (i=(words - b->top)>>3; i>0; i--,A+=8)
@@ -585,7 +586,6 @@ int BN_set_word(BIGNUM *a, BN_ULONG w)
        return(1);
        }
 
-/* ignore negative */
 BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
        {
        unsigned int i,m;
@@ -605,7 +605,8 @@ BIGNUM *BN_bin2bn(const unsigned char *s, int len, BIGNUM *ret)
                return(NULL);
        i=((n-1)/BN_BYTES)+1;
        m=((n-1)%(BN_BYTES));
-       ret->top=i-1;
+       ret->top=i;
+       ret->neg=0;
        while (n-- > 0)
                {
                l=(l<<8L)| *(s++);
@@ -776,4 +777,3 @@ int bn_cmp_words(const BN_ULONG *a, const BN_ULONG *b, int n)
                }
        return(0);
        }
-