From e7f347a01eda46a45e1cf14918c37eea24b4bd32 Mon Sep 17 00:00:00 2001 From: tb <> Date: Wed, 9 Aug 2023 08:29:23 +0000 Subject: Simplify BN_BLINDING_invert() If the blinding is non-NULL, Ai is set on it, so no need to check for that. Also, we can get away with a single call to BN_mod_mul(). ok jsing --- src/lib/libcrypto/bn/bn_blind.c | 19 +++++-------------- 1 file changed, 5 insertions(+), 14 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c index e9873b009e..e13c36c5f1 100644 --- a/src/lib/libcrypto/bn/bn_blind.c +++ b/src/lib/libcrypto/bn/bn_blind.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_blind.c,v 1.37 2023/08/08 15:24:02 tb Exp $ */ +/* $OpenBSD: bn_blind.c,v 1.38 2023/08/09 08:29:23 tb Exp $ */ /* ==================================================================== * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. * @@ -266,21 +266,12 @@ BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) } int -BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) +BN_BLINDING_invert(BIGNUM *n, const BIGNUM *inv, BN_BLINDING *b, BN_CTX *ctx) { - int ret; - - if (r != NULL) - ret = BN_mod_mul(n, n, r, b->mod, ctx); - else { - if (b->Ai == NULL) { - BNerror(BN_R_NOT_INITIALIZED); - return (0); - } - ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx); - } + if (inv == NULL) + inv = b->Ai; - return ret; + return BN_mod_mul(n, n, inv, b->mod, ctx); } CRYPTO_THREADID * -- cgit v1.2.3-55-g6feb