In the case where a < 0 and |a| < w, the result (assigned to a) from
[openssl.git] / crypto / bn / bn_word.c
index c0cfbc67970130e513771956c44cb1aeacb6ce27..7e7ca58842bb92dbd732924a05d247d7aa8f6682 100644 (file)
@@ -60,7 +60,7 @@
 #include "cryptlib.h"
 #include "bn_lcl.h"
 
-BN_ULONG BN_mod_word(BIGNUM *a, BN_ULONG w)
+BN_ULONG BN_mod_word(const BIGNUM *a, BN_ULONG w)
        {
 #ifndef BN_LLONG
        BN_ULONG ret=0;
@@ -115,7 +115,7 @@ int BN_add_word(BIGNUM *a, BN_ULONG w)
                a->neg=0;
                i=BN_sub_word(a,w);
                if (!BN_is_zero(a))
-                       a->neg=1;
+                       a->neg=!(a->neg);
                return(i);
                }
        w&=BN_MASK2;