diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/libcrypto/bn/bn_depr.c | 53 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_prime.c | 57 |
2 files changed, 57 insertions, 53 deletions
diff --git a/src/lib/libcrypto/bn/bn_depr.c b/src/lib/libcrypto/bn/bn_depr.c index 0e9f622586..f8b01b7bf6 100644 --- a/src/lib/libcrypto/bn/bn_depr.c +++ b/src/lib/libcrypto/bn/bn_depr.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_depr.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ | 1 | /* $OpenBSD: bn_depr.c,v 1.9 2023/01/28 17:09:00 jsing Exp $ */ |
2 | /* ==================================================================== | 2 | /* ==================================================================== |
3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. | 3 | * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. |
4 | * | 4 | * |
@@ -62,54 +62,3 @@ | |||
62 | #include <openssl/opensslconf.h> | 62 | #include <openssl/opensslconf.h> |
63 | 63 | ||
64 | #include "bn_local.h" | 64 | #include "bn_local.h" |
65 | |||
66 | #ifndef OPENSSL_NO_DEPRECATED | ||
67 | BIGNUM * | ||
68 | BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | ||
69 | const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) | ||
70 | { | ||
71 | BN_GENCB cb; | ||
72 | BIGNUM *rnd = NULL; | ||
73 | int found = 0; | ||
74 | |||
75 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
76 | |||
77 | if (ret == NULL) { | ||
78 | if ((rnd = BN_new()) == NULL) | ||
79 | goto err; | ||
80 | } else | ||
81 | rnd = ret; | ||
82 | if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) | ||
83 | goto err; | ||
84 | |||
85 | /* we have a prime :-) */ | ||
86 | found = 1; | ||
87 | |||
88 | err: | ||
89 | if (!found && (ret == NULL) && (rnd != NULL)) | ||
90 | BN_free(rnd); | ||
91 | return (found ? rnd : NULL); | ||
92 | } | ||
93 | |||
94 | int | ||
95 | BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), | ||
96 | BN_CTX *ctx_passed, void *cb_arg) | ||
97 | { | ||
98 | BN_GENCB cb; | ||
99 | |||
100 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
101 | return BN_is_prime_ex(a, checks, ctx_passed, &cb); | ||
102 | } | ||
103 | |||
104 | int | ||
105 | BN_is_prime_fasttest(const BIGNUM *a, int checks, | ||
106 | void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, | ||
107 | int do_trial_division) | ||
108 | { | ||
109 | BN_GENCB cb; | ||
110 | |||
111 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
112 | return BN_is_prime_fasttest_ex(a, checks, ctx_passed, | ||
113 | do_trial_division, &cb); | ||
114 | } | ||
115 | #endif | ||
diff --git a/src/lib/libcrypto/bn/bn_prime.c b/src/lib/libcrypto/bn/bn_prime.c index f5e4597f9b..a4b50eb3fc 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.28 2022/11/26 16:08:51 tb Exp $ */ | 1 | /* $OpenBSD: bn_prime.c,v 1.29 2023/01/28 17:09:00 jsing 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 | * |
@@ -156,6 +156,35 @@ BN_GENCB_call(BN_GENCB *cb, int a, int b) | |||
156 | return 0; | 156 | return 0; |
157 | } | 157 | } |
158 | 158 | ||
159 | #ifndef OPENSSL_NO_DEPRECATED | ||
160 | BIGNUM * | ||
161 | BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | ||
162 | const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) | ||
163 | { | ||
164 | BN_GENCB cb; | ||
165 | BIGNUM *rnd = NULL; | ||
166 | int found = 0; | ||
167 | |||
168 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
169 | |||
170 | if (ret == NULL) { | ||
171 | if ((rnd = BN_new()) == NULL) | ||
172 | goto err; | ||
173 | } else | ||
174 | rnd = ret; | ||
175 | if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) | ||
176 | goto err; | ||
177 | |||
178 | /* we have a prime :-) */ | ||
179 | found = 1; | ||
180 | |||
181 | err: | ||
182 | if (!found && (ret == NULL) && (rnd != NULL)) | ||
183 | BN_free(rnd); | ||
184 | return (found ? rnd : NULL); | ||
185 | } | ||
186 | #endif | ||
187 | |||
159 | int | 188 | int |
160 | BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | 189 | BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, |
161 | const BIGNUM *rem, BN_GENCB *cb) | 190 | const BIGNUM *rem, BN_GENCB *cb) |
@@ -236,12 +265,38 @@ BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | |||
236 | return found; | 265 | return found; |
237 | } | 266 | } |
238 | 267 | ||
268 | #ifndef OPENSSL_NO_DEPRECATED | ||
269 | int | ||
270 | BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), | ||
271 | BN_CTX *ctx_passed, void *cb_arg) | ||
272 | { | ||
273 | BN_GENCB cb; | ||
274 | |||
275 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
276 | return BN_is_prime_ex(a, checks, ctx_passed, &cb); | ||
277 | } | ||
278 | #endif | ||
279 | |||
239 | int | 280 | int |
240 | BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) | 281 | BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) |
241 | { | 282 | { |
242 | return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); | 283 | return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); |
243 | } | 284 | } |
244 | 285 | ||
286 | #ifndef OPENSSL_NO_DEPRECATED | ||
287 | int | ||
288 | BN_is_prime_fasttest(const BIGNUM *a, int checks, | ||
289 | void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, | ||
290 | int do_trial_division) | ||
291 | { | ||
292 | BN_GENCB cb; | ||
293 | |||
294 | BN_GENCB_set_old(&cb, callback, cb_arg); | ||
295 | return BN_is_prime_fasttest_ex(a, checks, ctx_passed, | ||
296 | do_trial_division, &cb); | ||
297 | } | ||
298 | #endif | ||
299 | |||
245 | int | 300 | int |
246 | BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, | 301 | BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, |
247 | int do_trial_division, BN_GENCB *cb) | 302 | int do_trial_division, BN_GENCB *cb) |