-/* $OpenBSD: bn_blind.c,v 1.41 2023/08/09 08:39:46 tb Exp $ */
+/* $OpenBSD: bn_blind.c,v 1.42 2023/08/09 09:09:24 tb Exp $ */
/* ====================================================================
* Copyright (c) 1998-2006 The OpenSSL Project. All rights reserved.
*
const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx);
};
-static BN_BLINDING *
-BN_BLINDING_new(const BIGNUM *e, const BIGNUM *mod)
+BN_BLINDING *
+BN_BLINDING_new(const BIGNUM *e, BIGNUM *mod, BN_CTX *ctx,
+ int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx)
{
BN_BLINDING *ret = NULL;
ret->counter = BN_BLINDING_COUNTER - 1;
CRYPTO_THREADID_current(&ret->tid);
+ if (bn_mod_exp != NULL)
+ ret->bn_mod_exp = bn_mod_exp;
+ if (m_ctx != NULL)
+ ret->m_ctx = m_ctx;
+
return ret;
err:
{
return &b->tid;
}
-
-BN_BLINDING *
-BN_BLINDING_create_param(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
- int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx)
-{
- BN_BLINDING *ret = NULL;
-
- if ((ret = BN_BLINDING_new(e, m)) == NULL)
- goto err;
-
- if (bn_mod_exp != NULL)
- ret->bn_mod_exp = bn_mod_exp;
- if (m_ctx != NULL)
- ret->m_ctx = m_ctx;
-
- return ret;
-
- err:
- BN_BLINDING_free(ret);
-
- return NULL;
-}
-/* $OpenBSD: bn_local.h,v 1.35 2023/08/09 08:27:02 tb Exp $ */
+/* $OpenBSD: bn_local.h,v 1.36 2023/08/09 09:09:24 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
int BN_div_recp(BIGNUM *dv, BIGNUM *rem, const BIGNUM *m,
BN_RECP_CTX *recp, BN_CTX *ctx);
+BN_BLINDING *BN_BLINDING_new(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
+ int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
+ const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx);
void BN_BLINDING_free(BN_BLINDING *b);
int BN_BLINDING_convert(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
int BN_BLINDING_invert(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
-
CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
-BN_BLINDING *BN_BLINDING_create_param(const BIGNUM *e, BIGNUM *m, BN_CTX *ctx,
- int (*bn_mod_exp)(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
- const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), BN_MONT_CTX *m_ctx);
/* Explicitly const time / non-const time versions for internal use */
int BN_mod_exp_ct(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
-/* $OpenBSD: rsa_crpt.c,v 1.25 2023/08/08 15:18:24 tb Exp $ */
+/* $OpenBSD: rsa_crpt.c,v 1.26 2023/08/09 09:09:24 tb Exp $ */
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
* All rights reserved.
*
BN_init(&n);
BN_with_flags(&n, rsa->n, BN_FLG_CONSTTIME);
- if ((ret = BN_BLINDING_create_param(e, &n, ctx, rsa->meth->bn_mod_exp,
+ if ((ret = BN_BLINDING_new(e, &n, ctx, rsa->meth->bn_mod_exp,
rsa->_method_mod_n)) == NULL) {
RSAerror(ERR_R_BN_LIB);
goto err;