summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2023-08-09 09:09:24 +0000
committertb <>2023-08-09 09:09:24 +0000
commit95e0708389805cb1b16c1ce58b7f070258d316cd (patch)
tree41a815a3c376b191177486d9fb4d5299c7ef7093 /src
parentb747bfb735f278053b97b609afd7fa3b35ee1582 (diff)
downloadopenbsd-95e0708389805cb1b16c1ce58b7f070258d316cd.tar.gz
openbsd-95e0708389805cb1b16c1ce58b7f070258d316cd.tar.bz2
openbsd-95e0708389805cb1b16c1ce58b7f070258d316cd.zip
Merge BN_BLINDING_create_param() into BN_BLINDING_new()
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c36
-rw-r--r--src/lib/libcrypto/bn/bn_local.h9
-rw-r--r--src/lib/libcrypto/rsa/rsa_crpt.c4
3 files changed, 16 insertions, 33 deletions
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c
index 996b1d6965..e126865754 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.41 2023/08/09 08:39:46 tb Exp $ */ 1/* $OpenBSD: bn_blind.c,v 1.42 2023/08/09 09:09:24 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 *
@@ -131,8 +131,10 @@ struct bn_blinding_st {
131 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx); 131 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
132}; 132};
133 133
134static BN_BLINDING * 134BN_BLINDING *
135BN_BLINDING_new(const BIGNUM *e, const BIGNUM *mod) 135BN_BLINDING_new(const BIGNUM *e, BIGNUM *mod, BN_CTX *ctx,
136 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
137 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx)
136{ 138{
137 BN_BLINDING *ret = NULL; 139 BN_BLINDING *ret = NULL;
138 140
@@ -155,6 +157,11 @@ BN_BLINDING_new(const BIGNUM *e, const BIGNUM *mod)
155 ret->counter = BN_BLINDING_COUNTER - 1; 157 ret->counter = BN_BLINDING_COUNTER - 1;
156 CRYPTO_THREADID_current(&ret->tid); 158 CRYPTO_THREADID_current(&ret->tid);
157 159
160 if (bn_mod_exp != NULL)
161 ret->bn_mod_exp = bn_mod_exp;
162 if (m_ctx != NULL)
163 ret->m_ctx = m_ctx;
164
158 return ret; 165 return ret;
159 166
160 err: 167 err:
@@ -250,26 +257,3 @@ BN_BLINDING_thread_id(BN_BLINDING *b)
250{ 257{
251 return &b->tid; 258 return &b->tid;
252} 259}
253
254BN_BLINDING *
255BN_BLINDING_create_param(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
256 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
257 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx)
258{
259 BN_BLINDING *ret = NULL;
260
261 if ((ret = BN_BLINDING_new(e, m)) == NULL)
262 goto err;
263
264 if (bn_mod_exp != NULL)
265 ret->bn_mod_exp = bn_mod_exp;
266 if (m_ctx != NULL)
267 ret->m_ctx = m_ctx;
268
269 return ret;
270
271 err:
272 BN_BLINDING_free(ret);
273
274 return NULL;
275}
diff --git a/src/lib/libcrypto/bn/bn_local.h b/src/lib/libcrypto/bn/bn_local.h
index be9f67adea..66df40ada0 100644
--- a/src/lib/libcrypto/bn/bn_local.h
+++ b/src/lib/libcrypto/bn/bn_local.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_local.h,v 1.35 2023/08/09 08:27:02 tb Exp $ */ 1/* $OpenBSD: bn_local.h,v 1.36 2023/08/09 09:09:24 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -292,14 +292,13 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
292int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m, 292int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
293 BN_RECP_CTX *recp, BN_CTX *ctx); 293 BN_RECP_CTX *recp, BN_CTX *ctx);
294 294
295BN_BLINDING *BN_BLINDING_new(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
296 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
297 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx);
295void BN_BLINDING_free(BN_BLINDING *b); 298void BN_BLINDING_free(BN_BLINDING *b);
296int BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); 299int BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
297int BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); 300int BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
298
299CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); 301CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
300BN_BLINDING *BN_BLINDING_create_param(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
301 int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
302 const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx);
303 302
304/* Explicitly const time / non-const time versions for internal use */ 303/* Explicitly const time / non-const time versions for internal use */
305int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, 304int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
diff --git a/src/lib/libcrypto/rsa/rsa_crpt.c b/src/lib/libcrypto/rsa/rsa_crpt.c
index 99086735ea..4739b76240 100644
--- a/src/lib/libcrypto/rsa/rsa_crpt.c
+++ b/src/lib/libcrypto/rsa/rsa_crpt.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: rsa_crpt.c,v 1.25 2023/08/08 15:18:24 tb Exp $ */ 1/* $OpenBSD: rsa_crpt.c,v 1.26 2023/08/09 09:09:24 tb Exp $ */
2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) 2/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3 * All rights reserved. 3 * All rights reserved.
4 * 4 *
@@ -209,7 +209,7 @@ RSA_setup_blinding(RSA *rsa, BN_CTX *in_ctx)
209 BN_init(&n); 209 BN_init(&n);
210 BN_with_flags(&n, rsa->n, BN_FLG_CONSTTIME); 210 BN_with_flags(&n, rsa->n, BN_FLG_CONSTTIME);
211 211
212 if ((ret = BN_BLINDING_create_param(e, &n, ctx, rsa->meth->bn_mod_exp, 212 if ((ret = BN_BLINDING_new(e, &n, ctx, rsa->meth->bn_mod_exp,
213 rsa->_method_mod_n)) == NULL) { 213 rsa->_method_mod_n)) == NULL) {
214 RSAerror(ERR_R_BN_LIB); 214 RSAerror(ERR_R_BN_LIB);
215 goto err; 215 goto err;