summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-08-09 08:29:23 +0000
committertb <>2023-08-09 08:29:23 +0000
commite7f347a01eda46a45e1cf14918c37eea24b4bd32 (patch)
treec498fa1d2b426668a6cfa8493ee2a7391d46e521
parentfae7c0b0264e481f2cb4d4a46950e0ac8f1a6bab (diff)
downloadopenbsd-e7f347a01eda46a45e1cf14918c37eea24b4bd32.tar.gz
openbsd-e7f347a01eda46a45e1cf14918c37eea24b4bd32.tar.bz2
openbsd-e7f347a01eda46a45e1cf14918c37eea24b4bd32.zip
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
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c19
1 files changed, 5 insertions, 14 deletions
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 @@
1/* $OpenBSD: bn_blind.c,v 1.37 2023/08/08 15:24:02 tb Exp $ */ 1/* $OpenBSD: bn_blind.c,v 1.38 2023/08/09 08:29:23 tb Exp $ */
2/* ==================================================================== 2/* ====================================================================
3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved. 3 * Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
4 * 4 *
@@ -266,21 +266,12 @@ BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
266} 266}
267 267
268int 268int
269BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) 269BN_BLINDING_invert(BIGNUM *n, const BIGNUM *inv, BN_BLINDING *b, BN_CTX *ctx)
270{ 270{
271 int ret; 271 if (inv == NULL)
272 272 inv = b->Ai;
273 if (r != NULL)
274 ret = BN_mod_mul(n, n, r, b->mod, ctx);
275 else {
276 if (b->Ai == NULL) {
277 BNerror(BN_R_NOT_INITIALIZED);
278 return (0);
279 }
280 ret = BN_mod_mul(n, n, b->Ai, b->mod, ctx);
281 }
282 273
283 return ret; 274 return BN_mod_mul(n, n, inv, b->mod, ctx);
284} 275}
285 276
286CRYPTO_THREADID * 277CRYPTO_THREADID *