From 183847747af50de1f0c6da1224e0ad6b6f54ebea Mon Sep 17 00:00:00 2001 From: =?utf8?q?Bodo=20M=C3=B6ller?= Date: Sat, 3 Aug 2002 18:27:47 +0000 Subject: [PATCH] fix bn_expand2 --- crypto/bn/bn_gf2m.c | 2 +- crypto/bn/bn_lib.c | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/crypto/bn/bn_gf2m.c b/crypto/bn/bn_gf2m.c index c969685c87..bf7031b3ab 100644 --- a/crypto/bn/bn_gf2m.c +++ b/crypto/bn/bn_gf2m.c @@ -284,7 +284,7 @@ int BN_GF2m_add(BIGNUM *r, const BIGNUM *a, const BIGNUM *b) if (a->top < b->top) { at = b; bt = a; } else { at = a; bt = b; } - bn_wexpand(r, at->top); + bn_expand2(r, at->top); for (i = 0; i < bt->top; i++) { diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index 60e3c680bc..20f851cc66 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -453,13 +453,14 @@ BIGNUM *bn_expand2(BIGNUM *b, int words) if ((b != NULL) && (b->top < b->dmax)) { A = &(b->d[b->top]); - for (i=(words - b->top)>>3; i>0; i--,A+=8) + for (i=(b->dmax - b->top)>>3; i>0; i--,A+=8) { A[0]=0; A[1]=0; A[2]=0; A[3]=0; A[4]=0; A[5]=0; A[6]=0; A[7]=0; } - for (i=(words - b->top)&7; i>0; i--,A++) + for (i=(b->dmax - b->top)&7; i>0; i--,A++) A[0]=0; + assert(A == &(b->d[b->dmax])); } return b; -- 2.34.1