From 3f0e663d41d78ec3603e3d4895fa3700096a3515 Mon Sep 17 00:00:00 2001 From: tb <> Date: Thu, 30 Mar 2023 14:28:56 +0000 Subject: Call bn_copy() unconditionally in BN_mul() and BN_sqr() bn_copy() does the right thing if source and target are the same, so there is no need for an additional check. Requested by jsing --- src/lib/libcrypto/bn/bn_mul.c | 8 +++----- src/lib/libcrypto/bn/bn_sqr.c | 9 +++------ 2 files changed, 6 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/lib/libcrypto/bn/bn_mul.c b/src/lib/libcrypto/bn/bn_mul.c index 3a33767a93..fe3f29617f 100644 --- a/src/lib/libcrypto/bn/bn_mul.c +++ b/src/lib/libcrypto/bn/bn_mul.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_mul.c,v 1.35 2023/03/27 10:22:47 tb Exp $ */ +/* $OpenBSD: bn_mul.c,v 1.36 2023/03/30 14:28:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -786,10 +786,8 @@ BN_mul(BIGNUM *r, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx) BN_set_negative(rr, a->neg ^ b->neg); - if (r != rr) { - if (!bn_copy(r, rr)) - goto err; - } + if (!bn_copy(r, rr)) + goto err; done: ret = 1; err: diff --git a/src/lib/libcrypto/bn/bn_sqr.c b/src/lib/libcrypto/bn/bn_sqr.c index 6641b77592..d5da775200 100644 --- a/src/lib/libcrypto/bn/bn_sqr.c +++ b/src/lib/libcrypto/bn/bn_sqr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_sqr.c,v 1.28 2023/03/27 10:22:47 tb Exp $ */ +/* $OpenBSD: bn_sqr.c,v 1.29 2023/03/30 14:28:56 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -404,11 +404,8 @@ BN_sqr(BIGNUM *r, const BIGNUM *a, BN_CTX *ctx) rr->neg = 0; - if (rr != r) { - if (!bn_copy(r, rr)) - goto err; - } - + if (!bn_copy(r, rr)) + goto err; done: ret = 1; err: -- cgit v1.2.3-55-g6feb