From: Samuel Weiser Date: Sat, 16 Sep 2017 14:52:44 +0000 (+0200) Subject: BN_copy now propagates BN_FLG_CONSTTIME X-Git-Tag: OpenSSL_1_1_0g~61 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=a8e047a819b8f8bf8699e0bbfc838e1f23e82051;p=oweals%2Fopenssl.git BN_copy now propagates BN_FLG_CONSTTIME Reviewed-by: Paul Dale Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/4377) (cherry picked from commit 9f9442918aeaed5dc2442d81ab8d29fe3e1fb906) --- diff --git a/crypto/bn/bn_lib.c b/crypto/bn/bn_lib.c index fd06d08a83..c2dff7da9b 100644 --- a/crypto/bn/bn_lib.c +++ b/crypto/bn/bn_lib.c @@ -406,6 +406,9 @@ BIGNUM *BN_copy(BIGNUM *a, const BIGNUM *b) memcpy(a->d, b->d, sizeof(b->d[0]) * b->top); #endif + if (BN_get_flags(b, BN_FLG_CONSTTIME) != 0) + BN_set_flags(a, BN_FLG_CONSTTIME); + a->top = b->top; a->neg = b->neg; bn_check_top(a); diff --git a/crypto/bn/bn_mont.c b/crypto/bn/bn_mont.c index 90e1ba296e..faea4684fa 100644 --- a/crypto/bn/bn_mont.c +++ b/crypto/bn/bn_mont.c @@ -258,8 +258,6 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) R = &(mont->RR); /* grab RR as a temp */ if (!BN_copy(&(mont->N), mod)) goto err; /* Set N */ - if (BN_get_flags(mod, BN_FLG_CONSTTIME) != 0) - BN_set_flags(&(mont->N), BN_FLG_CONSTTIME); mont->N.neg = 0; #ifdef MONT_WORD