diff options
| author | tb <> | 2023-03-27 10:25:02 +0000 |
|---|---|---|
| committer | tb <> | 2023-03-27 10:25:02 +0000 |
| commit | f01ccc7c36ff1a6f9eaa959f859f2fe82c336039 (patch) | |
| tree | ba91913b4904177f237fb62457d06d7234e7ad69 | |
| parent | 00aea13536dd9c7115e084e54260c208dfdfb18a (diff) | |
| download | openbsd-f01ccc7c36ff1a6f9eaa959f859f2fe82c336039.tar.gz openbsd-f01ccc7c36ff1a6f9eaa959f859f2fe82c336039.tar.bz2 openbsd-f01ccc7c36ff1a6f9eaa959f859f2fe82c336039.zip | |
Replace the remaining BN_copy() with bn_copy()
ok jsing
| -rw-r--r-- | src/lib/libcrypto/bn/bn_blind.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_exp.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_gcd.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_gf2m.c | 18 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_isqrt.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_mont.c | 8 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_recp.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_sqrt.c | 10 | ||||
| -rw-r--r-- | src/lib/libcrypto/bn/bn_x931p.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_gen.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/dsa/dsa_ossl.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec2_mult.c | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec2_smpl.c | 44 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_key.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ec_lib.c | 16 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_mont.c | 4 | ||||
| -rw-r--r-- | src/lib/libcrypto/ec/ecp_smpl.c | 66 | ||||
| -rw-r--r-- | src/lib/libcrypto/ecdsa/ecs_ossl.c | 6 |
19 files changed, 116 insertions, 116 deletions
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c index 61d0cf7a95..9c07f33e1f 100644 --- a/src/lib/libcrypto/bn/bn_blind.c +++ b/src/lib/libcrypto/bn/bn_blind.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_blind.c,v 1.20 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: bn_blind.c,v 1.21 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. |
| 4 | * | 4 | * |
| @@ -244,7 +244,7 @@ BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) | |||
| 244 | return (0); | 244 | return (0); |
| 245 | 245 | ||
| 246 | if (r != NULL) { | 246 | if (r != NULL) { |
| 247 | if (!BN_copy(r, b->Ai)) | 247 | if (!bn_copy(r, b->Ai)) |
| 248 | ret = 0; | 248 | ret = 0; |
| 249 | } | 249 | } |
| 250 | 250 | ||
diff --git a/src/lib/libcrypto/bn/bn_exp.c b/src/lib/libcrypto/bn/bn_exp.c index b756d2b305..4e90d5d871 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.43 2023/03/27 10:22:47 tb Exp $ */ | 1 | /* $OpenBSD: bn_exp.c,v 1.44 2023/03/27 10:25:02 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 | * |
| @@ -816,7 +816,7 @@ BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, | |||
| 816 | (BN_mod_ct(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1)))) | 816 | (BN_mod_ct(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1)))) |
| 817 | /* BN_MOD_MUL_WORD is only used with 'w' large, | 817 | /* BN_MOD_MUL_WORD is only used with 'w' large, |
| 818 | * so the BN_ucmp test is probably more overhead | 818 | * so the BN_ucmp test is probably more overhead |
| 819 | * than always using BN_mod (which uses BN_copy if | 819 | * than always using BN_mod (which uses bn_copy if |
| 820 | * a similar test returns true). */ | 820 | * a similar test returns true). */ |
| 821 | /* We can use BN_mod and do not need BN_nnmod because our | 821 | /* We can use BN_mod and do not need BN_nnmod because our |
| 822 | * accumulator is never negative (the result of BN_mod does | 822 | * accumulator is never negative (the result of BN_mod does |
| @@ -985,7 +985,7 @@ BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, const BIGNUM *m, | |||
| 985 | 985 | ||
| 986 | if (m->neg) { | 986 | if (m->neg) { |
| 987 | /* ignore sign of 'm' */ | 987 | /* ignore sign of 'm' */ |
| 988 | if (!BN_copy(aa, m)) | 988 | if (!bn_copy(aa, m)) |
| 989 | goto err; | 989 | goto err; |
| 990 | aa->neg = 0; | 990 | aa->neg = 0; |
| 991 | if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) | 991 | if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) |
diff --git a/src/lib/libcrypto/bn/bn_gcd.c b/src/lib/libcrypto/bn/bn_gcd.c index 138befc868..4a79f26c6f 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.22 2023/03/27 10:21:23 tb Exp $ */ | 1 | /* $OpenBSD: bn_gcd.c,v 1.23 2023/03/27 10:25:02 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 | * |
| @@ -314,7 +314,7 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
| 314 | * A == gcd(a,n); | 314 | * A == gcd(a,n); |
| 315 | */ | 315 | */ |
| 316 | 316 | ||
| 317 | if (!BN_copy(R, A)) | 317 | if (!bn_copy(R, A)) |
| 318 | goto err; | 318 | goto err; |
| 319 | ret = R; | 319 | ret = R; |
| 320 | err: | 320 | err: |
| @@ -524,7 +524,7 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, | |||
| 524 | if (BN_is_one(A)) { | 524 | if (BN_is_one(A)) { |
| 525 | /* Y*a == 1 (mod |n|) */ | 525 | /* Y*a == 1 (mod |n|) */ |
| 526 | if (!Y->neg && BN_ucmp(Y, n) < 0) { | 526 | if (!Y->neg && BN_ucmp(Y, n) < 0) { |
| 527 | if (!BN_copy(R, Y)) | 527 | if (!bn_copy(R, Y)) |
| 528 | goto err; | 528 | goto err; |
| 529 | } else { | 529 | } else { |
| 530 | if (!BN_nnmod(R, Y, n, ctx)) | 530 | if (!BN_nnmod(R, Y, n, ctx)) |
| @@ -779,7 +779,7 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct | |||
| 779 | if (!BN_lshift(tmp, X, 2)) | 779 | if (!BN_lshift(tmp, X, 2)) |
| 780 | goto err; | 780 | goto err; |
| 781 | } else if (D->top == 1) { | 781 | } else if (D->top == 1) { |
| 782 | if (!BN_copy(tmp, X)) | 782 | if (!bn_copy(tmp, X)) |
| 783 | goto err; | 783 | goto err; |
| 784 | if (!BN_mul_word(tmp, D->d[0])) | 784 | if (!BN_mul_word(tmp, D->d[0])) |
| 785 | goto err; | 785 | goto err; |
| @@ -815,7 +815,7 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct | |||
| 815 | if (BN_is_one(A)) { | 815 | if (BN_is_one(A)) { |
| 816 | /* Y*a == 1 (mod |n|) */ | 816 | /* Y*a == 1 (mod |n|) */ |
| 817 | if (!Y->neg && BN_ucmp(Y, n) < 0) { | 817 | if (!Y->neg && BN_ucmp(Y, n) < 0) { |
| 818 | if (!BN_copy(R, Y)) | 818 | if (!bn_copy(R, Y)) |
| 819 | goto err; | 819 | goto err; |
| 820 | } else { | 820 | } else { |
| 821 | if (!BN_nnmod(R, Y,n, ctx)) | 821 | if (!BN_nnmod(R, Y,n, ctx)) |
diff --git a/src/lib/libcrypto/bn/bn_gf2m.c b/src/lib/libcrypto/bn/bn_gf2m.c index 3a0accb4a2..62ac2a5151 100644 --- a/src/lib/libcrypto/bn/bn_gf2m.c +++ b/src/lib/libcrypto/bn/bn_gf2m.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_gf2m.c,v 1.31 2023/03/27 10:20:27 tb Exp $ */ | 1 | /* $OpenBSD: bn_gf2m.c,v 1.32 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -643,7 +643,7 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 643 | if (BN_is_zero(u)) | 643 | if (BN_is_zero(u)) |
| 644 | goto err; | 644 | goto err; |
| 645 | 645 | ||
| 646 | if (!BN_copy(v, p)) | 646 | if (!bn_copy(v, p)) |
| 647 | goto err; | 647 | goto err; |
| 648 | #if 0 | 648 | #if 0 |
| 649 | if (!BN_one(b)) | 649 | if (!BN_one(b)) |
| @@ -773,7 +773,7 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 773 | } | 773 | } |
| 774 | #endif | 774 | #endif |
| 775 | 775 | ||
| 776 | if (!BN_copy(r, b)) | 776 | if (!bn_copy(r, b)) |
| 777 | goto err; | 777 | goto err; |
| 778 | ret = 1; | 778 | ret = 1; |
| 779 | 779 | ||
| @@ -865,7 +865,7 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, | |||
| 865 | goto err; | 865 | goto err; |
| 866 | if (!BN_GF2m_mod(a, x, p)) | 866 | if (!BN_GF2m_mod(a, x, p)) |
| 867 | goto err; | 867 | goto err; |
| 868 | if (!BN_copy(b, p)) | 868 | if (!bn_copy(b, p)) |
| 869 | goto err; | 869 | goto err; |
| 870 | 870 | ||
| 871 | while (!BN_is_odd(a)) { | 871 | while (!BN_is_odd(a)) { |
| @@ -912,7 +912,7 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, | |||
| 912 | } | 912 | } |
| 913 | } while (1); | 913 | } while (1); |
| 914 | 914 | ||
| 915 | if (!BN_copy(r, u)) | 915 | if (!bn_copy(r, u)) |
| 916 | goto err; | 916 | goto err; |
| 917 | ret = 1; | 917 | ret = 1; |
| 918 | 918 | ||
| @@ -985,7 +985,7 @@ BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], | |||
| 985 | goto err; | 985 | goto err; |
| 986 | } | 986 | } |
| 987 | } | 987 | } |
| 988 | if (!BN_copy(r, u)) | 988 | if (!bn_copy(r, u)) |
| 989 | goto err; | 989 | goto err; |
| 990 | ret = 1; | 990 | ret = 1; |
| 991 | 991 | ||
| @@ -1117,7 +1117,7 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], | |||
| 1117 | if (p[0] & 0x1) /* m is odd */ | 1117 | if (p[0] & 0x1) /* m is odd */ |
| 1118 | { | 1118 | { |
| 1119 | /* compute half-trace of a */ | 1119 | /* compute half-trace of a */ |
| 1120 | if (!BN_copy(z, a)) | 1120 | if (!bn_copy(z, a)) |
| 1121 | goto err; | 1121 | goto err; |
| 1122 | for (j = 1; j <= (p[0] - 1) / 2; j++) { | 1122 | for (j = 1; j <= (p[0] - 1) / 2; j++) { |
| 1123 | if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) | 1123 | if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) |
| @@ -1143,7 +1143,7 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], | |||
| 1143 | if (!BN_GF2m_mod_arr(rho, rho, p)) | 1143 | if (!BN_GF2m_mod_arr(rho, rho, p)) |
| 1144 | goto err; | 1144 | goto err; |
| 1145 | BN_zero(z); | 1145 | BN_zero(z); |
| 1146 | if (!BN_copy(w, rho)) | 1146 | if (!bn_copy(w, rho)) |
| 1147 | goto err; | 1147 | goto err; |
| 1148 | for (j = 1; j <= p[0] - 1; j++) { | 1148 | for (j = 1; j <= p[0] - 1; j++) { |
| 1149 | if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) | 1149 | if (!BN_GF2m_mod_sqr_arr(z, z, p, ctx)) |
| @@ -1174,7 +1174,7 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], | |||
| 1174 | goto err; | 1174 | goto err; |
| 1175 | } | 1175 | } |
| 1176 | 1176 | ||
| 1177 | if (!BN_copy(r, z)) | 1177 | if (!bn_copy(r, z)) |
| 1178 | goto err; | 1178 | goto err; |
| 1179 | 1179 | ||
| 1180 | ret = 1; | 1180 | ret = 1; |
diff --git a/src/lib/libcrypto/bn/bn_isqrt.c b/src/lib/libcrypto/bn/bn_isqrt.c index ec77e1b078..4a757b02ce 100644 --- a/src/lib/libcrypto/bn/bn_isqrt.c +++ b/src/lib/libcrypto/bn/bn_isqrt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_isqrt.c,v 1.6 2022/12/17 15:56:25 jsing Exp $ */ | 1 | /* $OpenBSD: bn_isqrt.c,v 1.7 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> | 3 | * Copyright (c) 2022 Theo Buehler <tb@openbsd.org> |
| 4 | * | 4 | * |
| @@ -141,7 +141,7 @@ bn_isqrt(BIGNUM *out_sqrt, int *out_perfect, const BIGNUM *n, BN_CTX *in_ctx) | |||
| 141 | *out_perfect = perfect; | 141 | *out_perfect = perfect; |
| 142 | 142 | ||
| 143 | if (out_sqrt != NULL) { | 143 | if (out_sqrt != NULL) { |
| 144 | if (!BN_copy(out_sqrt, a)) | 144 | if (!bn_copy(out_sqrt, a)) |
| 145 | goto err; | 145 | goto err; |
| 146 | } | 146 | } |
| 147 | 147 | ||
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 9da03e2c6e..49cc6662db 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_lib.c,v 1.77 2023/03/27 08:37:33 tb Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.78 2023/03/27 10:25:02 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 | * |
| @@ -333,7 +333,7 @@ BN_dup(const BIGNUM *a) | |||
| 333 | t = BN_new(); | 333 | t = BN_new(); |
| 334 | if (t == NULL) | 334 | if (t == NULL) |
| 335 | return NULL; | 335 | return NULL; |
| 336 | if (!BN_copy(t, a)) { | 336 | if (!bn_copy(t, a)) { |
| 337 | BN_free(t); | 337 | BN_free(t); |
| 338 | return NULL; | 338 | return NULL; |
| 339 | } | 339 | } |
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c index b7b2384cff..4b904c876a 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.54 2023/03/27 10:21:23 tb Exp $ */ | 1 | /* $OpenBSD: bn_mont.c,v 1.55 2023/03/27 10:25:02 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 | * |
| @@ -166,9 +166,9 @@ BN_MONT_CTX_copy(BN_MONT_CTX *dst, BN_MONT_CTX *src) | |||
| 166 | if (dst == src) | 166 | if (dst == src) |
| 167 | return dst; | 167 | return dst; |
| 168 | 168 | ||
| 169 | if (!BN_copy(&dst->RR, &src->RR)) | 169 | if (!bn_copy(&dst->RR, &src->RR)) |
| 170 | return NULL; | 170 | return NULL; |
| 171 | if (!BN_copy(&dst->N, &src->N)) | 171 | if (!bn_copy(&dst->N, &src->N)) |
| 172 | return NULL; | 172 | return NULL; |
| 173 | 173 | ||
| 174 | dst->ri = src->ri; | 174 | dst->ri = src->ri; |
| @@ -198,7 +198,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) | |||
| 198 | /* Save modulus and determine length of R. */ | 198 | /* Save modulus and determine length of R. */ |
| 199 | if (BN_is_zero(mod)) | 199 | if (BN_is_zero(mod)) |
| 200 | goto err; | 200 | goto err; |
| 201 | if (!BN_copy(&mont->N, mod)) | 201 | if (!bn_copy(&mont->N, mod)) |
| 202 | goto err; | 202 | goto err; |
| 203 | mont->N.neg = 0; | 203 | mont->N.neg = 0; |
| 204 | mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2; | 204 | mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2; |
diff --git a/src/lib/libcrypto/bn/bn_recp.c b/src/lib/libcrypto/bn/bn_recp.c index 117f8933bb..35390e30d4 100644 --- a/src/lib/libcrypto/bn/bn_recp.c +++ b/src/lib/libcrypto/bn/bn_recp.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_recp.c,v 1.18 2023/02/13 04:25:37 jsing Exp $ */ | 1 | /* $OpenBSD: bn_recp.c,v 1.19 2023/03/27 10:25:02 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 | * |
| @@ -99,7 +99,7 @@ BN_RECP_CTX_free(BN_RECP_CTX *recp) | |||
| 99 | int | 99 | int |
| 100 | BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) | 100 | BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) |
| 101 | { | 101 | { |
| 102 | if (!BN_copy(&(recp->N), d)) | 102 | if (!bn_copy(&(recp->N), d)) |
| 103 | return 0; | 103 | return 0; |
| 104 | BN_zero(&(recp->Nr)); | 104 | BN_zero(&(recp->Nr)); |
| 105 | recp->num_bits = BN_num_bits(d); | 105 | recp->num_bits = BN_num_bits(d); |
| @@ -160,7 +160,7 @@ BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, BN_RECP_CTX *recp, | |||
| 160 | 160 | ||
| 161 | if (BN_ucmp(m, &(recp->N)) < 0) { | 161 | if (BN_ucmp(m, &(recp->N)) < 0) { |
| 162 | BN_zero(d); | 162 | BN_zero(d); |
| 163 | if (!BN_copy(r, m)) { | 163 | if (!bn_copy(r, m)) { |
| 164 | BN_CTX_end(ctx); | 164 | BN_CTX_end(ctx); |
| 165 | return 0; | 165 | return 0; |
| 166 | } | 166 | } |
diff --git a/src/lib/libcrypto/bn/bn_sqrt.c b/src/lib/libcrypto/bn/bn_sqrt.c index 9bbca4267a..3d9f017f59 100644 --- a/src/lib/libcrypto/bn/bn_sqrt.c +++ b/src/lib/libcrypto/bn/bn_sqrt.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_sqrt.c,v 1.15 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: bn_sqrt.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> | 2 | /* Written by Lenka Fibikova <fibikova@exp-math.uni-essen.de> |
| 3 | * and Bodo Moeller for the OpenSSL project. */ | 3 | * and Bodo Moeller for the OpenSSL project. */ |
| 4 | /* ==================================================================== | 4 | /* ==================================================================== |
| @@ -209,7 +209,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 209 | if (!BN_mod_mul(x, x, t, p, ctx)) | 209 | if (!BN_mod_mul(x, x, t, p, ctx)) |
| 210 | goto end; | 210 | goto end; |
| 211 | 211 | ||
| 212 | if (!BN_copy(ret, x)) | 212 | if (!bn_copy(ret, x)) |
| 213 | goto end; | 213 | goto end; |
| 214 | err = 0; | 214 | err = 0; |
| 215 | goto vrfy; | 215 | goto vrfy; |
| @@ -217,7 +217,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 217 | 217 | ||
| 218 | /* e > 2, so we really have to use the Tonelli/Shanks algorithm. | 218 | /* e > 2, so we really have to use the Tonelli/Shanks algorithm. |
| 219 | * First, find some y that is not a square. */ | 219 | * First, find some y that is not a square. */ |
| 220 | if (!BN_copy(q, p)) /* use 'q' as temp */ | 220 | if (!bn_copy(q, p)) /* use 'q' as temp */ |
| 221 | goto end; | 221 | goto end; |
| 222 | q->neg = 0; | 222 | q->neg = 0; |
| 223 | i = 2; | 223 | i = 2; |
| @@ -344,7 +344,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 344 | */ | 344 | */ |
| 345 | 345 | ||
| 346 | if (BN_is_one(b)) { | 346 | if (BN_is_one(b)) { |
| 347 | if (!BN_copy(ret, x)) | 347 | if (!bn_copy(ret, x)) |
| 348 | goto end; | 348 | goto end; |
| 349 | err = 0; | 349 | err = 0; |
| 350 | goto vrfy; | 350 | goto vrfy; |
| @@ -368,7 +368,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) | |||
| 368 | } | 368 | } |
| 369 | 369 | ||
| 370 | /* t := y^2^(e - i - 1) */ | 370 | /* t := y^2^(e - i - 1) */ |
| 371 | if (!BN_copy(t, y)) | 371 | if (!bn_copy(t, y)) |
| 372 | goto end; | 372 | goto end; |
| 373 | for (j = e - i - 1; j > 0; j--) { | 373 | for (j = e - i - 1; j > 0; j--) { |
| 374 | if (!BN_mod_sqr(t, t, p, ctx)) | 374 | if (!BN_mod_sqr(t, t, p, ctx)) |
diff --git a/src/lib/libcrypto/bn/bn_x931p.c b/src/lib/libcrypto/bn/bn_x931p.c index e73c416e3f..9105be11cd 100644 --- a/src/lib/libcrypto/bn/bn_x931p.c +++ b/src/lib/libcrypto/bn/bn_x931p.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: bn_x931p.c,v 1.15 2022/12/26 07:18:51 jmc Exp $ */ | 1 | /* $OpenBSD: bn_x931p.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 2005. | 3 | * project 2005. |
| 4 | */ | 4 | */ |
| @@ -73,7 +73,7 @@ bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, BN_GENCB *cb) | |||
| 73 | { | 73 | { |
| 74 | int i = 0, is_prime; | 74 | int i = 0, is_prime; |
| 75 | 75 | ||
| 76 | if (!BN_copy(pi, Xpi)) | 76 | if (!bn_copy(pi, Xpi)) |
| 77 | return 0; | 77 | return 0; |
| 78 | if (!BN_is_odd(pi) && !BN_add_word(pi, 1)) | 78 | if (!BN_is_odd(pi) && !BN_add_word(pi, 1)) |
| 79 | return 0; | 79 | return 0; |
| @@ -170,7 +170,7 @@ BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, | |||
| 170 | for (;;) { | 170 | for (;;) { |
| 171 | int i = 1; | 171 | int i = 1; |
| 172 | BN_GENCB_call(cb, 0, i++); | 172 | BN_GENCB_call(cb, 0, i++); |
| 173 | if (!BN_copy(pm1, p)) | 173 | if (!bn_copy(pm1, p)) |
| 174 | goto err; | 174 | goto err; |
| 175 | if (!BN_sub_word(pm1, 1)) | 175 | if (!BN_sub_word(pm1, 1)) |
| 176 | goto err; | 176 | goto err; |
diff --git a/src/lib/libcrypto/dsa/dsa_gen.c b/src/lib/libcrypto/dsa/dsa_gen.c index 1f91894100..49b4561494 100644 --- a/src/lib/libcrypto/dsa/dsa_gen.c +++ b/src/lib/libcrypto/dsa/dsa_gen.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_gen.c,v 1.27 2023/01/11 04:39:42 jsing Exp $ */ | 1 | /* $OpenBSD: dsa_gen.c,v 1.28 2023/03/27 10:25:02 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 @@ dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, | |||
| 264 | /* more of step 8 */ | 264 | /* more of step 8 */ |
| 265 | if (!BN_mask_bits(W, bits - 1)) | 265 | if (!BN_mask_bits(W, bits - 1)) |
| 266 | goto err; | 266 | goto err; |
| 267 | if (!BN_copy(X, W)) | 267 | if (!bn_copy(X, W)) |
| 268 | goto err; | 268 | goto err; |
| 269 | if (!BN_add(X, X, test)) | 269 | if (!BN_add(X, X, test)) |
| 270 | goto err; | 270 | goto err; |
diff --git a/src/lib/libcrypto/dsa/dsa_ossl.c b/src/lib/libcrypto/dsa/dsa_ossl.c index ece1026fc9..b69cf1a03f 100644 --- a/src/lib/libcrypto/dsa/dsa_ossl.c +++ b/src/lib/libcrypto/dsa/dsa_ossl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: dsa_ossl.c,v 1.50 2023/03/04 21:30:23 tb Exp $ */ | 1 | /* $OpenBSD: dsa_ossl.c,v 1.51 2023/03/27 10:25:02 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 | * |
| @@ -282,13 +282,13 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
| 282 | * small timing information leakage. We then choose the sum that is | 282 | * small timing information leakage. We then choose the sum that is |
| 283 | * one bit longer than the modulus. | 283 | * one bit longer than the modulus. |
| 284 | * | 284 | * |
| 285 | * TODO: revisit the BN_copy aiming for a memory access agnostic | 285 | * TODO: revisit the bn_copy aiming for a memory access agnostic |
| 286 | * conditional copy. | 286 | * conditional copy. |
| 287 | */ | 287 | */ |
| 288 | 288 | ||
| 289 | if (!BN_add(l, k, dsa->q) || | 289 | if (!BN_add(l, k, dsa->q) || |
| 290 | !BN_add(m, l, dsa->q) || | 290 | !BN_add(m, l, dsa->q) || |
| 291 | !BN_copy(k, BN_num_bits(l) > q_bits ? l : m)) | 291 | !bn_copy(k, BN_num_bits(l) > q_bits ? l : m)) |
| 292 | goto err; | 292 | goto err; |
| 293 | 293 | ||
| 294 | if (dsa->meth->bn_mod_exp != NULL) { | 294 | if (dsa->meth->bn_mod_exp != NULL) { |
diff --git a/src/lib/libcrypto/ec/ec2_mult.c b/src/lib/libcrypto/ec/ec2_mult.c index 8b8aaf7122..d32b7442c4 100644 --- a/src/lib/libcrypto/ec/ec2_mult.c +++ b/src/lib/libcrypto/ec/ec2_mult.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec2_mult.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ | 1 | /* $OpenBSD: ec2_mult.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -137,7 +137,7 @@ gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, | |||
| 137 | if ((t2 = BN_CTX_get(ctx)) == NULL) | 137 | if ((t2 = BN_CTX_get(ctx)) == NULL) |
| 138 | goto err; | 138 | goto err; |
| 139 | 139 | ||
| 140 | if (!BN_copy(t1, x)) | 140 | if (!bn_copy(t1, x)) |
| 141 | goto err; | 141 | goto err; |
| 142 | if (!group->meth->field_mul(group, x1, x1, z2, ctx)) | 142 | if (!group->meth->field_mul(group, x1, x1, z2, ctx)) |
| 143 | goto err; | 143 | goto err; |
| @@ -183,7 +183,7 @@ gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, | |||
| 183 | return 1; | 183 | return 1; |
| 184 | } | 184 | } |
| 185 | if (BN_is_zero(z2)) { | 185 | if (BN_is_zero(z2)) { |
| 186 | if (!BN_copy(x2, x)) | 186 | if (!bn_copy(x2, x)) |
| 187 | return 0; | 187 | return 0; |
| 188 | if (!BN_GF2m_add(z2, x, y)) | 188 | if (!BN_GF2m_add(z2, x, y)) |
| 189 | return 0; | 189 | return 0; |
diff --git a/src/lib/libcrypto/ec/ec2_smpl.c b/src/lib/libcrypto/ec/ec2_smpl.c index 84cba1b83b..1ad339cbd7 100644 --- a/src/lib/libcrypto/ec/ec2_smpl.c +++ b/src/lib/libcrypto/ec/ec2_smpl.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec2_smpl.c,v 1.33 2023/03/08 05:45:31 jsing Exp $ */ | 1 | /* $OpenBSD: ec2_smpl.c,v 1.34 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* ==================================================================== | 2 | /* ==================================================================== |
| 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. | 3 | * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. |
| 4 | * | 4 | * |
| @@ -115,11 +115,11 @@ ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) | |||
| 115 | { | 115 | { |
| 116 | int i; | 116 | int i; |
| 117 | 117 | ||
| 118 | if (!BN_copy(&dest->field, &src->field)) | 118 | if (!bn_copy(&dest->field, &src->field)) |
| 119 | return 0; | 119 | return 0; |
| 120 | if (!BN_copy(&dest->a, &src->a)) | 120 | if (!bn_copy(&dest->a, &src->a)) |
| 121 | return 0; | 121 | return 0; |
| 122 | if (!BN_copy(&dest->b, &src->b)) | 122 | if (!bn_copy(&dest->b, &src->b)) |
| 123 | return 0; | 123 | return 0; |
| 124 | dest->poly[0] = src->poly[0]; | 124 | dest->poly[0] = src->poly[0]; |
| 125 | dest->poly[1] = src->poly[1]; | 125 | dest->poly[1] = src->poly[1]; |
| @@ -146,7 +146,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP *group, | |||
| 146 | int ret = 0, i; | 146 | int ret = 0, i; |
| 147 | 147 | ||
| 148 | /* group->field */ | 148 | /* group->field */ |
| 149 | if (!BN_copy(&group->field, p)) | 149 | if (!bn_copy(&group->field, p)) |
| 150 | goto err; | 150 | goto err; |
| 151 | i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; | 151 | i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; |
| 152 | if ((i != 5) && (i != 3)) { | 152 | if ((i != 5) && (i != 3)) { |
| @@ -185,15 +185,15 @@ ec_GF2m_simple_group_get_curve(const EC_GROUP *group, | |||
| 185 | int ret = 0; | 185 | int ret = 0; |
| 186 | 186 | ||
| 187 | if (p != NULL) { | 187 | if (p != NULL) { |
| 188 | if (!BN_copy(p, &group->field)) | 188 | if (!bn_copy(p, &group->field)) |
| 189 | return 0; | 189 | return 0; |
| 190 | } | 190 | } |
| 191 | if (a != NULL) { | 191 | if (a != NULL) { |
| 192 | if (!BN_copy(a, &group->a)) | 192 | if (!bn_copy(a, &group->a)) |
| 193 | goto err; | 193 | goto err; |
| 194 | } | 194 | } |
| 195 | if (b != NULL) { | 195 | if (b != NULL) { |
| 196 | if (!BN_copy(b, &group->b)) | 196 | if (!bn_copy(b, &group->b)) |
| 197 | goto err; | 197 | goto err; |
| 198 | } | 198 | } |
| 199 | ret = 1; | 199 | ret = 1; |
| @@ -274,11 +274,11 @@ ec_GF2m_simple_point_finish(EC_POINT *point) | |||
| 274 | static int | 274 | static int |
| 275 | ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) | 275 | ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) |
| 276 | { | 276 | { |
| 277 | if (!BN_copy(&dest->X, &src->X)) | 277 | if (!bn_copy(&dest->X, &src->X)) |
| 278 | return 0; | 278 | return 0; |
| 279 | if (!BN_copy(&dest->Y, &src->Y)) | 279 | if (!bn_copy(&dest->Y, &src->Y)) |
| 280 | return 0; | 280 | return 0; |
| 281 | if (!BN_copy(&dest->Z, &src->Z)) | 281 | if (!bn_copy(&dest->Z, &src->Z)) |
| 282 | return 0; | 282 | return 0; |
| 283 | dest->Z_is_one = src->Z_is_one; | 283 | dest->Z_is_one = src->Z_is_one; |
| 284 | 284 | ||
| @@ -310,13 +310,13 @@ ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *poi | |||
| 310 | ECerror(ERR_R_PASSED_NULL_PARAMETER); | 310 | ECerror(ERR_R_PASSED_NULL_PARAMETER); |
| 311 | return 0; | 311 | return 0; |
| 312 | } | 312 | } |
| 313 | if (!BN_copy(&point->X, x)) | 313 | if (!bn_copy(&point->X, x)) |
| 314 | goto err; | 314 | goto err; |
| 315 | BN_set_negative(&point->X, 0); | 315 | BN_set_negative(&point->X, 0); |
| 316 | if (!BN_copy(&point->Y, y)) | 316 | if (!bn_copy(&point->Y, y)) |
| 317 | goto err; | 317 | goto err; |
| 318 | BN_set_negative(&point->Y, 0); | 318 | BN_set_negative(&point->Y, 0); |
| 319 | if (!BN_copy(&point->Z, BN_value_one())) | 319 | if (!bn_copy(&point->Z, BN_value_one())) |
| 320 | goto err; | 320 | goto err; |
| 321 | BN_set_negative(&point->Z, 0); | 321 | BN_set_negative(&point->Z, 0); |
| 322 | point->Z_is_one = 1; | 322 | point->Z_is_one = 1; |
| @@ -345,12 +345,12 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, | |||
| 345 | return 0; | 345 | return 0; |
| 346 | } | 346 | } |
| 347 | if (x != NULL) { | 347 | if (x != NULL) { |
| 348 | if (!BN_copy(x, &point->X)) | 348 | if (!bn_copy(x, &point->X)) |
| 349 | goto err; | 349 | goto err; |
| 350 | BN_set_negative(x, 0); | 350 | BN_set_negative(x, 0); |
| 351 | } | 351 | } |
| 352 | if (y != NULL) { | 352 | if (y != NULL) { |
| 353 | if (!BN_copy(y, &point->Y)) | 353 | if (!bn_copy(y, &point->Y)) |
| 354 | goto err; | 354 | goto err; |
| 355 | BN_set_negative(y, 0); | 355 | BN_set_negative(y, 0); |
| 356 | } | 356 | } |
| @@ -406,18 +406,18 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, | |||
| 406 | goto err; | 406 | goto err; |
| 407 | 407 | ||
| 408 | if (a->Z_is_one) { | 408 | if (a->Z_is_one) { |
| 409 | if (!BN_copy(x0, &a->X)) | 409 | if (!bn_copy(x0, &a->X)) |
| 410 | goto err; | 410 | goto err; |
| 411 | if (!BN_copy(y0, &a->Y)) | 411 | if (!bn_copy(y0, &a->Y)) |
| 412 | goto err; | 412 | goto err; |
| 413 | } else { | 413 | } else { |
| 414 | if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)) | 414 | if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)) |
| 415 | goto err; | 415 | goto err; |
| 416 | } | 416 | } |
| 417 | if (b->Z_is_one) { | 417 | if (b->Z_is_one) { |
| 418 | if (!BN_copy(x1, &b->X)) | 418 | if (!bn_copy(x1, &b->X)) |
| 419 | goto err; | 419 | goto err; |
| 420 | if (!BN_copy(y1, &b->Y)) | 420 | if (!bn_copy(y1, &b->Y)) |
| 421 | goto err; | 421 | goto err; |
| 422 | } else { | 422 | } else { |
| 423 | if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx)) | 423 | if (!EC_POINT_get_affine_coordinates(group, b, x1, y1, ctx)) |
| @@ -647,9 +647,9 @@ ec_GF2m_simple_make_affine(const EC_GROUP *group, EC_POINT *point, BN_CTX *ctx) | |||
| 647 | 647 | ||
| 648 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) | 648 | if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) |
| 649 | goto err; | 649 | goto err; |
| 650 | if (!BN_copy(&point->X, x)) | 650 | if (!bn_copy(&point->X, x)) |
| 651 | goto err; | 651 | goto err; |
| 652 | if (!BN_copy(&point->Y, y)) | 652 | if (!bn_copy(&point->Y, y)) |
| 653 | goto err; | 653 | goto err; |
| 654 | if (!BN_one(&point->Z)) | 654 | if (!BN_one(&point->Z)) |
| 655 | goto err; | 655 | goto err; |
diff --git a/src/lib/libcrypto/ec/ec_key.c b/src/lib/libcrypto/ec/ec_key.c index 3799498ab1..2f9f05cc56 100644 --- a/src/lib/libcrypto/ec/ec_key.c +++ b/src/lib/libcrypto/ec/ec_key.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_key.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ | 1 | /* $OpenBSD: ec_key.c,v 1.32 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project. | 3 | * Written by Nils Larsch for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -172,7 +172,7 @@ EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) | |||
| 172 | if (dest->priv_key == NULL) | 172 | if (dest->priv_key == NULL) |
| 173 | return NULL; | 173 | return NULL; |
| 174 | } | 174 | } |
| 175 | if (!BN_copy(dest->priv_key, src->priv_key)) | 175 | if (!bn_copy(dest->priv_key, src->priv_key)) |
| 176 | return NULL; | 176 | return NULL; |
| 177 | } | 177 | } |
| 178 | /* copy method/extra data */ | 178 | /* copy method/extra data */ |
diff --git a/src/lib/libcrypto/ec/ec_lib.c b/src/lib/libcrypto/ec/ec_lib.c index 2d14f9c9c5..38ddd7af9f 100644 --- a/src/lib/libcrypto/ec/ec_lib.c +++ b/src/lib/libcrypto/ec/ec_lib.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ec_lib.c,v 1.51 2023/03/08 06:47:30 jsing Exp $ */ | 1 | /* $OpenBSD: ec_lib.c,v 1.52 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -181,9 +181,9 @@ EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) | |||
| 181 | dest->generator = NULL; | 181 | dest->generator = NULL; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | if (!BN_copy(&dest->order, &src->order)) | 184 | if (!bn_copy(&dest->order, &src->order)) |
| 185 | return 0; | 185 | return 0; |
| 186 | if (!BN_copy(&dest->cofactor, &src->cofactor)) | 186 | if (!bn_copy(&dest->cofactor, &src->cofactor)) |
| 187 | return 0; | 187 | return 0; |
| 188 | 188 | ||
| 189 | dest->curve_name = src->curve_name; | 189 | dest->curve_name = src->curve_name; |
| @@ -279,7 +279,7 @@ ec_guess_cofactor(EC_GROUP *group) | |||
| 279 | if (!BN_set_bit(q, BN_num_bits(&group->field) - 1)) | 279 | if (!BN_set_bit(q, BN_num_bits(&group->field) - 1)) |
| 280 | goto err; | 280 | goto err; |
| 281 | } else { | 281 | } else { |
| 282 | if (!BN_copy(q, &group->field)) | 282 | if (!bn_copy(q, &group->field)) |
| 283 | goto err; | 283 | goto err; |
| 284 | } | 284 | } |
| 285 | 285 | ||
| @@ -357,12 +357,12 @@ EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, | |||
| 357 | if (!EC_POINT_copy(group->generator, generator)) | 357 | if (!EC_POINT_copy(group->generator, generator)) |
| 358 | return 0; | 358 | return 0; |
| 359 | 359 | ||
| 360 | if (!BN_copy(&group->order, order)) | 360 | if (!bn_copy(&group->order, order)) |
| 361 | return 0; | 361 | return 0; |
| 362 | 362 | ||
| 363 | /* Either take the provided positive cofactor, or try to compute it. */ | 363 | /* Either take the provided positive cofactor, or try to compute it. */ |
| 364 | if (cofactor != NULL && !BN_is_zero(cofactor)) { | 364 | if (cofactor != NULL && !BN_is_zero(cofactor)) { |
| 365 | if (!BN_copy(&group->cofactor, cofactor)) | 365 | if (!bn_copy(&group->cofactor, cofactor)) |
| 366 | return 0; | 366 | return 0; |
| 367 | } else if (!ec_guess_cofactor(group)) | 367 | } else if (!ec_guess_cofactor(group)) |
| 368 | return 0; | 368 | return 0; |
| @@ -387,7 +387,7 @@ EC_GROUP_get0_generator(const EC_GROUP *group) | |||
| 387 | int | 387 | int |
| 388 | EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) | 388 | EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) |
| 389 | { | 389 | { |
| 390 | if (!BN_copy(order, &group->order)) | 390 | if (!bn_copy(order, &group->order)) |
| 391 | return 0; | 391 | return 0; |
| 392 | 392 | ||
| 393 | return !BN_is_zero(order); | 393 | return !BN_is_zero(order); |
| @@ -402,7 +402,7 @@ EC_GROUP_order_bits(const EC_GROUP *group) | |||
| 402 | int | 402 | int |
| 403 | EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) | 403 | EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) |
| 404 | { | 404 | { |
| 405 | if (!BN_copy(cofactor, &group->cofactor)) | 405 | if (!bn_copy(cofactor, &group->cofactor)) |
| 406 | return 0; | 406 | return 0; |
| 407 | 407 | ||
| 408 | return !BN_is_zero(&group->cofactor); | 408 | return !BN_is_zero(&group->cofactor); |
diff --git a/src/lib/libcrypto/ec/ecp_mont.c b/src/lib/libcrypto/ec/ecp_mont.c index 8b85bf32fa..915cf15f72 100644 --- a/src/lib/libcrypto/ec/ecp_mont.c +++ b/src/lib/libcrypto/ec/ecp_mont.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: ecp_mont.c,v 1.27 2023/03/08 05:45:31 jsing Exp $ */ | 1 | /* $OpenBSD: ecp_mont.c,v 1.28 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Originally written by Bodo Moeller for the OpenSSL project. | 3 | * Originally written by Bodo Moeller for the OpenSSL project. |
| 4 | */ | 4 | */ |
| @@ -220,7 +220,7 @@ ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) | |||
| 220 | ECerror(EC_R_NOT_INITIALIZED); | 220 | ECerror(EC_R_NOT_INITIALIZED); |
| 221 | return 0; | 221 | return 0; |
| 222 | } | 222 | } |
| 223 | if (!BN_copy(r, group->mont_one)) | 223 | if (!bn_copy(r, group->mont_one)) |
| 224 | return 0; | 224 | return 0; |
| 225 | return 1; | 225 | return 1; |
| 226 | } | 226 | } |
diff --git a/src/lib/libcrypto/ec/ecp_smpl.c b/src/lib/libcrypto/ec/ecp_smpl.c index 9af6034601..90330652e4 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.42 2023/03/08 05:45:31 jsing Exp $ */ | 1 | /* $OpenBSD: ecp_smpl.c,v 1.43 2023/03/27 10:25:02 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 | * Includes code written by Bodo Moeller for the OpenSSL project. | 4 | * Includes code written by Bodo Moeller for the OpenSSL project. |
| @@ -102,11 +102,11 @@ ec_GFp_simple_group_finish(EC_GROUP *group) | |||
| 102 | int | 102 | int |
| 103 | ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) | 103 | ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) |
| 104 | { | 104 | { |
| 105 | if (!BN_copy(&dest->field, &src->field)) | 105 | if (!bn_copy(&dest->field, &src->field)) |
| 106 | return 0; | 106 | return 0; |
| 107 | if (!BN_copy(&dest->a, &src->a)) | 107 | if (!bn_copy(&dest->a, &src->a)) |
| 108 | return 0; | 108 | return 0; |
| 109 | if (!BN_copy(&dest->b, &src->b)) | 109 | if (!bn_copy(&dest->b, &src->b)) |
| 110 | return 0; | 110 | return 0; |
| 111 | 111 | ||
| 112 | dest->a_is_minus3 = src->a_is_minus3; | 112 | dest->a_is_minus3 = src->a_is_minus3; |
| @@ -137,7 +137,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group, | |||
| 137 | goto err; | 137 | goto err; |
| 138 | 138 | ||
| 139 | /* group->field */ | 139 | /* group->field */ |
| 140 | if (!BN_copy(&group->field, p)) | 140 | if (!bn_copy(&group->field, p)) |
| 141 | goto err; | 141 | goto err; |
| 142 | BN_set_negative(&group->field, 0); | 142 | BN_set_negative(&group->field, 0); |
| 143 | 143 | ||
| @@ -147,7 +147,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group, | |||
| 147 | if (group->meth->field_encode) { | 147 | if (group->meth->field_encode) { |
| 148 | if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) | 148 | if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) |
| 149 | goto err; | 149 | goto err; |
| 150 | } else if (!BN_copy(&group->a, tmp_a)) | 150 | } else if (!bn_copy(&group->a, tmp_a)) |
| 151 | goto err; | 151 | goto err; |
| 152 | 152 | ||
| 153 | /* group->b */ | 153 | /* group->b */ |
| @@ -177,7 +177,7 @@ ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNU | |||
| 177 | BN_CTX *new_ctx = NULL; | 177 | BN_CTX *new_ctx = NULL; |
| 178 | 178 | ||
| 179 | if (p != NULL) { | 179 | if (p != NULL) { |
| 180 | if (!BN_copy(p, &group->field)) | 180 | if (!bn_copy(p, &group->field)) |
| 181 | return 0; | 181 | return 0; |
| 182 | } | 182 | } |
| 183 | if (a != NULL || b != NULL) { | 183 | if (a != NULL || b != NULL) { |
| @@ -197,11 +197,11 @@ ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNU | |||
| 197 | } | 197 | } |
| 198 | } else { | 198 | } else { |
| 199 | if (a != NULL) { | 199 | if (a != NULL) { |
| 200 | if (!BN_copy(a, &group->a)) | 200 | if (!bn_copy(a, &group->a)) |
| 201 | goto err; | 201 | goto err; |
| 202 | } | 202 | } |
| 203 | if (b != NULL) { | 203 | if (b != NULL) { |
| 204 | if (!BN_copy(b, &group->b)) | 204 | if (!bn_copy(b, &group->b)) |
| 205 | goto err; | 205 | goto err; |
| 206 | } | 206 | } |
| 207 | } | 207 | } |
| @@ -252,9 +252,9 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) | |||
| 252 | if (!group->meth->field_decode(group, b, &group->b, ctx)) | 252 | if (!group->meth->field_decode(group, b, &group->b, ctx)) |
| 253 | goto err; | 253 | goto err; |
| 254 | } else { | 254 | } else { |
| 255 | if (!BN_copy(a, &group->a)) | 255 | if (!bn_copy(a, &group->a)) |
| 256 | goto err; | 256 | goto err; |
| 257 | if (!BN_copy(b, &group->b)) | 257 | if (!bn_copy(b, &group->b)) |
| 258 | goto err; | 258 | goto err; |
| 259 | } | 259 | } |
| 260 | 260 | ||
| @@ -317,11 +317,11 @@ ec_GFp_simple_point_finish(EC_POINT *point) | |||
| 317 | int | 317 | int |
| 318 | ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) | 318 | ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) |
| 319 | { | 319 | { |
| 320 | if (!BN_copy(&dest->X, &src->X)) | 320 | if (!bn_copy(&dest->X, &src->X)) |
| 321 | return 0; | 321 | return 0; |
| 322 | if (!BN_copy(&dest->Y, &src->Y)) | 322 | if (!bn_copy(&dest->Y, &src->Y)) |
| 323 | return 0; | 323 | return 0; |
| 324 | if (!BN_copy(&dest->Z, &src->Z)) | 324 | if (!bn_copy(&dest->Z, &src->Z)) |
| 325 | return 0; | 325 | return 0; |
| 326 | dest->Z_is_one = src->Z_is_one; | 326 | dest->Z_is_one = src->Z_is_one; |
| 327 | 327 | ||
| @@ -416,15 +416,15 @@ ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group, | |||
| 416 | } | 416 | } |
| 417 | } else { | 417 | } else { |
| 418 | if (x != NULL) { | 418 | if (x != NULL) { |
| 419 | if (!BN_copy(x, &point->X)) | 419 | if (!bn_copy(x, &point->X)) |
| 420 | goto err; | 420 | goto err; |
| 421 | } | 421 | } |
| 422 | if (y != NULL) { | 422 | if (y != NULL) { |
| 423 | if (!BN_copy(y, &point->Y)) | 423 | if (!bn_copy(y, &point->Y)) |
| 424 | goto err; | 424 | goto err; |
| 425 | } | 425 | } |
| 426 | if (z != NULL) { | 426 | if (z != NULL) { |
| 427 | if (!BN_copy(z, &point->Z)) | 427 | if (!bn_copy(z, &point->Z)) |
| 428 | goto err; | 428 | goto err; |
| 429 | } | 429 | } |
| 430 | } | 430 | } |
| @@ -499,11 +499,11 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT | |||
| 499 | } | 499 | } |
| 500 | } else { | 500 | } else { |
| 501 | if (x != NULL) { | 501 | if (x != NULL) { |
| 502 | if (!BN_copy(x, &point->X)) | 502 | if (!bn_copy(x, &point->X)) |
| 503 | goto err; | 503 | goto err; |
| 504 | } | 504 | } |
| 505 | if (y != NULL) { | 505 | if (y != NULL) { |
| 506 | if (!BN_copy(y, &point->Y)) | 506 | if (!bn_copy(y, &point->Y)) |
| 507 | goto err; | 507 | goto err; |
| 508 | } | 508 | } |
| 509 | } | 509 | } |
| @@ -606,9 +606,9 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E | |||
| 606 | 606 | ||
| 607 | /* n1, n2 */ | 607 | /* n1, n2 */ |
| 608 | if (b->Z_is_one) { | 608 | if (b->Z_is_one) { |
| 609 | if (!BN_copy(n1, &a->X)) | 609 | if (!bn_copy(n1, &a->X)) |
| 610 | goto end; | 610 | goto end; |
| 611 | if (!BN_copy(n2, &a->Y)) | 611 | if (!bn_copy(n2, &a->Y)) |
| 612 | goto end; | 612 | goto end; |
| 613 | /* n1 = X_a */ | 613 | /* n1 = X_a */ |
| 614 | /* n2 = Y_a */ | 614 | /* n2 = Y_a */ |
| @@ -628,9 +628,9 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E | |||
| 628 | 628 | ||
| 629 | /* n3, n4 */ | 629 | /* n3, n4 */ |
| 630 | if (a->Z_is_one) { | 630 | if (a->Z_is_one) { |
| 631 | if (!BN_copy(n3, &b->X)) | 631 | if (!bn_copy(n3, &b->X)) |
| 632 | goto end; | 632 | goto end; |
| 633 | if (!BN_copy(n4, &b->Y)) | 633 | if (!bn_copy(n4, &b->Y)) |
| 634 | goto end; | 634 | goto end; |
| 635 | /* n3 = X_b */ | 635 | /* n3 = X_b */ |
| 636 | /* n4 = Y_b */ | 636 | /* n4 = Y_b */ |
| @@ -681,14 +681,14 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E | |||
| 681 | 681 | ||
| 682 | /* Z_r */ | 682 | /* Z_r */ |
| 683 | if (a->Z_is_one && b->Z_is_one) { | 683 | if (a->Z_is_one && b->Z_is_one) { |
| 684 | if (!BN_copy(&r->Z, n5)) | 684 | if (!bn_copy(&r->Z, n5)) |
| 685 | goto end; | 685 | goto end; |
| 686 | } else { | 686 | } else { |
| 687 | if (a->Z_is_one) { | 687 | if (a->Z_is_one) { |
| 688 | if (!BN_copy(n0, &b->Z)) | 688 | if (!bn_copy(n0, &b->Z)) |
| 689 | goto end; | 689 | goto end; |
| 690 | } else if (b->Z_is_one) { | 690 | } else if (b->Z_is_one) { |
| 691 | if (!BN_copy(n0, &a->Z)) | 691 | if (!bn_copy(n0, &a->Z)) |
| 692 | goto end; | 692 | goto end; |
| 693 | } else { | 693 | } else { |
| 694 | if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) | 694 | if (!field_mul(group, n0, &a->Z, &b->Z, ctx)) |
| @@ -832,7 +832,7 @@ ec_GFp_simple_dbl(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, BN_CTX | |||
| 832 | 832 | ||
| 833 | /* Z_r */ | 833 | /* Z_r */ |
| 834 | if (a->Z_is_one) { | 834 | if (a->Z_is_one) { |
| 835 | if (!BN_copy(n0, &a->Y)) | 835 | if (!bn_copy(n0, &a->Y)) |
| 836 | goto err; | 836 | goto err; |
| 837 | } else { | 837 | } else { |
| 838 | if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) | 838 | if (!field_mul(group, n0, &a->Y, &a->Z, ctx)) |
| @@ -1214,11 +1214,11 @@ ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *po | |||
| 1214 | 1214 | ||
| 1215 | if (heap[2 * i] != NULL) { | 1215 | if (heap[2 * i] != NULL) { |
| 1216 | if ((heap[2 * i + 1] == NULL) || BN_is_zero(heap[2 * i + 1])) { | 1216 | if ((heap[2 * i + 1] == NULL) || BN_is_zero(heap[2 * i + 1])) { |
| 1217 | if (!BN_copy(heap[i], heap[2 * i])) | 1217 | if (!bn_copy(heap[i], heap[2 * i])) |
| 1218 | goto err; | 1218 | goto err; |
| 1219 | } else { | 1219 | } else { |
| 1220 | if (BN_is_zero(heap[2 * i])) { | 1220 | if (BN_is_zero(heap[2 * i])) { |
| 1221 | if (!BN_copy(heap[i], heap[2 * i + 1])) | 1221 | if (!bn_copy(heap[i], heap[2 * i + 1])) |
| 1222 | goto err; | 1222 | goto err; |
| 1223 | } else { | 1223 | } else { |
| 1224 | if (!group->meth->field_mul(group, heap[i], | 1224 | if (!group->meth->field_mul(group, heap[i], |
| @@ -1256,12 +1256,12 @@ ec_GFp_simple_points_make_affine(const EC_GROUP *group, size_t num, EC_POINT *po | |||
| 1256 | goto err; | 1256 | goto err; |
| 1257 | if (!group->meth->field_mul(group, tmp1, heap[i / 2], heap[i], ctx)) | 1257 | if (!group->meth->field_mul(group, tmp1, heap[i / 2], heap[i], ctx)) |
| 1258 | goto err; | 1258 | goto err; |
| 1259 | if (!BN_copy(heap[i], tmp0)) | 1259 | if (!bn_copy(heap[i], tmp0)) |
| 1260 | goto err; | 1260 | goto err; |
| 1261 | if (!BN_copy(heap[i + 1], tmp1)) | 1261 | if (!bn_copy(heap[i + 1], tmp1)) |
| 1262 | goto err; | 1262 | goto err; |
| 1263 | } else { | 1263 | } else { |
| 1264 | if (!BN_copy(heap[i], heap[i / 2])) | 1264 | if (!bn_copy(heap[i], heap[i / 2])) |
| 1265 | goto err; | 1265 | goto err; |
| 1266 | } | 1266 | } |
| 1267 | } | 1267 | } |
| @@ -1473,7 +1473,7 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, | |||
| 1473 | !bn_wexpand(lambda, group_top + 2)) | 1473 | !bn_wexpand(lambda, group_top + 2)) |
| 1474 | goto err; | 1474 | goto err; |
| 1475 | 1475 | ||
| 1476 | if (!BN_copy(k, scalar)) | 1476 | if (!bn_copy(k, scalar)) |
| 1477 | goto err; | 1477 | goto err; |
| 1478 | 1478 | ||
| 1479 | BN_set_flags(k, BN_FLG_CONSTTIME); | 1479 | BN_set_flags(k, BN_FLG_CONSTTIME); |
diff --git a/src/lib/libcrypto/ecdsa/ecs_ossl.c b/src/lib/libcrypto/ecdsa/ecs_ossl.c index 25bcb06e88..e6d6b0cd71 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.30 2023/03/27 10:21:23 tb Exp $ */ | 1 | /* $OpenBSD: ecs_ossl.c,v 1.31 2023/03/27 10:25:02 tb Exp $ */ |
| 2 | /* | 2 | /* |
| 3 | * Written by Nils Larsch for the OpenSSL project | 3 | * Written by Nils Larsch for the OpenSSL project |
| 4 | */ | 4 | */ |
| @@ -200,12 +200,12 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) | |||
| 200 | * code path used in the constant time implementations | 200 | * code path used in the constant time implementations |
| 201 | * elsewhere. | 201 | * elsewhere. |
| 202 | * | 202 | * |
| 203 | * TODO: revisit the BN_copy aiming for a memory access agnostic | 203 | * TODO: revisit the bn_copy aiming for a memory access agnostic |
| 204 | * conditional copy. | 204 | * conditional copy. |
| 205 | */ | 205 | */ |
| 206 | if (!BN_add(r, k, order) || | 206 | if (!BN_add(r, k, order) || |
| 207 | !BN_add(X, r, order) || | 207 | !BN_add(X, r, order) || |
| 208 | !BN_copy(k, BN_num_bits(r) > order_bits ? r : X)) | 208 | !bn_copy(k, BN_num_bits(r) > order_bits ? r : X)) |
| 209 | goto err; | 209 | goto err; |
| 210 | 210 | ||
| 211 | BN_set_flags(k, BN_FLG_CONSTTIME); | 211 | BN_set_flags(k, BN_FLG_CONSTTIME); |
