Clear BN_FLG_CONSTTIME on BN_CTX_get()
authorNicola Tuveri <nic.tuv@gmail.com>
Fri, 8 Feb 2019 10:42:25 +0000 (12:42 +0200)
committerNicola Tuveri <nic.tuv@gmail.com>
Wed, 20 Feb 2019 21:02:09 +0000 (23:02 +0200)
(cherry picked from commit c8147d37ccaaf28c430d3fb45a14af36597e48b8)

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/8295)

crypto/bn/bn_ctx.c

index 526c6a046d16a394a44891c47fb50ad39781c944..3391134d7b25c8f4e7c97ccbeecc1cba0c6fe500 100644 (file)
@@ -299,6 +299,8 @@ BIGNUM *BN_CTX_get(BN_CTX *ctx)
     }
     /* OK, make sure the returned bignum is "zero" */
     BN_zero(ret);
+    /* clear BN_FLG_CONSTTIME if leaked from previous frames */
+    ret->flags &= (~BN_FLG_CONSTTIME);
     ctx->used++;
     CTXDBG_RET(ctx, ret);
     return ret;