]> git.ipfire.org Git - thirdparty/openssl.git/blame - crypto/bn/bn_depr.c
Copyright consolidation 06/10
[thirdparty/openssl.git] / crypto / bn / bn_depr.c
CommitLineData
4f22f405
RS
1/*
2 * Copyright 2002-2016 The OpenSSL Project Authors. All Rights Reserved.
e9224c71 3 *
4f22f405
RS
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
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>
effaf4de
RS
16#if OPENSSL_API_COMPAT >= 0x00908000L
17NON_EMPTY_TRANSLATION_UNIT
18#else
e9224c71 19
effaf4de
RS
20# include <stdio.h>
21# include <time.h>
22# include "internal/cryptlib.h"
23# include "bn_lcl.h"
24# include <openssl/rand.h>
9d473aa2 25
e9224c71 26BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
0f113f3e
MC
27 const BIGNUM *add, const BIGNUM *rem,
28 void (*callback) (int, int, void *), void *cb_arg)
29{
30 BN_GENCB cb;
31 BIGNUM *rnd = NULL;
e9224c71 32
0f113f3e 33 BN_GENCB_set_old(&cb, callback, cb_arg);
e9224c71 34
0f113f3e
MC
35 if (ret == NULL) {
36 if ((rnd = BN_new()) == NULL)
37 goto err;
38 } else
39 rnd = ret;
40 if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
41 goto err;
e9224c71 42
0f113f3e 43 /* we have a prime :-) */
23a1d5e9 44 return ret;
0f113f3e 45 err:
23a1d5e9
RS
46 BN_free(rnd);
47 return NULL;
0f113f3e 48}
e9224c71 49
0f113f3e
MC
50int BN_is_prime(const BIGNUM *a, int checks,
51 void (*callback) (int, int, void *), BN_CTX *ctx_passed,
52 void *cb_arg)
53{
54 BN_GENCB cb;
55 BN_GENCB_set_old(&cb, callback, cb_arg);
56 return BN_is_prime_ex(a, checks, ctx_passed, &cb);
57}
e9224c71
GT
58
59int BN_is_prime_fasttest(const BIGNUM *a, int checks,
0f113f3e
MC
60 void (*callback) (int, int, void *),
61 BN_CTX *ctx_passed, void *cb_arg,
62 int do_trial_division)
63{
64 BN_GENCB cb;
65 BN_GENCB_set_old(&cb, callback, cb_arg);
66 return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
67 do_trial_division, &cb);
68}
9d473aa2 69#endif