bugfix: 0 - w (w != 0) is actually negative
authorNils Larsch <nils@openssl.org>
Sun, 17 Jul 2005 16:09:09 +0000 (16:09 +0000)
committerNils Larsch <nils@openssl.org>
Sun, 17 Jul 2005 16:09:09 +0000 (16:09 +0000)
crypto/bn/bn_word.c

index 1bcb37e29222f76dce1baefd9d1bf949389e725e..bc5905fef4279e644ae4f2090ad6e7a5f4bd0f8d 100644 (file)
@@ -175,7 +175,13 @@ int BN_sub_word(BIGNUM *a, BN_ULONG w)
        /* degenerate case: w is zero */
        if (!w) return 1;
        /* degenerate case: a is zero */
-       if(BN_is_zero(a)) return BN_set_word(a,w);
+       if(BN_is_zero(a))
+               {
+               i = BN_set_word(a,w);
+               if (i != 0)
+                       BN_set_negative(a, 1);
+               return i;
+               }
        /* handle 'a' when negative */
        if (a->neg)
                {