summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn
diff options
context:
space:
mode:
authorjsing <>2022-12-01 02:58:31 +0000
committerjsing <>2022-12-01 02:58:31 +0000
commitd873fdce8c0f766ae04ec8b5987f13dd992d2b96 (patch)
tree3e7fae85ba49061f2fd1463d38a9c33b9744a863 /src/lib/libcrypto/bn
parenta506c8140d92cbd17760f5379c72bebfe62f7fa3 (diff)
downloadopenbsd-d873fdce8c0f766ae04ec8b5987f13dd992d2b96.tar.gz
openbsd-d873fdce8c0f766ae04ec8b5987f13dd992d2b96.tar.bz2
openbsd-d873fdce8c0f766ae04ec8b5987f13dd992d2b96.zip
BN_one() can fail, check its return value.
ok tb@
Diffstat (limited to 'src/lib/libcrypto/bn')
-rw-r--r--src/lib/libcrypto/bn/bn_gcd.c11
1 files changed, 7 insertions, 4 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;