-/* $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.
*
#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
-/* $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.
*
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)
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)