]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/bn/bn_depr.c
threads_pthread.c: change inline to ossl_inline
[thirdparty/openssl.git] / crypto / bn / bn_depr.c
CommitLineData
4f22f405 1/*
38fc02a7 2 * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
e9224c71 3 *
367ace68 4 * Licensed under the Apache License 2.0 (the "License"). You may not use
4f22f405
RS
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
e9224c71
GT
8 */
9
0f113f3e
MC
10/*
11 * Support for deprecated functions goes here - static linkage will only
12 * slurp this code if applications are using them directly.
13 */
e9224c71 14
98186eb4 15#include <openssl/opensslconf.h>
e9224c71 16
705536e2
RS
17#include <stdio.h>
18#include <time.h>
19#include "internal/cryptlib.h"
20#include "bn_local.h"
9d473aa2 21
e9224c71 22BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
0f113f3e
MC
23 const BIGNUM *add, const BIGNUM *rem,
24 void (*callback) (int, int, void *), void *cb_arg)
25{
26 BN_GENCB cb;
27 BIGNUM *rnd = NULL;
e9224c71 28
0f113f3e 29 BN_GENCB_set_old(&cb, callback, cb_arg);
e9224c71 30
0f113f3e
MC
31 if (ret == NULL) {
32 if ((rnd = BN_new()) == NULL)
33 goto err;
34 } else
35 rnd = ret;
36 if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
37 goto err;
e9224c71 38
0f113f3e 39 /* we have a prime :-) */
3d43f9c8 40 return rnd;
0f113f3e 41 err:
23a1d5e9
RS
42 BN_free(rnd);
43 return NULL;
0f113f3e 44}
e9224c71 45
0f113f3e
MC
46int BN_is_prime(const BIGNUM *a, int checks,
47 void (*callback) (int, int, void *), BN_CTX *ctx_passed,
48 void *cb_arg)
49{
50 BN_GENCB cb;
51 BN_GENCB_set_old(&cb, callback, cb_arg);
36ec749f 52 return ossl_bn_check_prime(a, checks, ctx_passed, 0, &cb);
0f113f3e 53}
e9224c71
GT
54
55int BN_is_prime_fasttest(const BIGNUM *a, int checks,
0f113f3e
MC
56 void (*callback) (int, int, void *),
57 BN_CTX *ctx_passed, void *cb_arg,
58 int do_trial_division)
59{
60 BN_GENCB cb;
61 BN_GENCB_set_old(&cb, callback, cb_arg);
36ec749f 62 return ossl_bn_check_prime(a, checks, ctx_passed, do_trial_division, &cb);
0f113f3e 63}