diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/bn_gcd.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/gost/gostr341001.c | 14 |
2 files changed, 16 insertions, 9 deletions
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c index 4661b35571..f3a23701b1 100644 --- a/src/lib/libcrypto/bn/bn_gcd.c +++ b/src/lib/libcrypto/bn/bn_gcd.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_gcd.c,v 1.18 2022/11/26 16:08:51 tb Exp $ */ | 1 | /* $OpenBSD: bn_gcd.c,v 1.19 2022/12/01 02:58:31 jsing 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 | * |
@@ -277,7 +277,8 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct | |||
277 | if (R == NULL) | 277 | if (R == NULL) |
278 | goto err; | 278 | goto err; |
279 | 279 | ||
280 | BN_one(X); | 280 | if (!BN_one(X)) |
281 | goto err; | ||
281 | BN_zero(Y); | 282 | BN_zero(Y); |
282 | if (BN_copy(B, a) == NULL) | 283 | if (BN_copy(B, a) == NULL) |
283 | goto err; | 284 | goto err; |
@@ -591,7 +592,8 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
591 | if (R == NULL) | 592 | if (R == NULL) |
592 | goto err; | 593 | goto err; |
593 | 594 | ||
594 | BN_one(X); | 595 | if (!BN_one(X)) |
596 | goto err; | ||
595 | BN_zero(Y); | 597 | BN_zero(Y); |
596 | if (BN_copy(B, a) == NULL) | 598 | if (BN_copy(B, a) == NULL) |
597 | goto err; | 599 | goto err; |
@@ -755,7 +757,8 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
755 | if ((T = BN_CTX_get(ctx)) == NULL) | 757 | if ((T = BN_CTX_get(ctx)) == NULL) |
756 | goto err; | 758 | goto err; |
757 | 759 | ||
758 | BN_one(X); | 760 | if (!BN_one(X)) |
761 | goto err; | ||
759 | BN_zero(Y); | 762 | BN_zero(Y); |
760 | if (BN_copy(B, a) == NULL) | 763 | if (BN_copy(B, a) == NULL) |
761 | goto err; | 764 | goto err; |
diff --git a/src/lib/libcrypto/gost/gostr341001.c b/src/lib/libcrypto/gost/gostr341001.c index 13f053dae8..79fddb11b0 100644 --- a/src/lib/libcrypto/gost/gostr341001.c +++ b/src/lib/libcrypto/gost/gostr341001.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: gostr341001.c,v 1.10 2022/11/26 16:08:53 tb Exp $ */ | 1 | /* $OpenBSD: gostr341001.c,v 1.11 2022/12/01 02:58:31 jsing Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> | 3 | * Copyright (c) 2014 Dmitry Eremin-Solenikov <dbaryshkov@gmail.com> |
4 | * Copyright (c) 2005-2006 Cryptocom LTD | 4 | * Copyright (c) 2005-2006 Cryptocom LTD |
@@ -178,8 +178,10 @@ gost2001_do_sign(BIGNUM *md, GOST_KEY *eckey) | |||
178 | goto err; | 178 | goto err; |
179 | if (BN_mod_ct(e, md, order, ctx) == 0) | 179 | if (BN_mod_ct(e, md, order, ctx) == 0) |
180 | goto err; | 180 | goto err; |
181 | if (BN_is_zero(e)) | 181 | if (BN_is_zero(e)) { |
182 | BN_one(e); | 182 | if (!BN_one(e)) |
183 | goto err; | ||
184 | } | ||
183 | if ((k = BN_CTX_get(ctx)) == NULL) | 185 | if ((k = BN_CTX_get(ctx)) == NULL) |
184 | goto err; | 186 | goto err; |
185 | if ((X = BN_CTX_get(ctx)) == NULL) | 187 | if ((X = BN_CTX_get(ctx)) == NULL) |
@@ -289,8 +291,10 @@ gost2001_do_verify(BIGNUM *md, ECDSA_SIG *sig, GOST_KEY *ec) | |||
289 | 291 | ||
290 | if (BN_mod_ct(e, md, order, ctx) == 0) | 292 | if (BN_mod_ct(e, md, order, ctx) == 0) |
291 | goto err; | 293 | goto err; |
292 | if (BN_is_zero(e)) | 294 | if (BN_is_zero(e)) { |
293 | BN_one(e); | 295 | if (!BN_one(e)) |
296 | goto err; | ||
297 | } | ||
294 | if ((v = BN_mod_inverse_ct(v, e, order, ctx)) == NULL) | 298 | if ((v = BN_mod_inverse_ct(v, e, order, ctx)) == NULL) |
295 | goto err; | 299 | goto err; |
296 | if (BN_mod_mul(z1, sig->s, v, order, ctx) == 0) | 300 | if (BN_mod_mul(z1, sig->s, v, order, ctx) == 0) |