diff options
| author | mrezai | 2016-04-15 19:03:35 +0430 |
|---|---|---|
| committer | Rémi Verschelde | 2016-04-27 08:49:39 +0200 |
| commit | 3efa0f130dbaaba5eecb42f76ed7518eedfdf0c8 (patch) | |
| tree | 91da0400f0a1386f7122e25c559abdfb53a9ec9e /drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c | |
| parent | 47c7b535d2cdcb89c7799475662c70ca9c7ff41d (diff) | |
| download | godot-3efa0f130dbaaba5eecb42f76ed7518eedfdf0c8.tar.gz godot-3efa0f130dbaaba5eecb42f76ed7518eedfdf0c8.tar.zst godot-3efa0f130dbaaba5eecb42f76ed7518eedfdf0c8.zip | |
Update OpenSSL to version 1.0.2g
(cherry picked from commit e97922f22038e9049ed4c2db5b3736dfaa0edde3)
Diffstat (limited to 'drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c')
| -rw-r--r-- | drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c | 28 |
1 files changed, 25 insertions, 3 deletions
diff --git a/drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c b/drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c index 4c5fa6b92..dd769609b 100644 --- a/drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c +++ b/drivers/builtin_openssl2/crypto/ecdsa/ecs_ossl.c @@ -179,10 +179,32 @@ static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, while (BN_is_zero(r)); /* compute the inverse of k */ - if (!BN_mod_inverse(k, k, order, ctx)) { - ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); - goto err; + if (EC_GROUP_get_mont_data(group) != NULL) { + /* + * We want inverse in constant time, therefore we utilize the fact + * order must be prime and use Fermats Little Theorem instead. + */ + if (!BN_set_word(X, 2)) { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } + if (!BN_mod_sub(X, order, X, order, ctx)) { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } + BN_set_flags(X, BN_FLG_CONSTTIME); + if (!BN_mod_exp_mont_consttime + (k, k, X, order, ctx, EC_GROUP_get_mont_data(group))) { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } + } else { + if (!BN_mod_inverse(k, k, order, ctx)) { + ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); + goto err; + } } + /* clear old values if necessary */ if (*rp != NULL) BN_clear_free(*rp); |
