提交 6c90182a 编写于 作者: A Andy Polyakov

bn/bn_mont.c: improve readability of post-condition code.

Reviewed-by: NRich Salz <rsalz@openssl.org>
Reviewed-by: NDavid Benjamin <davidben@google.com>
(Merged from https://github.com/openssl/openssl/pull/6662)
上级 3c97e412
...@@ -130,15 +130,14 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont) ...@@ -130,15 +130,14 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r, BN_MONT_CTX *mont)
*/ */
ap = &(r->d[nl]); 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| * |carry| is -1 if |ap| - |np| underflowed or zero if it did not. Note
* cannot be -1. That would imply the subtraction did not fit in |nl| words, * |carry| cannot be 1. That would imply the subtraction did not fit in
* and we know at most one subtraction is needed. * |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++) { 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; ap[i] = 0;
} }
bn_correct_top(r); bn_correct_top(r);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册