summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-03-27 10:22:47 +0000
committertb <>2023-03-27 10:22:47 +0000
commit00aea13536dd9c7115e084e54260c208dfdfb18a (patch)
tree0185376a4aa675f04952445753ad498a9709a2e1 /src
parentda1a532fc7d061a1f8b375580c6d9d22ea78970b (diff)
downloadopenbsd-00aea13536dd9c7115e084e54260c208dfdfb18a.tar.gz
openbsd-00aea13536dd9c7115e084e54260c208dfdfb18a.tar.bz2
openbsd-00aea13536dd9c7115e084e54260c208dfdfb18a.zip
Convert BN_copy() with missing error checks to bn_copy()
ok jsing
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_exp.c8
-rw-r--r--src/lib/libcrypto/bn/bn_mul.c8
-rw-r--r--src/lib/libcrypto/bn/bn_sqr.c8
-rw-r--r--src/lib/libcrypto/rsa/rsa_gen.c5
4 files changed, 18 insertions, 11 deletions
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c
index 4944daa48c..b756d2b305 100644
--- a/src/lib/libcrypto/bn/bn_exp.c
+++ b/src/lib/libcrypto/bn/bn_exp.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_exp.c,v 1.42 2023/03/27 10:21:23 tb Exp $ */ 1/* $OpenBSD: bn_exp.c,v 1.43 2023/03/27 10:22:47 tb 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 *
@@ -165,8 +165,10 @@ BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
165 ret = 1; 165 ret = 1;
166 166
167err: 167err:
168 if (r != rr && rr != NULL) 168 if (r != rr && rr != NULL) {
169 BN_copy(r, rr); 169 if (!bn_copy(r, rr))
170 ret = 0;
171 }
170 BN_CTX_end(ctx); 172 BN_CTX_end(ctx);
171 return (ret); 173 return (ret);
172} 174}
diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c
index 5e270b988f..3a33767a93 100644
--- a/src/lib/libcrypto/bn/bn_mul.c
+++ b/src/lib/libcrypto/bn/bn_mul.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mul.c,v 1.34 2023/02/22 05:57:19 jsing Exp $ */ 1/* $OpenBSD: bn_mul.c,v 1.35 2023/03/27 10:22:47 tb 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 *
@@ -786,8 +786,10 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
786 786
787 BN_set_negative(rr, a->neg ^ b->neg); 787 BN_set_negative(rr, a->neg ^ b->neg);
788 788
789 if (r != rr) 789 if (r != rr) {
790 BN_copy(r, rr); 790 if (!bn_copy(r, rr))
791 goto err;
792 }
791 done: 793 done:
792 ret = 1; 794 ret = 1;
793 err: 795 err:
diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c
index 6e784541bd..6641b77592 100644
--- a/src/lib/libcrypto/bn/bn_sqr.c
+++ b/src/lib/libcrypto/bn/bn_sqr.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_sqr.c,v 1.27 2023/02/17 05:13:34 jsing Exp $ */ 1/* $OpenBSD: bn_sqr.c,v 1.28 2023/03/27 10:22:47 tb 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 *
@@ -404,8 +404,10 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx)
404 404
405 rr->neg = 0; 405 rr->neg = 0;
406 406
407 if (rr != r) 407 if (rr != r) {
408 BN_copy(r, rr); 408 if (!bn_copy(r, rr))
409 goto err;
410 }
409 411
410 done: 412 done:
411 ret = 1; 413 ret = 1;
diff --git a/src/lib/libcrypto/rsa/rsa_gen.c b/src/lib/libcrypto/rsa/rsa_gen.c
index 7aefa7301c..d4a4d60a86 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.26 2022/11/26 16:08:54 tb Exp $ */ 1/* $OpenBSD: rsa_gen.c,v 1.27 2023/03/27 10:22:47 tb 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 *
@@ -131,7 +131,8 @@ rsa_builtin_keygen(RSA *rsa, int bits, BIGNUM *e_value, BN_GENCB *cb)
131 if (!rsa->iqmp && ((rsa->iqmp = BN_new()) == NULL)) 131 if (!rsa->iqmp && ((rsa->iqmp = BN_new()) == NULL))
132 goto err; 132 goto err;
133 133
134 BN_copy(rsa->e, e_value); 134 if (!bn_copy(rsa->e, e_value))
135 goto err;
135 136
136 /* generate p and q */ 137 /* generate p and q */
137 for (;;) { 138 for (;;) {