diff options
author | beck <> | 2017-01-21 11:00:47 +0000 |
---|---|---|
committer | beck <> | 2017-01-21 11:00:47 +0000 |
commit | 9a561f2327a3e6b5ee853e60427012bfe6e02043 (patch) | |
tree | 7ad0f2808a2ac42a510bf2f280dba63a3dfc83e3 /src/lib/libcrypto/ecdsa | |
parent | bce45cc241b51da39ead8b476c811b47d76ccc46 (diff) | |
download | openbsd-9a561f2327a3e6b5ee853e60427012bfe6e02043.tar.gz openbsd-9a561f2327a3e6b5ee853e60427012bfe6e02043.tar.bz2 openbsd-9a561f2327a3e6b5ee853e60427012bfe6e02043.zip |
Add ct and nonct versions of BN_mod_inverse for internal use
ok jsing@
Diffstat (limited to 'src/lib/libcrypto/ecdsa')
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 26158a001b..637da6535f 100644 --- a/src/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/src/lib/libcrypto/ecdsa/ecs_ossl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecs_ossl.c,v 1.7 2017/01/05 13:25:52 jsing Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.8 2017/01/21 11:00:47 beck Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -58,11 +58,13 @@ | |||
58 | 58 | ||
59 | #include <openssl/opensslconf.h> | 59 | #include <openssl/opensslconf.h> |
60 | 60 | ||
61 | #include "ecs_locl.h" | ||
62 | #include <openssl/err.h> | 61 | #include <openssl/err.h> |
63 | #include <openssl/obj_mac.h> | 62 | #include <openssl/obj_mac.h> |
64 | #include <openssl/bn.h> | 63 | #include <openssl/bn.h> |
65 | 64 | ||
65 | #include "bn_lcl.h" | ||
66 | #include "ecs_locl.h" | ||
67 | |||
66 | static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen, | 68 | static ECDSA_SIG *ecdsa_do_sign(const unsigned char *dgst, int dlen, |
67 | const BIGNUM *, const BIGNUM *, EC_KEY *eckey); | 69 | const BIGNUM *, const BIGNUM *, EC_KEY *eckey); |
68 | static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, | 70 | static int ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, |
@@ -176,7 +178,7 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
176 | } while (BN_is_zero(r)); | 178 | } while (BN_is_zero(r)); |
177 | 179 | ||
178 | /* compute the inverse of k */ | 180 | /* compute the inverse of k */ |
179 | if (!BN_mod_inverse(k, k, order, ctx)) { | 181 | if (!BN_mod_inverse_ct(k, k, order, ctx)) { |
180 | ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); | 182 | ECDSAerr(ECDSA_F_ECDSA_SIGN_SETUP, ERR_R_BN_LIB); |
181 | goto err; | 183 | goto err; |
182 | } | 184 | } |
@@ -360,7 +362,7 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, | |||
360 | goto err; | 362 | goto err; |
361 | } | 363 | } |
362 | /* calculate tmp1 = inv(S) mod order */ | 364 | /* calculate tmp1 = inv(S) mod order */ |
363 | if (!BN_mod_inverse(u2, sig->s, order, ctx)) { | 365 | if (!BN_mod_inverse_ct(u2, sig->s, order, ctx)) { |
364 | ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); | 366 | ECDSAerr(ECDSA_F_ECDSA_DO_VERIFY, ERR_R_BN_LIB); |
365 | goto err; | 367 | goto err; |
366 | } | 368 | } |