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>
diff --git a/crypto/fipsmodule/bn/montgomery.c b/crypto/fipsmodule/bn/montgomery.c
index 624ab5f..eaf2ba0 100644
--- a/crypto/fipsmodule/bn/montgomery.c
+++ b/crypto/fipsmodule/bn/montgomery.c
@@ -316,15 +316,10 @@
}
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)) {