diff options
author | tb <> | 2023-03-27 10:21:23 +0000 |
---|---|---|
committer | tb <> | 2023-03-27 10:21:23 +0000 |
commit | da1a532fc7d061a1f8b375580c6d9d22ea78970b (patch) | |
tree | 78bb6d4286a0a95d7729bde003bd20eb6757d89a /src | |
parent | 62d326cb4e50a66b7d20ac55a0808f880deb43d9 (diff) | |
download | openbsd-da1a532fc7d061a1f8b375580c6d9d22ea78970b.tar.gz openbsd-da1a532fc7d061a1f8b375580c6d9d22ea78970b.tar.bz2 openbsd-da1a532fc7d061a1f8b375580c6d9d22ea78970b.zip |
Convert BN_copy() with explicit comparison against NULL to bn_copy()
ok jsing
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/bn_div.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_exp.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_gcd.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_kron.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mod.c | 6 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 4 | ||||
-rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 4 |
7 files changed, 25 insertions, 25 deletions
diff --git a/src/lib/libcrypto/bn/bn_div.c b/src/lib/libcrypto/bn/bn_div.c index 692e618407..3225fa4424 100644 --- a/src/lib/libcrypto/bn/bn_div.c +++ b/src/lib/libcrypto/bn/bn_div.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_div.c,v 1.39 2023/02/16 10:41:03 jsing Exp $ */ | 1 | /* $OpenBSD: bn_div.c,v 1.40 2023/03/27 10:21:23 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 | * |
@@ -264,7 +264,7 @@ BN_div_internal(BIGNUM *quotient, BIGNUM *remainder, const BIGNUM *numerator, | |||
264 | if (!no_branch) { | 264 | if (!no_branch) { |
265 | if (BN_ucmp(numerator, divisor) < 0) { | 265 | if (BN_ucmp(numerator, divisor) < 0) { |
266 | if (remainder != NULL) { | 266 | if (remainder != NULL) { |
267 | if (BN_copy(remainder, numerator) == NULL) | 267 | if (!bn_copy(remainder, numerator)) |
268 | goto err; | 268 | goto err; |
269 | } | 269 | } |
270 | if (quotient != NULL) | 270 | if (quotient != NULL) |
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c index 9e4497bb06..4944daa48c 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.41 2023/03/26 19:09:42 tb Exp $ */ | 1 | /* $OpenBSD: bn_exp.c,v 1.42 2023/03/27 10:21:23 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 | * |
@@ -142,12 +142,12 @@ BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
142 | if (rr == NULL || v == NULL) | 142 | if (rr == NULL || v == NULL) |
143 | goto err; | 143 | goto err; |
144 | 144 | ||
145 | if (BN_copy(v, a) == NULL) | 145 | if (!bn_copy(v, a)) |
146 | goto err; | 146 | goto err; |
147 | bits = BN_num_bits(p); | 147 | bits = BN_num_bits(p); |
148 | 148 | ||
149 | if (BN_is_odd(p)) { | 149 | if (BN_is_odd(p)) { |
150 | if (BN_copy(rr, a) == NULL) | 150 | if (!bn_copy(rr, a)) |
151 | goto err; | 151 | goto err; |
152 | } else { | 152 | } else { |
153 | if (!BN_one(rr)) | 153 | if (!BN_one(rr)) |
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c index 84c3d85850..138befc868 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.21 2023/01/21 09:21:11 jsing Exp $ */ | 1 | /* $OpenBSD: bn_gcd.c,v 1.22 2023/03/27 10:21:23 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 | * |
@@ -221,9 +221,9 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
221 | if (!BN_one(X)) | 221 | if (!BN_one(X)) |
222 | goto err; | 222 | goto err; |
223 | BN_zero(Y); | 223 | BN_zero(Y); |
224 | if (BN_copy(B, a) == NULL) | 224 | if (!bn_copy(B, a)) |
225 | goto err; | 225 | goto err; |
226 | if (BN_copy(A, n) == NULL) | 226 | if (!bn_copy(A, n)) |
227 | goto err; | 227 | goto err; |
228 | A->neg = 0; | 228 | A->neg = 0; |
229 | 229 | ||
@@ -337,9 +337,9 @@ BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) | |||
337 | if ((b = BN_CTX_get(ctx)) == NULL) | 337 | if ((b = BN_CTX_get(ctx)) == NULL) |
338 | goto err; | 338 | goto err; |
339 | 339 | ||
340 | if (BN_copy(a, in_a) == NULL) | 340 | if (!bn_copy(a, in_a)) |
341 | goto err; | 341 | goto err; |
342 | if (BN_copy(b, in_b) == NULL) | 342 | if (!bn_copy(b, in_b)) |
343 | goto err; | 343 | goto err; |
344 | a->neg = 0; | 344 | a->neg = 0; |
345 | b->neg = 0; | 345 | b->neg = 0; |
@@ -353,7 +353,7 @@ BN_gcd(BIGNUM *r, const BIGNUM *in_a, const BIGNUM *in_b, BN_CTX *ctx) | |||
353 | if (t == NULL) | 353 | if (t == NULL) |
354 | goto err; | 354 | goto err; |
355 | 355 | ||
356 | if (BN_copy(r, t) == NULL) | 356 | if (!bn_copy(r, t)) |
357 | goto err; | 357 | goto err; |
358 | ret = 1; | 358 | ret = 1; |
359 | 359 | ||
@@ -419,9 +419,9 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
419 | if (!BN_one(X)) | 419 | if (!BN_one(X)) |
420 | goto err; | 420 | goto err; |
421 | BN_zero(Y); | 421 | BN_zero(Y); |
422 | if (BN_copy(B, a) == NULL) | 422 | if (!bn_copy(B, a)) |
423 | goto err; | 423 | goto err; |
424 | if (BN_copy(A, n) == NULL) | 424 | if (!bn_copy(A, n)) |
425 | goto err; | 425 | goto err; |
426 | A->neg = 0; | 426 | A->neg = 0; |
427 | 427 | ||
@@ -582,9 +582,9 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct | |||
582 | if (!BN_one(X)) | 582 | if (!BN_one(X)) |
583 | goto err; | 583 | goto err; |
584 | BN_zero(Y); | 584 | BN_zero(Y); |
585 | if (BN_copy(B, a) == NULL) | 585 | if (!bn_copy(B, a)) |
586 | goto err; | 586 | goto err; |
587 | if (BN_copy(A, n) == NULL) | 587 | if (!bn_copy(A, n)) |
588 | goto err; | 588 | goto err; |
589 | A->neg = 0; | 589 | A->neg = 0; |
590 | if (B->neg || (BN_ucmp(B, A) >= 0)) { | 590 | if (B->neg || (BN_ucmp(B, A) >= 0)) { |
diff --git a/src/lib/libcrypto/bn/bn_kron.c b/src/lib/libcrypto/bn/bn_kron.c index cbd79f0455..f48823acab 100644 --- a/src/lib/libcrypto/bn/bn_kron.c +++ b/src/lib/libcrypto/bn/bn_kron.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_kron.c,v 1.13 2023/03/25 10:51:18 tb Exp $ */ | 1 | /* $OpenBSD: bn_kron.c,v 1.14 2023/03/27 10:21:23 tb Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2000 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -78,9 +78,9 @@ BN_kronecker(const BIGNUM *A, const BIGNUM *B, BN_CTX *ctx) | |||
78 | if ((b = BN_CTX_get(ctx)) == NULL) | 78 | if ((b = BN_CTX_get(ctx)) == NULL) |
79 | goto end; | 79 | goto end; |
80 | 80 | ||
81 | if (BN_copy(a, A) == NULL) | 81 | if (!bn_copy(a, A)) |
82 | goto end; | 82 | goto end; |
83 | if (BN_copy(b, B) == NULL) | 83 | if (!bn_copy(b, B)) |
84 | goto end; | 84 | goto end; |
85 | 85 | ||
86 | /* | 86 | /* |
diff --git a/src/lib/libcrypto/bn/bn_mod.c b/src/lib/libcrypto/bn/bn_mod.c index 2072dd904f..868ef5bc5b 100644 --- a/src/lib/libcrypto/bn/bn_mod.c +++ b/src/lib/libcrypto/bn/bn_mod.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mod.c,v 1.19 2023/02/03 05:15:40 jsing Exp $ */ | 1 | /* $OpenBSD: bn_mod.c,v 1.20 2023/03/27 10:21:23 tb 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 | /* ==================================================================== | 4 | /* ==================================================================== |
@@ -264,7 +264,7 @@ BN_mod_lshift(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m, BN_CTX *ctx) | |||
264 | if (BN_is_negative(m)) { | 264 | if (BN_is_negative(m)) { |
265 | if ((abs_m = BN_CTX_get(ctx)) == NULL) | 265 | if ((abs_m = BN_CTX_get(ctx)) == NULL) |
266 | goto err; | 266 | goto err; |
267 | if (BN_copy(abs_m, m) == NULL) | 267 | if (!bn_copy(abs_m, m)) |
268 | goto err; | 268 | goto err; |
269 | BN_set_negative(abs_m, 0); | 269 | BN_set_negative(abs_m, 0); |
270 | m = abs_m; | 270 | m = abs_m; |
@@ -288,7 +288,7 @@ BN_mod_lshift_quick(BIGNUM *r, const BIGNUM *a, int n, const BIGNUM *m) | |||
288 | { | 288 | { |
289 | int max_shift; | 289 | int max_shift; |
290 | 290 | ||
291 | if (BN_copy(r, a) == NULL) | 291 | if (!bn_copy(r, a)) |
292 | return 0; | 292 | return 0; |
293 | 293 | ||
294 | while (n > 0) { | 294 | while (n > 0) { |
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index 582c8d4ef8..b7b2384cff 100644 --- a/src/lib/libcrypto/bn/bn_mont.c +++ b/src/lib/libcrypto/bn/bn_mont.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_mont.c,v 1.53 2023/03/26 19:09:42 tb Exp $ */ | 1 | /* $OpenBSD: bn_mont.c,v 1.54 2023/03/27 10:21:23 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 | * |
@@ -561,7 +561,7 @@ BN_from_montgomery(BIGNUM *r, const BIGNUM *a, BN_MONT_CTX *mctx, BN_CTX *ctx) | |||
561 | 561 | ||
562 | if ((tmp = BN_CTX_get(ctx)) == NULL) | 562 | if ((tmp = BN_CTX_get(ctx)) == NULL) |
563 | goto err; | 563 | goto err; |
564 | if (BN_copy(tmp, a) == NULL) | 564 | if (!bn_copy(tmp, a)) |
565 | goto err; | 565 | goto err; |
566 | if (!bn_montgomery_reduce(r, tmp, mctx)) | 566 | if (!bn_montgomery_reduce(r, tmp, mctx)) |
567 | goto err; | 567 | goto err; |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 271c8435f8..25bcb06e88 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.29 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.30 2023/03/27 10:21:23 tb Exp $ */ |
2 | /* | 2 | /* |
3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
4 | */ | 4 | */ |
@@ -322,7 +322,7 @@ ecdsa_do_sign(const unsigned char *dgst, int dgst_len, | |||
322 | ckinv = kinv; | 322 | ckinv = kinv; |
323 | } else { | 323 | } else { |
324 | ckinv = in_kinv; | 324 | ckinv = in_kinv; |
325 | if (BN_copy(ret->r, in_r) == NULL) { | 325 | if (!bn_copy(ret->r, in_r)) { |
326 | ECDSAerror(ERR_R_MALLOC_FAILURE); | 326 | ECDSAerror(ERR_R_MALLOC_FAILURE); |
327 | goto err; | 327 | goto err; |
328 | } | 328 | } |