summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_mont.c
diff options
context:
space:
mode:
authortb <>2025-02-13 11:04:20 +0000
committertb <>2025-02-13 11:04:20 +0000
commitade8722cf772f75a9dd24ace7878bf2f0730171c (patch)
tree6331480d1d99f90f319b23c696f38c97cf3908da /src/lib/libcrypto/bn/bn_mont.c
parent70b5e4a9ddfad29232b45bb7cfe175cb06edf1a7 (diff)
downloadopenbsd-ade8722cf772f75a9dd24ace7878bf2f0730171c.tar.gz
openbsd-ade8722cf772f75a9dd24ace7878bf2f0730171c.tar.bz2
openbsd-ade8722cf772f75a9dd24ace7878bf2f0730171c.zip
bn: add internal BN_MONT_CTX_create()
This does what the public BN_MONT_CTX_new() should have done in the first place rather than doing the toolkit thing of returning an invalid object that you need to figure out how to populate and with what because the docs are abysmal. It takes the required arguments and calls BN_MONT_CTX_set(), which all callers do immediately after _new() (except for DSA which managed to squeeze 170 lines of garbage between the two calls). ok jsing
Diffstat (limited to 'src/lib/libcrypto/bn/bn_mont.c')
-rw-r--r--src/lib/libcrypto/bn/bn_mont.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/lib/libcrypto/bn/bn_mont.c b/src/lib/libcrypto/bn/bn_mont.c
index c7e2eefb58..cfdc7e510f 100644
--- a/src/lib/libcrypto/bn/bn_mont.c
+++ b/src/lib/libcrypto/bn/bn_mont.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_mont.c,v 1.63 2024/03/26 04:23:04 jsing Exp $ */ 1/* $OpenBSD: bn_mont.c,v 1.64 2025/02/13 11:04:20 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 *
@@ -154,6 +154,24 @@ BN_MONT_CTX_free(BN_MONT_CTX *mctx)
154LCRYPTO_ALIAS(BN_MONT_CTX_free); 154LCRYPTO_ALIAS(BN_MONT_CTX_free);
155 155
156BN_MONT_CTX * 156BN_MONT_CTX *
157BN_MONT_CTX_create(const BIGNUM *bn, BN_CTX *bn_ctx)
158{
159 BN_MONT_CTX *mctx;
160
161 if ((mctx = BN_MONT_CTX_new()) == NULL)
162 goto err;
163 if (!BN_MONT_CTX_set(mctx, bn, bn_ctx))
164 goto err;
165
166 return mctx;
167
168 err:
169 BN_MONT_CTX_free(mctx);
170
171 return NULL;
172}
173
174BN_MONT_CTX *
157BN_MONT_CTX_copy(BN_MONT_CTX *dst, BN_MONT_CTX *src) 175BN_MONT_CTX_copy(BN_MONT_CTX *dst, BN_MONT_CTX *src)
158{ 176{
159 if (dst == src) 177 if (dst == src)