Skip to content

Commit e7f347a

Browse files
author
tb
committed
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
1 parent fae7c0b commit e7f347a

File tree

1 file changed

+5
-14
lines changed

1 file changed

+5
-14
lines changed

src/lib/libcrypto/bn/bn_blind.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -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 $ */
22
/* ====================================================================
33
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
44
*
@@ -266,21 +266,12 @@ BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
266266
}
267267

268268
int
269-
BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx)
269+
BN_BLINDING_invert(BIGNUM *n, const BIGNUM *inv, BN_BLINDING *b, BN_CTX *ctx)
270270
{
271-
int ret;
272-
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-
}
271+
if (inv == NULL)
272+
inv = b->Ai;
282273

283-
return ret;
274+
return BN_mod_mul(n, n, inv, b->mod, ctx);
284275
}
285276

286277
CRYPTO_THREADID *

0 commit comments

Comments
 (0)