]> asedeno.scripts.mit.edu Git - PuTTY.git/blobdiff - sshbn.c
Add a -fuzznet option to Unix plink.
[PuTTY.git] / sshbn.c
diff --git a/sshbn.c b/sshbn.c
index fd9e5c0aee3aa73d1966650de81ef4e8fe854643..7aa1069709f774964aa1de309fcb9f3412d528ef 100644 (file)
--- a/sshbn.c
+++ b/sshbn.c
@@ -1142,8 +1142,7 @@ Bignum bignum_from_bytes(const unsigned char *data, int nbytes)
             (BignumInt)byte << (8*i % BIGNUM_INT_BITS);
     }
 
-    while (result[0] > 1 && result[result[0]] == 0)
-       result[0]--;
+    bn_restore_invariant(result);
     return result;
 }
 
@@ -1165,8 +1164,7 @@ Bignum bignum_from_bytes_le(const unsigned char *data, int nbytes)
             (BignumInt)byte << (8*i % BIGNUM_INT_BITS);
     }
 
-    while (result[0] > 1 && result[result[0]] == 0)
-        result[0]--;
+    bn_restore_invariant(result);
     return result;
 }
 
@@ -1311,9 +1309,9 @@ int bignum_bit(Bignum bn, int i)
  */
 void bignum_set_bit(Bignum bn, int bitnum, int value)
 {
-    if (bitnum < 0 || bitnum >= (int)(BIGNUM_INT_BITS * bn[0]))
-       abort();                       /* beyond the end */
-    else {
+    if (bitnum < 0 || bitnum >= (int)(BIGNUM_INT_BITS * bn[0])) {
+        if (value) abort();                   /* beyond the end */
+    else {
        int v = bitnum / BIGNUM_INT_BITS + 1;
        BignumInt mask = (BignumInt)1 << (bitnum % BIGNUM_INT_BITS);
        if (value)