diff options
author | inoguchi <> | 2022-01-20 11:12:14 +0000 |
---|---|---|
committer | inoguchi <> | 2022-01-20 11:12:14 +0000 |
commit | 16d4a60b8641ac0612a3e7f2bbbaad39ab88c974 (patch) | |
tree | 738ba0a6b501fd8e94d479e5af4cf39d1de4479c /src | |
parent | 58a48f1e9c4f1c9c42f60ac854e4870e9d623585 (diff) | |
download | openbsd-16d4a60b8641ac0612a3e7f2bbbaad39ab88c974.tar.gz openbsd-16d4a60b8641ac0612a3e7f2bbbaad39ab88c974.tar.bz2 openbsd-16d4a60b8641ac0612a3e7f2bbbaad39ab88c974.zip |
Fix check for BN_mod_inverse_ct return value
ok jsing@ millert@ tb@
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_chk.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/rsa/rsa_gen.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/sm2/sm2_sign.c | 4 |
5 files changed, 13 insertions, 13 deletions
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 1d0b1d6106..6f5280bbc9 100644 --- a/src/lib/libcrypto/ec/ecp_smpl.c +++ b/src/lib/libcrypto/ec/ecp_smpl.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ecp_smpl.c,v 1.33 2021/09/08 17:29:21 tb Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.34 2022/01/20 11:02:44 inoguchi Exp $ */ |
2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Includes code written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
3 | * for the OpenSSL project. | 3 | * for the OpenSSL project. |
4 | * Includes code written by Bodo Moeller for the OpenSSL project. | 4 | * Includes code written by Bodo Moeller for the OpenSSL project. |
@@ -586,7 +586,7 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP * group, const EC_POIN | |||
586 | } | 586 | } |
587 | } | 587 | } |
588 | } else { | 588 | } else { |
589 | if (!BN_mod_inverse_ct(Z_1, Z_, &group->field, ctx)) { | 589 | if (BN_mod_inverse_ct(Z_1, Z_, &group->field, ctx) == NULL) { |
590 | ECerror(ERR_R_BN_LIB); | 590 | ECerror(ERR_R_BN_LIB); |
591 | goto err; | 591 | goto err; |
592 | } | 592 | } |
@@ -1316,7 +1316,7 @@ ec_GFp_simple_points_make_affine(const EC_GROUP * group, size_t num, EC_POINT * | |||
1316 | 1316 | ||
1317 | /* invert heap[1] */ | 1317 | /* invert heap[1] */ |
1318 | if (!BN_is_zero(heap[1])) { | 1318 | if (!BN_is_zero(heap[1])) { |
1319 | if (!BN_mod_inverse_ct(heap[1], heap[1], &group->field, ctx)) { | 1319 | if (BN_mod_inverse_ct(heap[1], heap[1], &group->field, ctx) == NULL) { |
1320 | ECerror(ERR_R_BN_LIB); | 1320 | ECerror(ERR_R_BN_LIB); |
1321 | goto err; | 1321 | goto err; |
1322 | } | 1322 | } |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index e7e7a52665..2429e36b59 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.22 2021/04/20 17:23:37 tb Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.23 2022/01/20 11:03:48 inoguchi Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -216,7 +216,7 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
216 | } | 216 | } |
217 | } while (BN_is_zero(r)); | 217 | } while (BN_is_zero(r)); |
218 | 218 | ||
219 | if (!BN_mod_inverse_ct(k, k, order, ctx)) { | 219 | if (BN_mod_inverse_ct(k, k, order, ctx) == NULL) { |
220 | ECDSAerror(ERR_R_BN_LIB); | 220 | ECDSAerror(ERR_R_BN_LIB); |
221 | goto err; | 221 | goto err; |
222 | } | 222 | } |
@@ -487,7 +487,7 @@ ecdsa_do_verify(const unsigned char *dgst, int dgst_len, const ECDSA_SIG *sig, | |||
487 | if (!ecdsa_prepare_digest(dgst, dgst_len, order, m)) | 487 | if (!ecdsa_prepare_digest(dgst, dgst_len, order, m)) |
488 | goto err; | 488 | goto err; |
489 | 489 | ||
490 | if (!BN_mod_inverse_ct(u2, sig->s, order, ctx)) { /* w = inv(s) */ | 490 | if (BN_mod_inverse_ct(u2, sig->s, order, ctx) == NULL) { /* w = inv(s) */ |
491 | ECDSAerror(ERR_R_BN_LIB); | 491 | ECDSAerror(ERR_R_BN_LIB); |
492 | goto err; | 492 | goto err; |
493 | } | 493 | } |
diff --git a/src/lib/libcrypto/rsa/rsa_chk.c b/src/lib/libcrypto/rsa/rsa_chk.c index 807eae084e..ac9dbf7a22 100644 --- a/src/lib/libcrypto/rsa/rsa_chk.c +++ b/src/lib/libcrypto/rsa/rsa_chk.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_chk.c,v 1.15 2022/01/10 00:03:02 tb Exp $ */ | 1 | /* $OpenBSD: rsa_chk.c,v 1.16 2022/01/20 11:08:12 inoguchi Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1999 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -199,7 +199,7 @@ RSA_check_key(const RSA *key) | |||
199 | } | 199 | } |
200 | 200 | ||
201 | /* iqmp = q^-1 mod p? */ | 201 | /* iqmp = q^-1 mod p? */ |
202 | if (!BN_mod_inverse_ct(i, key->q, key->p, ctx)) { | 202 | if (BN_mod_inverse_ct(i, key->q, key->p, ctx) == NULL) { |
203 | ret = -1; | 203 | ret = -1; |
204 | goto err; | 204 | goto err; |
205 | } | 205 | } |
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c index 3a0d8837b4..5f062a7a24 100644 --- a/src/lib/libcrypto/rsa/rsa_gen.c +++ b/src/lib/libcrypto/rsa/rsa_gen.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: rsa_gen.c,v 1.24 2022/01/07 09:55:32 tb Exp $ */ | 1 | /* $OpenBSD: rsa_gen.c,v 1.25 2022/01/20 11:11:17 inoguchi Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -198,7 +198,7 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) | |||
198 | BN_init(&pr0); | 198 | BN_init(&pr0); |
199 | BN_with_flags(&pr0, r0, BN_FLG_CONSTTIME); | 199 | BN_with_flags(&pr0, r0, BN_FLG_CONSTTIME); |
200 | 200 | ||
201 | if (!BN_mod_inverse_ct(rsa->d, rsa->e, &pr0, ctx)) /* d */ | 201 | if (BN_mod_inverse_ct(rsa->d, rsa->e, &pr0, ctx) == NULL) /* d */ |
202 | goto err; | 202 | goto err; |
203 | 203 | ||
204 | /* set up d for correct BN_FLG_CONSTTIME flag */ | 204 | /* set up d for correct BN_FLG_CONSTTIME flag */ |
@@ -216,7 +216,7 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb) | |||
216 | /* calculate inverse of q mod p */ | 216 | /* calculate inverse of q mod p */ |
217 | BN_init(&p); | 217 | BN_init(&p); |
218 | BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME); | 218 | BN_with_flags(&p, rsa->p, BN_FLG_CONSTTIME); |
219 | if (!BN_mod_inverse_ct(rsa->iqmp, rsa->q, &p, ctx)) | 219 | if (BN_mod_inverse_ct(rsa->iqmp, rsa->q, &p, ctx) == NULL) |
220 | goto err; | 220 | goto err; |
221 | 221 | ||
222 | ok = 1; | 222 | ok = 1; |
diff --git a/src/lib/libcrypto/sm2/sm2_sign.c b/src/lib/libcrypto/sm2/sm2_sign.c index d306658a48..b35de841b1 100644 --- a/src/lib/libcrypto/sm2/sm2_sign.c +++ b/src/lib/libcrypto/sm2/sm2_sign.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: sm2_sign.c,v 1.1.1.1 2021/08/18 16:04:32 tb Exp $ */ | 1 | /* $OpenBSD: sm2_sign.c,v 1.2 2022/01/20 11:12:14 inoguchi Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2017, 2019 Ribose Inc | 3 | * Copyright (c) 2017, 2019 Ribose Inc |
4 | * | 4 | * |
@@ -194,7 +194,7 @@ sm2_sig_gen(const EC_KEY *key, const BIGNUM *e) | |||
194 | goto err; | 194 | goto err; |
195 | } | 195 | } |
196 | 196 | ||
197 | if (!BN_mod_inverse_ct(s, s, order, ctx)) { | 197 | if (BN_mod_inverse_ct(s, s, order, ctx) == NULL) { |
198 | SM2error(ERR_R_BN_LIB); | 198 | SM2error(ERR_R_BN_LIB); |
199 | goto err; | 199 | goto err; |
200 | } | 200 | } |