From: tb Date: Thu, 30 Mar 2023 14:28:56 +0000 (+0000) Subject: Call bn_copy() unconditionally in BN_mul() and BN_sqr() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3ff1a53503ba45ccd7b5e162aab5d17fe3659e88;p=openbsd 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 --- diff --git a/lib/libcrypto/bn/bn_mul.c b/lib/libcrypto/bn/bn_mul.c index 3a33767a935..fe3f29617fe 100644 --- a/lib/libcrypto/bn/bn_mul.c +++ b/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/lib/libcrypto/bn/bn_sqr.c b/lib/libcrypto/bn/bn_sqr.c index 6641b77592d..d5da7752005 100644 --- a/lib/libcrypto/bn/bn_sqr.c +++ b/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: