diff options
author | tb <> | 2023-04-25 19:57:59 +0000 |
---|---|---|
committer | tb <> | 2023-04-25 19:57:59 +0000 |
commit | ad0266b1c04352135e70c59a3ab0453a830f097f (patch) | |
tree | b5976467001913ddba531cfe162d423fca5677fb /src/lib | |
parent | 82b040aef9cef17610a89204220ee3cb1012fb20 (diff) | |
download | openbsd-ad0266b1c04352135e70c59a3ab0453a830f097f.tar.gz openbsd-ad0266b1c04352135e70c59a3ab0453a830f097f.tar.bz2 openbsd-ad0266b1c04352135e70c59a3ab0453a830f097f.zip |
Remove the deprecated API from BN
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/bn/bn.h | 35 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_blind.c | 20 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_lib.c | 67 | ||||
-rw-r--r-- | src/lib/libcrypto/bn/bn_prime.c | 57 |
4 files changed, 5 insertions, 174 deletions
diff --git a/src/lib/libcrypto/bn/bn.h b/src/lib/libcrypto/bn/bn.h index b15e6311f9..c1d28cb10d 100644 --- a/src/lib/libcrypto/bn/bn.h +++ b/src/lib/libcrypto/bn/bn.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn.h,v 1.69 2023/04/25 19:53:30 tb Exp $ */ | 1 | /* $OpenBSD: bn.h,v 1.70 2023/04/25 19:57:59 tb Exp $ */ |
2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -201,15 +201,6 @@ extern "C" { | |||
201 | * BN_mod_inverse() will call BN_mod_inverse_no_branch. | 201 | * BN_mod_inverse() will call BN_mod_inverse_no_branch. |
202 | */ | 202 | */ |
203 | 203 | ||
204 | #ifndef OPENSSL_NO_DEPRECATED | ||
205 | #define BN_FLG_EXP_CONSTTIME BN_FLG_CONSTTIME /* deprecated name for the flag */ | ||
206 | /* avoid leaking exponent information through timings | ||
207 | * (BN_mod_exp_mont() will call BN_mod_exp_mont_consttime) */ | ||
208 | #endif | ||
209 | |||
210 | #ifndef OPENSSL_NO_DEPRECATED | ||
211 | #define BN_FLG_FREE 0x8000 /* used for debugging */ | ||
212 | #endif | ||
213 | void BN_set_flags(BIGNUM *b, int n); | 204 | void BN_set_flags(BIGNUM *b, int n); |
214 | int BN_get_flags(const BIGNUM *b, int n); | 205 | int BN_get_flags(const BIGNUM *b, int n); |
215 | void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); | 206 | void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); |
@@ -443,20 +434,6 @@ void BN_consttime_swap(BN_ULONG swap, BIGNUM *a, BIGNUM *b, int nwords); | |||
443 | 434 | ||
444 | int BN_security_bits(int L, int N); | 435 | int BN_security_bits(int L, int N); |
445 | 436 | ||
446 | /* Deprecated versions */ | ||
447 | #ifndef OPENSSL_NO_DEPRECATED | ||
448 | BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, | ||
449 | const BIGNUM *add, const BIGNUM *rem, | ||
450 | void (*callback)(int, int, void *), void *cb_arg); | ||
451 | int BN_is_prime(const BIGNUM *p, int nchecks, | ||
452 | void (*callback)(int, int, void *), | ||
453 | BN_CTX *ctx, void *cb_arg); | ||
454 | int BN_is_prime_fasttest(const BIGNUM *p, int nchecks, | ||
455 | void (*callback)(int, int, void *), BN_CTX *ctx, void *cb_arg, | ||
456 | int do_trial_division); | ||
457 | #endif /* !defined(OPENSSL_NO_DEPRECATED) */ | ||
458 | |||
459 | /* Newer versions */ | ||
460 | int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | 437 | int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, |
461 | const BIGNUM *rem, BN_GENCB *cb); | 438 | const BIGNUM *rem, BN_GENCB *cb); |
462 | int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); | 439 | int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); |
@@ -487,10 +464,7 @@ int BN_BLINDING_convert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); | |||
487 | int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); | 464 | int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); |
488 | int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); | 465 | int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
489 | int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); | 466 | int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); |
490 | #ifndef OPENSSL_NO_DEPRECATED | 467 | |
491 | unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *); | ||
492 | void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long); | ||
493 | #endif | ||
494 | CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); | 468 | CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); |
495 | unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); | 469 | unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); |
496 | void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); | 470 | void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); |
@@ -500,11 +474,6 @@ BN_BLINDING *BN_BLINDING_create_param(BN_BLINDING *b, | |||
500 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), | 474 | const BIGNUM *m, BN_CTX *ctx, BN_MONT_CTX *m_ctx), |
501 | BN_MONT_CTX *m_ctx); | 475 | BN_MONT_CTX *m_ctx); |
502 | 476 | ||
503 | #ifndef OPENSSL_NO_DEPRECATED | ||
504 | void BN_set_params(int mul, int high, int low, int mont); | ||
505 | int BN_get_params(int which); /* 0, mul, 1 high, 2 low, 3 mont */ | ||
506 | #endif | ||
507 | |||
508 | /* Primes from RFC 2409 */ | 477 | /* Primes from RFC 2409 */ |
509 | BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); | 478 | BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); |
510 | BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); | 479 | BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); |
diff --git a/src/lib/libcrypto/bn/bn_blind.c b/src/lib/libcrypto/bn/bn_blind.c index 9c07f33e1f..77ba691b6d 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.21 2023/03/27 10:25:02 tb Exp $ */ | 1 | /* $OpenBSD: bn_blind.c,v 1.22 2023/04/25 19:57:59 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 | * |
@@ -124,10 +124,6 @@ struct bn_blinding_st { | |||
124 | BIGNUM *Ai; | 124 | BIGNUM *Ai; |
125 | BIGNUM *e; | 125 | BIGNUM *e; |
126 | BIGNUM *mod; /* just a reference */ | 126 | BIGNUM *mod; /* just a reference */ |
127 | #ifndef OPENSSL_NO_DEPRECATED | ||
128 | unsigned long thread_id; /* added in OpenSSL 0.9.6j and 0.9.7b; | ||
129 | * used only by crypto/rsa/rsa_eay.c, rsa_lib.c */ | ||
130 | #endif | ||
131 | CRYPTO_THREADID tid; | 127 | CRYPTO_THREADID tid; |
132 | int counter; | 128 | int counter; |
133 | unsigned long flags; | 129 | unsigned long flags; |
@@ -279,20 +275,6 @@ BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *ctx) | |||
279 | return (ret); | 275 | return (ret); |
280 | } | 276 | } |
281 | 277 | ||
282 | #ifndef OPENSSL_NO_DEPRECATED | ||
283 | unsigned long | ||
284 | BN_BLINDING_get_thread_id(const BN_BLINDING *b) | ||
285 | { | ||
286 | return b->thread_id; | ||
287 | } | ||
288 | |||
289 | void | ||
290 | BN_BLINDING_set_thread_id(BN_BLINDING *b, unsigned long n) | ||
291 | { | ||
292 | b->thread_id = n; | ||
293 | } | ||
294 | #endif | ||
295 | |||
296 | CRYPTO_THREADID * | 278 | CRYPTO_THREADID * |
297 | BN_BLINDING_thread_id(BN_BLINDING *b) | 279 | BN_BLINDING_thread_id(BN_BLINDING *b) |
298 | { | 280 | { |
diff --git a/src/lib/libcrypto/bn/bn_lib.c b/src/lib/libcrypto/bn/bn_lib.c index 78410e2133..439bdb1e9d 100644 --- a/src/lib/libcrypto/bn/bn_lib.c +++ b/src/lib/libcrypto/bn/bn_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bn_lib.c,v 1.84 2023/04/19 11:12:43 jsing Exp $ */ | 1 | /* $OpenBSD: bn_lib.c,v 1.85 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 | * |
@@ -120,71 +120,6 @@ BN_clear_free(BIGNUM *bn) | |||
120 | BN_free(bn); | 120 | BN_free(bn); |
121 | } | 121 | } |
122 | 122 | ||
123 | /* This stuff appears to be completely unused, so is deprecated */ | ||
124 | #ifndef OPENSSL_NO_DEPRECATED | ||
125 | /* For a 32 bit machine | ||
126 | * 2 - 4 == 128 | ||
127 | * 3 - 8 == 256 | ||
128 | * 4 - 16 == 512 | ||
129 | * 5 - 32 == 1024 | ||
130 | * 6 - 64 == 2048 | ||
131 | * 7 - 128 == 4096 | ||
132 | * 8 - 256 == 8192 | ||
133 | */ | ||
134 | static int bn_limit_bits = 0; | ||
135 | static int bn_limit_num = 8; /* (1<<bn_limit_bits) */ | ||
136 | static int bn_limit_bits_low = 0; | ||
137 | static int bn_limit_num_low = 8; /* (1<<bn_limit_bits_low) */ | ||
138 | static int bn_limit_bits_high = 0; | ||
139 | static int bn_limit_num_high = 8; /* (1<<bn_limit_bits_high) */ | ||
140 | static int bn_limit_bits_mont = 0; | ||
141 | static int bn_limit_num_mont = 8; /* (1<<bn_limit_bits_mont) */ | ||
142 | |||
143 | void | ||
144 | BN_set_params(int mult, int high, int low, int mont) | ||
145 | { | ||
146 | if (mult >= 0) { | ||
147 | if (mult > (int)(sizeof(int) * 8) - 1) | ||
148 | mult = sizeof(int) * 8 - 1; | ||
149 | bn_limit_bits = mult; | ||
150 | bn_limit_num = 1 << mult; | ||
151 | } | ||
152 | if (high >= 0) { | ||
153 | if (high > (int)(sizeof(int) * 8) - 1) | ||
154 | high = sizeof(int) * 8 - 1; | ||
155 | bn_limit_bits_high = high; | ||
156 | bn_limit_num_high = 1 << high; | ||
157 | } | ||
158 | if (low >= 0) { | ||
159 | if (low > (int)(sizeof(int) * 8) - 1) | ||
160 | low = sizeof(int) * 8 - 1; | ||
161 | bn_limit_bits_low = low; | ||
162 | bn_limit_num_low = 1 << low; | ||
163 | } | ||
164 | if (mont >= 0) { | ||
165 | if (mont > (int)(sizeof(int) * 8) - 1) | ||
166 | mont = sizeof(int) * 8 - 1; | ||
167 | bn_limit_bits_mont = mont; | ||
168 | bn_limit_num_mont = 1 << mont; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | int | ||
173 | BN_get_params(int which) | ||
174 | { | ||
175 | if (which == 0) | ||
176 | return (bn_limit_bits); | ||
177 | else if (which == 1) | ||
178 | return (bn_limit_bits_high); | ||
179 | else if (which == 2) | ||
180 | return (bn_limit_bits_low); | ||
181 | else if (which == 3) | ||
182 | return (bn_limit_bits_mont); | ||
183 | else | ||
184 | return (0); | ||
185 | } | ||
186 | #endif | ||
187 | |||
188 | void | 123 | void |
189 | BN_set_flags(BIGNUM *b, int n) | 124 | BN_set_flags(BIGNUM *b, int n) |
190 | { | 125 | { |
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 | ||
155 | BIGNUM * | ||
156 | BN_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 | |||
176 | err: | ||
177 | if (!found && (ret == NULL) && (rnd != NULL)) | ||
178 | BN_free(rnd); | ||
179 | return (found ? rnd : NULL); | ||
180 | } | ||
181 | #endif | ||
182 | |||
183 | int | 154 | int |
184 | BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, | 155 | BN_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 | ||
264 | int | ||
265 | BN_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 | |||
275 | int | 234 | int |
276 | BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) | 235 | BN_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 | ||
282 | int | ||
283 | BN_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 | |||
295 | int | 240 | int |
296 | BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, | 241 | BN_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) |