]>
Commit | Line | Data |
---|---|---|
4f22f405 RS |
1 | /* |
2 | * Copyright 2002-2016 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> |
fcd2d5a6 | 16 | #if OPENSSL_API_0_9_8 |
effaf4de RS |
17 | NON_EMPTY_TRANSLATION_UNIT |
18 | #else | |
e9224c71 | 19 | |
effaf4de RS |
20 | # include <stdio.h> |
21 | # include <time.h> | |
22 | # include "internal/cryptlib.h" | |
706457b7 | 23 | # include "bn_local.h" |
9d473aa2 | 24 | |
e9224c71 | 25 | BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, |
0f113f3e MC |
26 | const BIGNUM *add, const BIGNUM *rem, |
27 | void (*callback) (int, int, void *), void *cb_arg) | |
28 | { | |
29 | BN_GENCB cb; | |
30 | BIGNUM *rnd = NULL; | |
e9224c71 | 31 | |
0f113f3e | 32 | BN_GENCB_set_old(&cb, callback, cb_arg); |
e9224c71 | 33 | |
0f113f3e MC |
34 | if (ret == NULL) { |
35 | if ((rnd = BN_new()) == NULL) | |
36 | goto err; | |
37 | } else | |
38 | rnd = ret; | |
39 | if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb)) | |
40 | goto err; | |
e9224c71 | 41 | |
0f113f3e | 42 | /* we have a prime :-) */ |
3d43f9c8 | 43 | return rnd; |
0f113f3e | 44 | err: |
23a1d5e9 RS |
45 | BN_free(rnd); |
46 | return NULL; | |
0f113f3e | 47 | } |
e9224c71 | 48 | |
0f113f3e MC |
49 | int BN_is_prime(const BIGNUM *a, int checks, |
50 | void (*callback) (int, int, void *), BN_CTX *ctx_passed, | |
51 | void *cb_arg) | |
52 | { | |
53 | BN_GENCB cb; | |
54 | BN_GENCB_set_old(&cb, callback, cb_arg); | |
42619397 | 55 | return bn_check_prime_int(a, checks, ctx_passed, 0, &cb); |
0f113f3e | 56 | } |
e9224c71 GT |
57 | |
58 | int BN_is_prime_fasttest(const BIGNUM *a, int checks, | |
0f113f3e MC |
59 | void (*callback) (int, int, void *), |
60 | BN_CTX *ctx_passed, void *cb_arg, | |
61 | int do_trial_division) | |
62 | { | |
63 | BN_GENCB cb; | |
64 | BN_GENCB_set_old(&cb, callback, cb_arg); | |
42619397 | 65 | return bn_check_prime_int(a, checks, ctx_passed, do_trial_division, &cb); |
0f113f3e | 66 | } |
42619397 | 67 | |
9d473aa2 | 68 | #endif |