summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authortb <>2023-04-25 19:57:59 +0000
committertb <>2023-04-25 19:57:59 +0000
commitad0266b1c04352135e70c59a3ab0453a830f097f (patch)
treeb5976467001913ddba531cfe162d423fca5677fb /src/lib
parent82b040aef9cef17610a89204220ee3cb1012fb20 (diff)
downloadopenbsd-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.h35
-rw-r--r--src/lib/libcrypto/bn/bn_blind.c20
-rw-r--r--src/lib/libcrypto/bn/bn_lib.c67
-rw-r--r--src/lib/libcrypto/bn/bn_prime.c57
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
213void BN_set_flags(BIGNUM *b, int n); 204void BN_set_flags(BIGNUM *b, int n);
214int BN_get_flags(const BIGNUM *b, int n); 205int BN_get_flags(const BIGNUM *b, int n);
215void BN_with_flags(BIGNUM *dest, const BIGNUM *src, int flags); 206void 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
444int BN_security_bits(int L, int N); 435int BN_security_bits(int L, int N);
445 436
446/* Deprecated versions */
447#ifndef OPENSSL_NO_DEPRECATED
448BIGNUM *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);
451int BN_is_prime(const BIGNUM *p, int nchecks,
452 void (*callback)(int, int, void *),
453 BN_CTX *ctx, void *cb_arg);
454int 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 */
460int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, 437int 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);
462int BN_is_prime_ex(const BIGNUM *p, int nchecks, BN_CTX *ctx, BN_GENCB *cb); 439int 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);
487int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx); 464int BN_BLINDING_invert(BIGNUM *n, BN_BLINDING *b, BN_CTX *ctx);
488int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *); 465int BN_BLINDING_convert_ex(BIGNUM *n, BIGNUM *r, BN_BLINDING *b, BN_CTX *);
489int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *); 466int BN_BLINDING_invert_ex(BIGNUM *n, const BIGNUM *r, BN_BLINDING *b, BN_CTX *);
490#ifndef OPENSSL_NO_DEPRECATED 467
491unsigned long BN_BLINDING_get_thread_id(const BN_BLINDING *);
492void BN_BLINDING_set_thread_id(BN_BLINDING *, unsigned long);
493#endif
494CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *); 468CRYPTO_THREADID *BN_BLINDING_thread_id(BN_BLINDING *);
495unsigned long BN_BLINDING_get_flags(const BN_BLINDING *); 469unsigned long BN_BLINDING_get_flags(const BN_BLINDING *);
496void BN_BLINDING_set_flags(BN_BLINDING *, unsigned long); 470void 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
504void BN_set_params(int mul, int high, int low, int mont);
505int 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 */
509BIGNUM *get_rfc2409_prime_768(BIGNUM *bn); 478BIGNUM *get_rfc2409_prime_768(BIGNUM *bn);
510BIGNUM *get_rfc2409_prime_1024(BIGNUM *bn); 479BIGNUM *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
283unsigned long
284BN_BLINDING_get_thread_id(const BN_BLINDING *b)
285{
286 return b->thread_id;
287}
288
289void
290BN_BLINDING_set_thread_id(BN_BLINDING *b, unsigned long n)
291{
292 b->thread_id = n;
293}
294#endif
295
296CRYPTO_THREADID * 278CRYPTO_THREADID *
297BN_BLINDING_thread_id(BN_BLINDING *b) 279BN_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 */
134static int bn_limit_bits = 0;
135static int bn_limit_num = 8; /* (1<<bn_limit_bits) */
136static int bn_limit_bits_low = 0;
137static int bn_limit_num_low = 8; /* (1<<bn_limit_bits_low) */
138static int bn_limit_bits_high = 0;
139static int bn_limit_num_high = 8; /* (1<<bn_limit_bits_high) */
140static int bn_limit_bits_mont = 0;
141static int bn_limit_num_mont = 8; /* (1<<bn_limit_bits_mont) */
142
143void
144BN_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
172int
173BN_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
188void 123void
189BN_set_flags(BIGNUM *b, int n) 124BN_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
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)