diff options
author | Andy Polyakov <appro@openssl.org> | 2018-07-06 14:54:34 +0200 |
---|---|---|
committer | Andy Polyakov <appro@openssl.org> | 2018-07-12 15:08:40 +0200 |
commit | 88af716e831fd7f76e2b2eab568905733b7c87eb (patch) | |
tree | da6a3b68df5c982714806b2475abbc255879ab0a | |
parent | 308447e3bdacd9ed55d5f8c4dd266d6aa75aab2b (diff) |
bn/bn_mont.c: improve readability of post-condition code.
Reviewed-by: Rich Salz <rsalz@openssl.org>
Reviewed-by: David Benjamin <davidben@google.com>
(Merged from https://github.com/openssl/openssl/pull/6662)
(cherry picked from commit 6c90182a5f87af1a1e462536e7123ad2afb84c43)
-rw-r--r-- | crypto/bn/bn_mont.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index f052d5612b..e1d2973032 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -130,15 +130,14 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) */ ap = &(r->d[nl]); + carry -= bn_sub_words(rp, ap, np, nl); /* - * |v| is one if |ap| - |np| underflowed or zero if it did not. Note |v| - * cannot be -1. That would imply the subtraction did not fit in |nl| words, - * and we know at most one subtraction is needed. + * |carry| is -1 if |ap| - |np| underflowed or zero if it did not. Note + * |carry| cannot be 1. That would imply the subtraction did not fit in + * |nl| words, and we know at most one subtraction is needed. */ - v = bn_sub_words(rp, ap, np, nl) - carry; - v = 0 - v; for (i = 0; i < nl; i++) { - rp[i] = (v & ap[i]) | (~v & rp[i]); + rp[i] = (carry & ap[i]) | (~carry & rp[i]); ap[i] = 0; } bn_correct_top(r); |