summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_prime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_prime.c')
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c57
1 files changed, 1 insertions, 56 deletions
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c
index 6e46a3912c..c2fd0fc2e9 100644
--- a/src/lib/libcrypto/bn/bn_prime.c
+++ b/src/lib/libcrypto/bn/bn_prime.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: bn_prime.c,v 1.30 2023/01/28 17:13:26 jsing Exp $ */ 1/* $OpenBSD: bn_prime.c,v 1.31 2023/04/25 19:57:59 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 *
@@ -151,35 +151,6 @@ BN_GENCB_call(BN_GENCB *cb, int a, int b)
151 return 0; 151 return 0;
152} 152}
153 153
154#ifndef OPENSSL_NO_DEPRECATED
155BIGNUM *
156BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
157 const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg)
158{
159 BN_GENCB cb;
160 BIGNUM *rnd = NULL;
161 int found = 0;
162
163 BN_GENCB_set_old(&cb, callback, cb_arg);
164
165 if (ret == NULL) {
166 if ((rnd = BN_new()) == NULL)
167 goto err;
168 } else
169 rnd = ret;
170 if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
171 goto err;
172
173 /* we have a prime :-) */
174 found = 1;
175
176err:
177 if (!found && (ret == NULL) && (rnd != NULL))
178 BN_free(rnd);
179 return (found ? rnd : NULL);
180}
181#endif
182
183int 154int
184BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, 155BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
185 const BIGNUM *rem, BN_GENCB *cb) 156 const BIGNUM *rem, BN_GENCB *cb)
@@ -260,38 +231,12 @@ BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
260 return found; 231 return found;
261} 232}
262 233
263#ifndef OPENSSL_NO_DEPRECATED
264int
265BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *),
266 BN_CTX *ctx_passed, void *cb_arg)
267{
268 BN_GENCB cb;
269
270 BN_GENCB_set_old(&cb, callback, cb_arg);
271 return BN_is_prime_ex(a, checks, ctx_passed, &cb);
272}
273#endif
274
275int 234int
276BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) 235BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb)
277{ 236{
278 return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); 237 return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb);
279} 238}
280 239
281#ifndef OPENSSL_NO_DEPRECATED
282int
283BN_is_prime_fasttest(const BIGNUM *a, int checks,
284 void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg,
285 int do_trial_division)
286{
287 BN_GENCB cb;
288
289 BN_GENCB_set_old(&cb, callback, cb_arg);
290 return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
291 do_trial_division, &cb);
292}
293#endif
294
295int 240int
296BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, 241BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed,
297 int do_trial_division, BN_GENCB *cb) 242 int do_trial_division, BN_GENCB *cb)