From 6e2e40cd5807b521e72b25814ae9b740253671f6 Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 27 Mar 2023 08:37:33 +0000 Subject: [PATCH] Add bn_copy(), a sane wrapper of BN_copy() for internal use ok jsing --- lib/libcrypto/bn/bn_lib.c | 8 +++++++- lib/libcrypto/bn/bn_local.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/libcrypto/bn/bn_lib.c b/lib/libcrypto/bn/bn_lib.c index 89e2713a0f4..9da03e2c6e6 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.76 2023/02/14 18:22:35 jsing Exp $ */ +/* $OpenBSD: bn_lib.c,v 1.77 2023/03/27 08:37:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -384,6 +384,12 @@ BN_copy(BIGNUM *a, const BIGNUM *b) return (a); } +int +bn_copy(BIGNUM *dst, const BIGNUM *src) +{ + return BN_copy(dst, src) != NULL; +} + void BN_swap(BIGNUM *a, BIGNUM *b) { diff --git a/lib/libcrypto/bn/bn_local.h b/lib/libcrypto/bn/bn_local.h index 4576c36c917..4912ae96f32 100644 --- a/lib/libcrypto/bn/bn_local.h +++ b/lib/libcrypto/bn/bn_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_local.h,v 1.17 2023/02/22 05:57:19 jsing Exp $ */ +/* $OpenBSD: bn_local.h,v 1.18 2023/03/27 08:37:33 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -312,6 +312,8 @@ int BN_gcd_nonct(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx); int BN_swap_ct(BN_ULONG swap, BIGNUM *a, BIGNUM *b, size_t nwords); +int bn_copy(BIGNUM *dst, const BIGNUM *src); + int bn_isqrt(BIGNUM *out_sqrt, int *out_perfect, const BIGNUM *n, BN_CTX *ctx); int bn_is_perfect_square(int *out_perfect, const BIGNUM *n, BN_CTX *ctx); -- 2.20.1