Ensure we test all parameters for BN_FLG_CONSTTIME
authorMatt Caswell <matt@openssl.org>
Wed, 27 Sep 2017 10:13:47 +0000 (11:13 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 11 Oct 2017 15:01:13 +0000 (16:01 +0100)
commit0cf65a0f5fdd72b950887e717f1f20d66ba30942
tree0a144dc145f2068fab3e3a084e453c6d23853f5f
parent24806f0944d48498cf6c28e3b7b3661416bc1470
Ensure we test all parameters for BN_FLG_CONSTTIME

RSA_setup_blinding() calls BN_BLINDING_create_param() which later calls
BN_mod_exp() as follows:

BN_mod_exp(ret->A, ret->A, ret->e, ret->mod, ctx)

ret->mod will have BN_FLG_CONSTTIME set, but ret->e does not. In
BN_mod_exp() we only test the third param for the existence of this flag.
We should test all the inputs.

Thanks to Samuel Weiser (samuel.weiser@iaik.tugraz.at) for reporting this
issue.

This typically only happens once at key load, so this is unlikely to be
exploitable in any real scenario.

Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4477)

(cherry picked from commit e913d11f444e0b46ec1ebbf3340813693f4d869d)
crypto/bn/bn_exp.c