2 * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the OpenSSL license (the "License"). You may not use
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
11 * Support for deprecated functions goes here - static linkage will only
12 * slurp this code if applications are using them directly.
15 #include <openssl/opensslconf.h>
17 NON_EMPTY_TRANSLATION_UNIT
22 # include "internal/cryptlib.h"
25 BIGNUM
*BN_generate_prime(BIGNUM
*ret
, int bits
, int safe
,
26 const BIGNUM
*add
, const BIGNUM
*rem
,
27 void (*callback
) (int, int, void *), void *cb_arg
)
32 BN_GENCB_set_old(&cb
, callback
, cb_arg
);
35 if ((rnd
= BN_new()) == NULL
)
39 if (!BN_generate_prime_ex(rnd
, bits
, safe
, add
, rem
, &cb
))
42 /* we have a prime :-) */
49 int BN_is_prime(const BIGNUM
*a
, int checks
,
50 void (*callback
) (int, int, void *), BN_CTX
*ctx_passed
,
54 BN_GENCB_set_old(&cb
, callback
, cb_arg
);
55 return BN_is_prime_ex(a
, checks
, ctx_passed
, &cb
);
58 int BN_is_prime_fasttest(const BIGNUM
*a
, int checks
,
59 void (*callback
) (int, int, void *),
60 BN_CTX
*ctx_passed
, void *cb_arg
,
61 int do_trial_division
)
64 BN_GENCB_set_old(&cb
, callback
, cb_arg
);
65 return BN_is_prime_fasttest_ex(a
, checks
, ctx_passed
,
66 do_trial_division
, &cb
);