From cef8f41d7627863d5c3ea47a696595d1c41886e6 Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 27 Mar 2023 10:25:02 +0000 Subject: [PATCH] Replace the remaining BN_copy() with bn_copy() ok jsing --- lib/libcrypto/bn/bn_blind.c | 4 +-- lib/libcrypto/bn/bn_exp.c | 6 ++-- lib/libcrypto/bn/bn_gcd.c | 10 +++--- lib/libcrypto/bn/bn_gf2m.c | 18 +++++----- lib/libcrypto/bn/bn_isqrt.c | 4 +-- lib/libcrypto/bn/bn_lib.c | 4 +-- lib/libcrypto/bn/bn_mont.c | 8 ++--- lib/libcrypto/bn/bn_recp.c | 6 ++-- lib/libcrypto/bn/bn_sqrt.c | 10 +++--- lib/libcrypto/bn/bn_x931p.c | 6 ++-- lib/libcrypto/dsa/dsa_gen.c | 4 +-- lib/libcrypto/dsa/dsa_ossl.c | 6 ++-- lib/libcrypto/ec/ec2_mult.c | 6 ++-- lib/libcrypto/ec/ec2_smpl.c | 44 +++++++++++------------ lib/libcrypto/ec/ec_key.c | 4 +-- lib/libcrypto/ec/ec_lib.c | 16 ++++----- lib/libcrypto/ec/ecp_mont.c | 4 +-- lib/libcrypto/ec/ecp_smpl.c | 66 +++++++++++++++++----------------- lib/libcrypto/ecdsa/ecs_ossl.c | 6 ++-- 19 files changed, 116 insertions(+), 116 deletions(-) diff --git a/lib/libcrypto/bn/bn_blind.c b/lib/libcrypto/bn/bn_blind.c index 61d0cf7a951..9c07f33e1f8 100644 --- a/lib/libcrypto/bn/bn_blind.c +++ b/lib/libcrypto/bn/bn_blind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_blind.c,v 1.20 2023/03/07 09:27:10 jsing Exp $ */ +/* $OpenBSD: bn_blind.c,v 1.21 2023/03/27 10:25:02 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -244,7 +244,7 @@ BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) return (0); if (r != NULL) { - if (!BN_copy(r, b->Ai)) + if (!bn_copy(r, b->Ai)) ret = 0; } diff --git a/lib/libcrypto/bn/bn_exp.c b/lib/libcrypto/bn/bn_exp.c index b756d2b3056..4e90d5d8718 100644 --- a/lib/libcrypto/bn/bn_exp.c +++ b/lib/libcrypto/bn/bn_exp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_exp.c,v 1.43 2023/03/27 10:22:47 tb Exp $ */ +/* $OpenBSD: bn_exp.c,v 1.44 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -816,7 +816,7 @@ BN_mod_exp_mont_word(BIGNUM *rr, BN_ULONG a, const BIGNUM *p, const BIGNUM *m, (BN_mod_ct(t, r, m, ctx) && (swap_tmp = r, r = t, t = swap_tmp, 1)))) /* BN_MOD_MUL_WORD is only used with 'w' large, * so the BN_ucmp test is probably more overhead - * than always using BN_mod (which uses BN_copy if + * than always using BN_mod (which uses bn_copy if * a similar test returns true). */ /* We can use BN_mod and do not need BN_nnmod because our * 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, if (m->neg) { /* ignore sign of 'm' */ - if (!BN_copy(aa, m)) + if (!bn_copy(aa, m)) goto err; aa->neg = 0; if (BN_RECP_CTX_set(&recp, aa, ctx) <= 0) diff --git a/lib/libcrypto/bn/bn_gcd.c b/lib/libcrypto/bn/bn_gcd.c index 138befc8680..4a79f26c6f0 100644 --- a/lib/libcrypto/bn/bn_gcd.c +++ b/lib/libcrypto/bn/bn_gcd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_gcd.c,v 1.22 2023/03/27 10:21:23 tb Exp $ */ +/* $OpenBSD: bn_gcd.c,v 1.23 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -314,7 +314,7 @@ BN_gcd_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, * A == gcd(a,n); */ - if (!BN_copy(R, A)) + if (!bn_copy(R, A)) goto err; ret = R; err: @@ -524,7 +524,7 @@ BN_mod_inverse_no_branch(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, if (BN_is_one(A)) { /* Y*a == 1 (mod |n|) */ if (!Y->neg && BN_ucmp(Y, n) < 0) { - if (!BN_copy(R, Y)) + if (!bn_copy(R, Y)) goto err; } else { 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 if (!BN_lshift(tmp, X, 2)) goto err; } else if (D->top == 1) { - if (!BN_copy(tmp, X)) + if (!bn_copy(tmp, X)) goto err; if (!BN_mul_word(tmp, D->d[0])) goto err; @@ -815,7 +815,7 @@ BN_mod_inverse_internal(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ct if (BN_is_one(A)) { /* Y*a == 1 (mod |n|) */ if (!Y->neg && BN_ucmp(Y, n) < 0) { - if (!BN_copy(R, Y)) + if (!bn_copy(R, Y)) goto err; } else { if (!BN_nnmod(R, Y,n, ctx)) diff --git a/lib/libcrypto/bn/bn_gf2m.c b/lib/libcrypto/bn/bn_gf2m.c index 3a0accb4a23..62ac2a5151f 100644 --- a/lib/libcrypto/bn/bn_gf2m.c +++ b/lib/libcrypto/bn/bn_gf2m.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_gf2m.c,v 1.31 2023/03/27 10:20:27 tb Exp $ */ +/* $OpenBSD: bn_gf2m.c,v 1.32 2023/03/27 10:25:02 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -643,7 +643,7 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) if (BN_is_zero(u)) goto err; - if (!BN_copy(v, p)) + if (!bn_copy(v, p)) goto err; #if 0 if (!BN_one(b)) @@ -773,7 +773,7 @@ BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) } #endif - if (!BN_copy(r, b)) + if (!bn_copy(r, b)) goto err; ret = 1; @@ -865,7 +865,7 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, goto err; if (!BN_GF2m_mod(a, x, p)) goto err; - if (!BN_copy(b, p)) + if (!bn_copy(b, p)) goto err; while (!BN_is_odd(a)) { @@ -912,7 +912,7 @@ BN_GF2m_mod_div(BIGNUM *r, const BIGNUM *y, const BIGNUM *x, const BIGNUM *p, } } while (1); - if (!BN_copy(r, u)) + if (!bn_copy(r, u)) goto err; ret = 1; @@ -985,7 +985,7 @@ BN_GF2m_mod_exp_arr(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, const int p[], goto err; } } - if (!BN_copy(r, u)) + if (!bn_copy(r, u)) goto err; ret = 1; @@ -1117,7 +1117,7 @@ BN_GF2m_mod_solve_quad_arr(BIGNUM *r, const BIGNUM *a_, const int p[], if (p[0] & 0x1) /* m is odd */ { /* compute half-trace of a */ - if (!BN_copy(z, a)) + if (!bn_copy(z, a)) goto err; for (j = 1; j <= (p[0] - 1) / 2; j++) { 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[], if (!BN_GF2m_mod_arr(rho, rho, p)) goto err; BN_zero(z); - if (!BN_copy(w, rho)) + if (!bn_copy(w, rho)) goto err; for (j = 1; j <= p[0] - 1; j++) { 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[], goto err; } - if (!BN_copy(r, z)) + if (!bn_copy(r, z)) goto err; ret = 1; diff --git a/lib/libcrypto/bn/bn_isqrt.c b/lib/libcrypto/bn/bn_isqrt.c index ec77e1b078e..4a757b02ceb 100644 --- a/lib/libcrypto/bn/bn_isqrt.c +++ b/lib/libcrypto/bn/bn_isqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_isqrt.c,v 1.6 2022/12/17 15:56:25 jsing Exp $ */ +/* $OpenBSD: bn_isqrt.c,v 1.7 2023/03/27 10:25:02 tb Exp $ */ /* * Copyright (c) 2022 Theo Buehler * @@ -141,7 +141,7 @@ bn_isqrt(BIGNUM *out_sqrt, int *out_perfect, const BIGNUM *n, BN_CTX *in_ctx) *out_perfect = perfect; if (out_sqrt != NULL) { - if (!BN_copy(out_sqrt, a)) + if (!bn_copy(out_sqrt, a)) goto err; } diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index 9da03e2c6e6..49cc6662db3 100644 --- a/lib/libcrypto/bn/bn_lib.c +++ b/lib/libcrypto/bn/bn_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_lib.c,v 1.77 2023/03/27 08:37:33 tb Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.78 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -333,7 +333,7 @@ BN_dup(const BIGNUM *a) t = BN_new(); if (t == NULL) return NULL; - if (!BN_copy(t, a)) { + if (!bn_copy(t, a)) { BN_free(t); return NULL; } diff --git a/lib/libcrypto/bn/bn_mont.c b/lib/libcrypto/bn/bn_mont.c index b7b2384cffd..4b904c876ae 100644 --- a/lib/libcrypto/bn/bn_mont.c +++ b/lib/libcrypto/bn/bn_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mont.c,v 1.54 2023/03/27 10:21:23 tb Exp $ */ +/* $OpenBSD: bn_mont.c,v 1.55 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -166,9 +166,9 @@ BN_MONT_CTX_copy(BN_MONT_CTX *dst, BN_MONT_CTX *src) if (dst == src) return dst; - if (!BN_copy(&dst->RR, &src->RR)) + if (!bn_copy(&dst->RR, &src->RR)) return NULL; - if (!BN_copy(&dst->N, &src->N)) + if (!bn_copy(&dst->N, &src->N)) return NULL; dst->ri = src->ri; @@ -198,7 +198,7 @@ BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx) /* Save modulus and determine length of R. */ if (BN_is_zero(mod)) goto err; - if (!BN_copy(&mont->N, mod)) + if (!bn_copy(&mont->N, mod)) goto err; mont->N.neg = 0; mont->ri = ((BN_num_bits(mod) + BN_BITS2 - 1) / BN_BITS2) * BN_BITS2; diff --git a/lib/libcrypto/bn/bn_recp.c b/lib/libcrypto/bn/bn_recp.c index 117f8933bbf..35390e30d44 100644 --- a/lib/libcrypto/bn/bn_recp.c +++ b/lib/libcrypto/bn/bn_recp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_recp.c,v 1.18 2023/02/13 04:25:37 jsing Exp $ */ +/* $OpenBSD: bn_recp.c,v 1.19 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -99,7 +99,7 @@ BN_RECP_CTX_free(BN_RECP_CTX *recp) int BN_RECP_CTX_set(BN_RECP_CTX *recp, const BIGNUM *d, BN_CTX *ctx) { - if (!BN_copy(&(recp->N), d)) + if (!bn_copy(&(recp->N), d)) return 0; BN_zero(&(recp->Nr)); 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, if (BN_ucmp(m, &(recp->N)) < 0) { BN_zero(d); - if (!BN_copy(r, m)) { + if (!bn_copy(r, m)) { BN_CTX_end(ctx); return 0; } diff --git a/lib/libcrypto/bn/bn_sqrt.c b/lib/libcrypto/bn/bn_sqrt.c index 9bbca4267a4..3d9f017f598 100644 --- a/lib/libcrypto/bn/bn_sqrt.c +++ b/lib/libcrypto/bn/bn_sqrt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqrt.c,v 1.15 2023/03/07 09:27:10 jsing Exp $ */ +/* $OpenBSD: bn_sqrt.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ /* Written by Lenka Fibikova * and Bodo Moeller for the OpenSSL project. */ /* ==================================================================== @@ -209,7 +209,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) if (!BN_mod_mul(x, x, t, p, ctx)) goto end; - if (!BN_copy(ret, x)) + if (!bn_copy(ret, x)) goto end; err = 0; goto vrfy; @@ -217,7 +217,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) /* e > 2, so we really have to use the Tonelli/Shanks algorithm. * First, find some y that is not a square. */ - if (!BN_copy(q, p)) /* use 'q' as temp */ + if (!bn_copy(q, p)) /* use 'q' as temp */ goto end; q->neg = 0; i = 2; @@ -344,7 +344,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) */ if (BN_is_one(b)) { - if (!BN_copy(ret, x)) + if (!bn_copy(ret, x)) goto end; err = 0; goto vrfy; @@ -368,7 +368,7 @@ BN_mod_sqrt(BIGNUM *in, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx) } /* t := y^2^(e - i - 1) */ - if (!BN_copy(t, y)) + if (!bn_copy(t, y)) goto end; for (j = e - i - 1; j > 0; j--) { if (!BN_mod_sqr(t, t, p, ctx)) diff --git a/lib/libcrypto/bn/bn_x931p.c b/lib/libcrypto/bn/bn_x931p.c index e73c416e3ff..9105be11cdf 100644 --- a/lib/libcrypto/bn/bn_x931p.c +++ b/lib/libcrypto/bn/bn_x931p.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_x931p.c,v 1.15 2022/12/26 07:18:51 jmc Exp $ */ +/* $OpenBSD: bn_x931p.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL * project 2005. */ @@ -73,7 +73,7 @@ bn_x931_derive_pi(BIGNUM *pi, const BIGNUM *Xpi, BN_CTX *ctx, BN_GENCB *cb) { int i = 0, is_prime; - if (!BN_copy(pi, Xpi)) + if (!bn_copy(pi, Xpi)) return 0; if (!BN_is_odd(pi) && !BN_add_word(pi, 1)) return 0; @@ -170,7 +170,7 @@ BN_X931_derive_prime_ex(BIGNUM *p, BIGNUM *p1, BIGNUM *p2, const BIGNUM *Xp, for (;;) { int i = 1; BN_GENCB_call(cb, 0, i++); - if (!BN_copy(pm1, p)) + if (!bn_copy(pm1, p)) goto err; if (!BN_sub_word(pm1, 1)) goto err; diff --git a/lib/libcrypto/dsa/dsa_gen.c b/lib/libcrypto/dsa/dsa_gen.c index 1f918941002..49b45614946 100644 --- a/lib/libcrypto/dsa/dsa_gen.c +++ b/lib/libcrypto/dsa/dsa_gen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_gen.c,v 1.27 2023/01/11 04:39:42 jsing Exp $ */ +/* $OpenBSD: dsa_gen.c,v 1.28 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -264,7 +264,7 @@ dsa_builtin_paramgen(DSA *ret, size_t bits, size_t qbits, const EVP_MD *evpmd, /* more of step 8 */ if (!BN_mask_bits(W, bits - 1)) goto err; - if (!BN_copy(X, W)) + if (!bn_copy(X, W)) goto err; if (!BN_add(X, X, test)) goto err; diff --git a/lib/libcrypto/dsa/dsa_ossl.c b/lib/libcrypto/dsa/dsa_ossl.c index ece1026fc9a..b69cf1a03f3 100644 --- a/lib/libcrypto/dsa/dsa_ossl.c +++ b/lib/libcrypto/dsa/dsa_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dsa_ossl.c,v 1.50 2023/03/04 21:30:23 tb Exp $ */ +/* $OpenBSD: dsa_ossl.c,v 1.51 2023/03/27 10:25:02 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -282,13 +282,13 @@ dsa_sign_setup(DSA *dsa, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) * small timing information leakage. We then choose the sum that is * one bit longer than the modulus. * - * TODO: revisit the BN_copy aiming for a memory access agnostic + * TODO: revisit the bn_copy aiming for a memory access agnostic * conditional copy. */ if (!BN_add(l, k, dsa->q) || !BN_add(m, l, dsa->q) || - !BN_copy(k, BN_num_bits(l) > q_bits ? l : m)) + !bn_copy(k, BN_num_bits(l) > q_bits ? l : m)) goto err; if (dsa->meth->bn_mod_exp != NULL) { diff --git a/lib/libcrypto/ec/ec2_mult.c b/lib/libcrypto/ec/ec2_mult.c index 8b8aaf7122a..d32b7442c40 100644 --- a/lib/libcrypto/ec/ec2_mult.c +++ b/lib/libcrypto/ec/ec2_mult.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_mult.c,v 1.15 2022/11/26 16:08:52 tb Exp $ */ +/* $OpenBSD: ec2_mult.c,v 1.16 2023/03/27 10:25:02 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -137,7 +137,7 @@ gf2m_Madd(const EC_GROUP *group, const BIGNUM *x, BIGNUM *x1, BIGNUM *z1, if ((t2 = BN_CTX_get(ctx)) == NULL) goto err; - if (!BN_copy(t1, x)) + if (!bn_copy(t1, x)) goto err; if (!group->meth->field_mul(group, x1, x1, z2, ctx)) goto err; @@ -183,7 +183,7 @@ gf2m_Mxy(const EC_GROUP *group, const BIGNUM *x, const BIGNUM *y, BIGNUM *x1, return 1; } if (BN_is_zero(z2)) { - if (!BN_copy(x2, x)) + if (!bn_copy(x2, x)) return 0; if (!BN_GF2m_add(z2, x, y)) return 0; diff --git a/lib/libcrypto/ec/ec2_smpl.c b/lib/libcrypto/ec/ec2_smpl.c index 84cba1b83ba..1ad339cbd78 100644 --- a/lib/libcrypto/ec/ec2_smpl.c +++ b/lib/libcrypto/ec/ec2_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec2_smpl.c,v 1.33 2023/03/08 05:45:31 jsing Exp $ */ +/* $OpenBSD: ec2_smpl.c,v 1.34 2023/03/27 10:25:02 tb Exp $ */ /* ==================================================================== * Copyright 2002 Sun Microsystems, Inc. ALL RIGHTS RESERVED. * @@ -115,11 +115,11 @@ ec_GF2m_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) { int i; - if (!BN_copy(&dest->field, &src->field)) + if (!bn_copy(&dest->field, &src->field)) return 0; - if (!BN_copy(&dest->a, &src->a)) + if (!bn_copy(&dest->a, &src->a)) return 0; - if (!BN_copy(&dest->b, &src->b)) + if (!bn_copy(&dest->b, &src->b)) return 0; dest->poly[0] = src->poly[0]; dest->poly[1] = src->poly[1]; @@ -146,7 +146,7 @@ ec_GF2m_simple_group_set_curve(EC_GROUP *group, int ret = 0, i; /* group->field */ - if (!BN_copy(&group->field, p)) + if (!bn_copy(&group->field, p)) goto err; i = BN_GF2m_poly2arr(&group->field, group->poly, 6) - 1; if ((i != 5) && (i != 3)) { @@ -185,15 +185,15 @@ ec_GF2m_simple_group_get_curve(const EC_GROUP *group, int ret = 0; if (p != NULL) { - if (!BN_copy(p, &group->field)) + if (!bn_copy(p, &group->field)) return 0; } if (a != NULL) { - if (!BN_copy(a, &group->a)) + if (!bn_copy(a, &group->a)) goto err; } if (b != NULL) { - if (!BN_copy(b, &group->b)) + if (!bn_copy(b, &group->b)) goto err; } ret = 1; @@ -274,11 +274,11 @@ ec_GF2m_simple_point_finish(EC_POINT *point) static int ec_GF2m_simple_point_copy(EC_POINT *dest, const EC_POINT *src) { - if (!BN_copy(&dest->X, &src->X)) + if (!bn_copy(&dest->X, &src->X)) return 0; - if (!BN_copy(&dest->Y, &src->Y)) + if (!bn_copy(&dest->Y, &src->Y)) return 0; - if (!BN_copy(&dest->Z, &src->Z)) + if (!bn_copy(&dest->Z, &src->Z)) return 0; dest->Z_is_one = src->Z_is_one; @@ -310,13 +310,13 @@ ec_GF2m_simple_point_set_affine_coordinates(const EC_GROUP *group, EC_POINT *poi ECerror(ERR_R_PASSED_NULL_PARAMETER); return 0; } - if (!BN_copy(&point->X, x)) + if (!bn_copy(&point->X, x)) goto err; BN_set_negative(&point->X, 0); - if (!BN_copy(&point->Y, y)) + if (!bn_copy(&point->Y, y)) goto err; BN_set_negative(&point->Y, 0); - if (!BN_copy(&point->Z, BN_value_one())) + if (!bn_copy(&point->Z, BN_value_one())) goto err; BN_set_negative(&point->Z, 0); point->Z_is_one = 1; @@ -345,12 +345,12 @@ ec_GF2m_simple_point_get_affine_coordinates(const EC_GROUP *group, return 0; } if (x != NULL) { - if (!BN_copy(x, &point->X)) + if (!bn_copy(x, &point->X)) goto err; BN_set_negative(x, 0); } if (y != NULL) { - if (!BN_copy(y, &point->Y)) + if (!bn_copy(y, &point->Y)) goto err; BN_set_negative(y, 0); } @@ -406,18 +406,18 @@ ec_GF2m_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, goto err; if (a->Z_is_one) { - if (!BN_copy(x0, &a->X)) + if (!bn_copy(x0, &a->X)) goto err; - if (!BN_copy(y0, &a->Y)) + if (!bn_copy(y0, &a->Y)) goto err; } else { if (!EC_POINT_get_affine_coordinates(group, a, x0, y0, ctx)) goto err; } if (b->Z_is_one) { - if (!BN_copy(x1, &b->X)) + if (!bn_copy(x1, &b->X)) goto err; - if (!BN_copy(y1, &b->Y)) + if (!bn_copy(y1, &b->Y)) goto err; } else { 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) if (!EC_POINT_get_affine_coordinates(group, point, x, y, ctx)) goto err; - if (!BN_copy(&point->X, x)) + if (!bn_copy(&point->X, x)) goto err; - if (!BN_copy(&point->Y, y)) + if (!bn_copy(&point->Y, y)) goto err; if (!BN_one(&point->Z)) goto err; diff --git a/lib/libcrypto/ec/ec_key.c b/lib/libcrypto/ec/ec_key.c index 3799498ab1c..2f9f05cc562 100644 --- a/lib/libcrypto/ec/ec_key.c +++ b/lib/libcrypto/ec/ec_key.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_key.c,v 1.31 2023/03/07 09:27:10 jsing Exp $ */ +/* $OpenBSD: ec_key.c,v 1.32 2023/03/27 10:25:02 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project. */ @@ -172,7 +172,7 @@ EC_KEY_copy(EC_KEY *dest, const EC_KEY *src) if (dest->priv_key == NULL) return NULL; } - if (!BN_copy(dest->priv_key, src->priv_key)) + if (!bn_copy(dest->priv_key, src->priv_key)) return NULL; } /* copy method/extra data */ diff --git a/lib/libcrypto/ec/ec_lib.c b/lib/libcrypto/ec/ec_lib.c index 2d14f9c9c51..38ddd7af9f8 100644 --- a/lib/libcrypto/ec/ec_lib.c +++ b/lib/libcrypto/ec/ec_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ec_lib.c,v 1.51 2023/03/08 06:47:30 jsing Exp $ */ +/* $OpenBSD: ec_lib.c,v 1.52 2023/03/27 10:25:02 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -181,9 +181,9 @@ EC_GROUP_copy(EC_GROUP *dest, const EC_GROUP *src) dest->generator = NULL; } - if (!BN_copy(&dest->order, &src->order)) + if (!bn_copy(&dest->order, &src->order)) return 0; - if (!BN_copy(&dest->cofactor, &src->cofactor)) + if (!bn_copy(&dest->cofactor, &src->cofactor)) return 0; dest->curve_name = src->curve_name; @@ -279,7 +279,7 @@ ec_guess_cofactor(EC_GROUP *group) if (!BN_set_bit(q, BN_num_bits(&group->field) - 1)) goto err; } else { - if (!BN_copy(q, &group->field)) + if (!bn_copy(q, &group->field)) goto err; } @@ -357,12 +357,12 @@ EC_GROUP_set_generator(EC_GROUP *group, const EC_POINT *generator, if (!EC_POINT_copy(group->generator, generator)) return 0; - if (!BN_copy(&group->order, order)) + if (!bn_copy(&group->order, order)) return 0; /* Either take the provided positive cofactor, or try to compute it. */ if (cofactor != NULL && !BN_is_zero(cofactor)) { - if (!BN_copy(&group->cofactor, cofactor)) + if (!bn_copy(&group->cofactor, cofactor)) return 0; } else if (!ec_guess_cofactor(group)) return 0; @@ -387,7 +387,7 @@ EC_GROUP_get0_generator(const EC_GROUP *group) int EC_GROUP_get_order(const EC_GROUP *group, BIGNUM *order, BN_CTX *ctx) { - if (!BN_copy(order, &group->order)) + if (!bn_copy(order, &group->order)) return 0; return !BN_is_zero(order); @@ -402,7 +402,7 @@ EC_GROUP_order_bits(const EC_GROUP *group) int EC_GROUP_get_cofactor(const EC_GROUP *group, BIGNUM *cofactor, BN_CTX *ctx) { - if (!BN_copy(cofactor, &group->cofactor)) + if (!bn_copy(cofactor, &group->cofactor)) return 0; return !BN_is_zero(&group->cofactor); diff --git a/lib/libcrypto/ec/ecp_mont.c b/lib/libcrypto/ec/ecp_mont.c index 8b85bf32fa0..915cf15f720 100644 --- a/lib/libcrypto/ec/ecp_mont.c +++ b/lib/libcrypto/ec/ecp_mont.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_mont.c,v 1.27 2023/03/08 05:45:31 jsing Exp $ */ +/* $OpenBSD: ecp_mont.c,v 1.28 2023/03/27 10:25:02 tb Exp $ */ /* * Originally written by Bodo Moeller for the OpenSSL project. */ @@ -220,7 +220,7 @@ ec_GFp_mont_field_set_to_one(const EC_GROUP *group, BIGNUM *r, BN_CTX *ctx) ECerror(EC_R_NOT_INITIALIZED); return 0; } - if (!BN_copy(r, group->mont_one)) + if (!bn_copy(r, group->mont_one)) return 0; return 1; } diff --git a/lib/libcrypto/ec/ecp_smpl.c b/lib/libcrypto/ec/ecp_smpl.c index 9af6034601a..90330652e49 100644 --- a/lib/libcrypto/ec/ecp_smpl.c +++ b/lib/libcrypto/ec/ecp_smpl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecp_smpl.c,v 1.42 2023/03/08 05:45:31 jsing Exp $ */ +/* $OpenBSD: ecp_smpl.c,v 1.43 2023/03/27 10:25:02 tb Exp $ */ /* Includes code written by Lenka Fibikova * for the OpenSSL project. * Includes code written by Bodo Moeller for the OpenSSL project. @@ -102,11 +102,11 @@ ec_GFp_simple_group_finish(EC_GROUP *group) int ec_GFp_simple_group_copy(EC_GROUP *dest, const EC_GROUP *src) { - if (!BN_copy(&dest->field, &src->field)) + if (!bn_copy(&dest->field, &src->field)) return 0; - if (!BN_copy(&dest->a, &src->a)) + if (!bn_copy(&dest->a, &src->a)) return 0; - if (!BN_copy(&dest->b, &src->b)) + if (!bn_copy(&dest->b, &src->b)) return 0; dest->a_is_minus3 = src->a_is_minus3; @@ -137,7 +137,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group, goto err; /* group->field */ - if (!BN_copy(&group->field, p)) + if (!bn_copy(&group->field, p)) goto err; BN_set_negative(&group->field, 0); @@ -147,7 +147,7 @@ ec_GFp_simple_group_set_curve(EC_GROUP *group, if (group->meth->field_encode) { if (!group->meth->field_encode(group, &group->a, tmp_a, ctx)) goto err; - } else if (!BN_copy(&group->a, tmp_a)) + } else if (!bn_copy(&group->a, tmp_a)) goto err; /* group->b */ @@ -177,7 +177,7 @@ ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNU BN_CTX *new_ctx = NULL; if (p != NULL) { - if (!BN_copy(p, &group->field)) + if (!bn_copy(p, &group->field)) return 0; } if (a != NULL || b != NULL) { @@ -197,11 +197,11 @@ ec_GFp_simple_group_get_curve(const EC_GROUP *group, BIGNUM *p, BIGNUM *a, BIGNU } } else { if (a != NULL) { - if (!BN_copy(a, &group->a)) + if (!bn_copy(a, &group->a)) goto err; } if (b != NULL) { - if (!BN_copy(b, &group->b)) + if (!bn_copy(b, &group->b)) goto err; } } @@ -252,9 +252,9 @@ ec_GFp_simple_group_check_discriminant(const EC_GROUP *group, BN_CTX *ctx) if (!group->meth->field_decode(group, b, &group->b, ctx)) goto err; } else { - if (!BN_copy(a, &group->a)) + if (!bn_copy(a, &group->a)) goto err; - if (!BN_copy(b, &group->b)) + if (!bn_copy(b, &group->b)) goto err; } @@ -317,11 +317,11 @@ ec_GFp_simple_point_finish(EC_POINT *point) int ec_GFp_simple_point_copy(EC_POINT *dest, const EC_POINT *src) { - if (!BN_copy(&dest->X, &src->X)) + if (!bn_copy(&dest->X, &src->X)) return 0; - if (!BN_copy(&dest->Y, &src->Y)) + if (!bn_copy(&dest->Y, &src->Y)) return 0; - if (!BN_copy(&dest->Z, &src->Z)) + if (!bn_copy(&dest->Z, &src->Z)) return 0; dest->Z_is_one = src->Z_is_one; @@ -416,15 +416,15 @@ ec_GFp_simple_get_Jprojective_coordinates(const EC_GROUP *group, } } else { if (x != NULL) { - if (!BN_copy(x, &point->X)) + if (!bn_copy(x, &point->X)) goto err; } if (y != NULL) { - if (!BN_copy(y, &point->Y)) + if (!bn_copy(y, &point->Y)) goto err; } if (z != NULL) { - if (!BN_copy(z, &point->Z)) + if (!bn_copy(z, &point->Z)) goto err; } } @@ -499,11 +499,11 @@ ec_GFp_simple_point_get_affine_coordinates(const EC_GROUP *group, const EC_POINT } } else { if (x != NULL) { - if (!BN_copy(x, &point->X)) + if (!bn_copy(x, &point->X)) goto err; } if (y != NULL) { - if (!BN_copy(y, &point->Y)) + if (!bn_copy(y, &point->Y)) goto err; } } @@ -606,9 +606,9 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E /* n1, n2 */ if (b->Z_is_one) { - if (!BN_copy(n1, &a->X)) + if (!bn_copy(n1, &a->X)) goto end; - if (!BN_copy(n2, &a->Y)) + if (!bn_copy(n2, &a->Y)) goto end; /* n1 = X_a */ /* n2 = Y_a */ @@ -628,9 +628,9 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E /* n3, n4 */ if (a->Z_is_one) { - if (!BN_copy(n3, &b->X)) + if (!bn_copy(n3, &b->X)) goto end; - if (!BN_copy(n4, &b->Y)) + if (!bn_copy(n4, &b->Y)) goto end; /* n3 = X_b */ /* n4 = Y_b */ @@ -681,14 +681,14 @@ ec_GFp_simple_add(const EC_GROUP *group, EC_POINT *r, const EC_POINT *a, const E /* Z_r */ if (a->Z_is_one && b->Z_is_one) { - if (!BN_copy(&r->Z, n5)) + if (!bn_copy(&r->Z, n5)) goto end; } else { if (a->Z_is_one) { - if (!BN_copy(n0, &b->Z)) + if (!bn_copy(n0, &b->Z)) goto end; } else if (b->Z_is_one) { - if (!BN_copy(n0, &a->Z)) + if (!bn_copy(n0, &a->Z)) goto end; } else { 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 /* Z_r */ if (a->Z_is_one) { - if (!BN_copy(n0, &a->Y)) + if (!bn_copy(n0, &a->Y)) goto err; } else { 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 if (heap[2 * i] != NULL) { if ((heap[2 * i + 1] == NULL) || BN_is_zero(heap[2 * i + 1])) { - if (!BN_copy(heap[i], heap[2 * i])) + if (!bn_copy(heap[i], heap[2 * i])) goto err; } else { if (BN_is_zero(heap[2 * i])) { - if (!BN_copy(heap[i], heap[2 * i + 1])) + if (!bn_copy(heap[i], heap[2 * i + 1])) goto err; } else { 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 goto err; if (!group->meth->field_mul(group, tmp1, heap[i / 2], heap[i], ctx)) goto err; - if (!BN_copy(heap[i], tmp0)) + if (!bn_copy(heap[i], tmp0)) goto err; - if (!BN_copy(heap[i + 1], tmp1)) + if (!bn_copy(heap[i + 1], tmp1)) goto err; } else { - if (!BN_copy(heap[i], heap[i / 2])) + if (!bn_copy(heap[i], heap[i / 2])) goto err; } } @@ -1473,7 +1473,7 @@ ec_GFp_simple_mul_ct(const EC_GROUP *group, EC_POINT *r, const BIGNUM *scalar, !bn_wexpand(lambda, group_top + 2)) goto err; - if (!BN_copy(k, scalar)) + if (!bn_copy(k, scalar)) goto err; BN_set_flags(k, BN_FLG_CONSTTIME); diff --git a/lib/libcrypto/ecdsa/ecs_ossl.c b/lib/libcrypto/ecdsa/ecs_ossl.c index 25bcb06e887..e6d6b0cd718 100644 --- a/lib/libcrypto/ecdsa/ecs_ossl.c +++ b/lib/libcrypto/ecdsa/ecs_ossl.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ecs_ossl.c,v 1.30 2023/03/27 10:21:23 tb Exp $ */ +/* $OpenBSD: ecs_ossl.c,v 1.31 2023/03/27 10:25:02 tb Exp $ */ /* * Written by Nils Larsch for the OpenSSL project */ @@ -200,12 +200,12 @@ ecdsa_sign_setup(EC_KEY *eckey, BN_CTX *ctx_in, BIGNUM **kinvp, BIGNUM **rp) * code path used in the constant time implementations * elsewhere. * - * TODO: revisit the BN_copy aiming for a memory access agnostic + * TODO: revisit the bn_copy aiming for a memory access agnostic * conditional copy. */ if (!BN_add(r, k, order) || !BN_add(X, r, order) || - !BN_copy(k, BN_num_bits(r) > order_bits ? r : X)) + !bn_copy(k, BN_num_bits(r) > order_bits ? r : X)) goto err; BN_set_flags(k, BN_FLG_CONSTTIME); -- 2.20.1