Use bn_resize_words in BN_from_montgomery_word.

Saves a bit of work, and we get a width sanity-check.

Bug: 232
Change-Id: I1c6bc376c9d8aaf60a078fdc39f35b6f44a688c6
Reviewed-on: https://boringssl-review.googlesource.com/25251
Reviewed-by: Adam Langley <agl@google.com>
This commit is contained in:
David Benjamin 2018-01-23 19:42:56 -05:00 committed by Adam Langley
parent 76ce04bec8
commit 7979dbede2

View File

@ -316,15 +316,10 @@ static int BN_from_montgomery_word(BIGNUM *ret, BIGNUM *r,
}
int max = (2 * n->top); // carry is stored separately
if (!bn_wexpand(r, max) ||
if (!bn_resize_words(r, max) ||
!bn_wexpand(ret, n->top)) {
return 0;
}
// Clear the top words of |r|.
if (max > r->top) {
OPENSSL_memset(r->d + r->top, 0, (max - r->top) * sizeof(BN_ULONG));
}
r->top = max;
ret->top = n->top;
if (!bn_from_montgomery_in_place(ret->d, ret->top, r->d, r->top, mont)) {