From 7cca1f96bf82b22ab49f179bae7df1562d0a104b Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Fri, 6 Jul 2018 13:16:40 +0200 Subject: [PATCH] bn/bn_lib.c: remove bn_check_top from bn_expand2. Trouble is that addition is postponing expansion till carry is calculated, and if addition carries, top word can be zero, which triggers assertion in bn_check_top. Reviewed-by: Rich Salz (Merged from https://github.com/openssl/openssl/pull/6810) (cherry picked from commit e42395e637c3507b80b25c7ed63236898822d2f1) Resolved conflicts: crypto/bn/bn_lib.c --- crypto/bn/bn_lib.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index f49c61cb5d..7ee80f4449 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -263,8 +263,6 @@ static BN_ULONG *bn_expand_internal(const BIGNUM *b, int words) const BN_ULONG *B; int i; - bn_check_top(b); - if (words > (INT_MAX / (4 * BN_BITS2))) { BNerr(BN_F_BN_EXPAND_INTERNAL, BN_R_BIGNUM_TOO_LONG); return NULL; @@ -398,8 +396,6 @@ BIGNUM *bn_dup_expand(const BIGNUM *b, int words) BIGNUM *bn_expand2(BIGNUM *b, int words) { - bn_check_top(b); - if (words > b->dmax) { BN_ULONG *a = bn_expand_internal(b, words); if (!a) @@ -433,7 +429,6 @@ BIGNUM *bn_expand2(BIGNUM *b, int words) assert(A == &(b->d[b->dmax])); } #endif - bn_check_top(b); return b; } -- 2.25.1