From: tb Date: Wed, 9 Aug 2023 08:29:23 +0000 (+0000) Subject: Simplify BN_BLINDING_invert() X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=77fb6647e2b212919ace3b60a033ceaf5966ea5a;p=openbsd 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 --- diff --git a/lib/libcrypto/bn/bn_blind.c b/lib/libcrypto/bn/bn_blind.c index e9873b009eb..e13c36c5f15 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.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 *