]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
Since we have bn_restore_invariant, we may as well use it more.
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 12 Oct 2015 22:25:16 +0000 (23:25 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Wed, 28 Oct 2015 22:08:32 +0000 (22:08 +0000)
sshbn.c

diff --git a/sshbn.c b/sshbn.c
index 3afea467f9d393fe55fa8f5581c4018665ebf5cd..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;
 }