diff options
author | Joel Sing <jsing@cvs.openbsd.org> | 2023-01-28 17:09:01 +0000 |
---|---|---|
committer | Joel Sing <jsing@cvs.openbsd.org> | 2023-01-28 17:09:01 +0000 |
commit | 2ae4a5fe31fa8511a07e208e53868f757bd63f56 (patch) | |
tree | 45a93df7f1a6e850b1e52709608716fdc6ec4363 /lib | |
parent | 75cc6d2a57313456f700badd56247620d1d199f8 (diff) |
Move the three functions that are in bn_depr.c back to bn_prime.c.
They should go away, but they have not yet disappeared and this
consolidates the source files.
Discussed with tb@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/bn/bn_depr.c | 53 | ||||
-rw-r--r-- | lib/libcrypto/bn/bn_prime.c | 57 |
2 files changed, 57 insertions, 53 deletions
diff --git a/lib/libcrypto/bn/bn_depr.c b/lib/libcrypto/bn/bn_depr.c index 0e9f6225866..f8b01b7bf6a 100644 --- a/lib/libcrypto/bn/bn_depr.c +++ b/lib/libcrypto/bn/bn_depr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_depr.c,v 1.8 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: bn_depr.c,v 1.9 2023/01/28 17:09:00 jsing Exp $ */ /* ==================================================================== * Copyright (c) 1998-2002 The OpenSSL Project. All rights reserved. * @@ -62,54 +62,3 @@ #include <openssl/opensslconf.h> #include "bn_local.h" - -#ifndef OPENSSL_NO_DEPRECATED -BIGNUM * -BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, - const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) -{ - BN_GENCB cb; - BIGNUM *rnd = NULL; - int found = 0; - - BN_GENCB_set_old(&cb, callback, cb_arg); - - if (ret == NULL) { - if ((rnd = BN_new()) == NULL) - goto err; - } else - rnd = ret; - if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) - goto err; - - /* we have a prime :-) */ - found = 1; - -err: - if (!found && (ret == NULL) && (rnd != NULL)) - BN_free(rnd); - return (found ? rnd : NULL); -} - -int -BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), - BN_CTX *ctx_passed, void *cb_arg) -{ - BN_GENCB cb; - - BN_GENCB_set_old(&cb, callback, cb_arg); - return BN_is_prime_ex(a, checks, ctx_passed, &cb); -} - -int -BN_is_prime_fasttest(const BIGNUM *a, int checks, - void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, - int do_trial_division) -{ - BN_GENCB cb; - - BN_GENCB_set_old(&cb, callback, cb_arg); - return BN_is_prime_fasttest_ex(a, checks, ctx_passed, - do_trial_division, &cb); -} -#endif diff --git a/lib/libcrypto/bn/bn_prime.c b/lib/libcrypto/bn/bn_prime.c index f5e4597f9ba..a4b50eb3fcc 100644 --- a/lib/libcrypto/bn/bn_prime.c +++ b/lib/libcrypto/bn/bn_prime.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bn_prime.c,v 1.28 2022/11/26 16:08:51 tb Exp $ */ +/* $OpenBSD: bn_prime.c,v 1.29 2023/01/28 17:09:00 jsing Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -156,6 +156,35 @@ BN_GENCB_call(BN_GENCB *cb, int a, int b) return 0; } +#ifndef OPENSSL_NO_DEPRECATED +BIGNUM * +BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add, + const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg) +{ + BN_GENCB cb; + BIGNUM *rnd = NULL; + int found = 0; + + BN_GENCB_set_old(&cb, callback, cb_arg); + + if (ret == NULL) { + if ((rnd = BN_new()) == NULL) + goto err; + } else + rnd = ret; + if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) + goto err; + + /* we have a prime :-) */ + found = 1; + +err: + if (!found && (ret == NULL) && (rnd != NULL)) + BN_free(rnd); + return (found ? rnd : NULL); +} +#endif + int BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, const BIGNUM *rem, BN_GENCB *cb) @@ -236,12 +265,38 @@ BN_generate_prime_ex(BIGNUM *ret, int bits, int safe, const BIGNUM *add, return found; } +#ifndef OPENSSL_NO_DEPRECATED +int +BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *), + BN_CTX *ctx_passed, void *cb_arg) +{ + BN_GENCB cb; + + BN_GENCB_set_old(&cb, callback, cb_arg); + return BN_is_prime_ex(a, checks, ctx_passed, &cb); +} +#endif + int BN_is_prime_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, BN_GENCB *cb) { return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 0, cb); } +#ifndef OPENSSL_NO_DEPRECATED +int +BN_is_prime_fasttest(const BIGNUM *a, int checks, + void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg, + int do_trial_division) +{ + BN_GENCB cb; + + BN_GENCB_set_old(&cb, callback, cb_arg); + return BN_is_prime_fasttest_ex(a, checks, ctx_passed, + do_trial_division, &cb); +} +#endif + int BN_is_prime_fasttest_ex(const BIGNUM *a, int checks, BN_CTX *ctx_passed, int do_trial_division, BN_GENCB *cb) |