summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/bn/bn_depr.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/bn/bn_depr.c')
-rw-r--r--src/lib/libcrypto/bn/bn_depr.c60
1 files changed, 32 insertions, 28 deletions
diff --git a/src/lib/libcrypto/bn/bn_depr.c b/src/lib/libcrypto/bn/bn_depr.c
index 27535e4fca..e4d7f33967 100644
--- a/src/lib/libcrypto/bn/bn_depr.c
+++ b/src/lib/libcrypto/bn/bn_depr.c
@@ -7,7 +7,7 @@
7 * are met: 7 * are met:
8 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
11 * 11 *
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in 13 * notice, this list of conditions and the following disclaimer in
@@ -62,51 +62,55 @@
62#include "bn_lcl.h" 62#include "bn_lcl.h"
63#include <openssl/rand.h> 63#include <openssl/rand.h>
64 64
65static void *dummy=&dummy; 65static void *dummy = &dummy;
66 66
67#ifndef OPENSSL_NO_DEPRECATED 67#ifndef OPENSSL_NO_DEPRECATED
68BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe, 68BIGNUM *
69 const BIGNUM *add, const BIGNUM *rem, 69BN_generate_prime(BIGNUM *ret, int bits, int safe, const BIGNUM *add,
70 void (*callback)(int,int,void *), void *cb_arg) 70 const BIGNUM *rem, void (*callback)(int, int, void *), void *cb_arg)
71 { 71{
72 BN_GENCB cb; 72 BN_GENCB cb;
73 BIGNUM *rnd=NULL; 73 BIGNUM *rnd = NULL;
74 int found = 0; 74 int found = 0;
75 75
76 BN_GENCB_set_old(&cb, callback, cb_arg); 76 BN_GENCB_set_old(&cb, callback, cb_arg);
77 77
78 if (ret == NULL) 78 if (ret == NULL) {
79 { 79 if ((rnd = BN_new()) == NULL)
80 if ((rnd=BN_new()) == NULL) goto err; 80 goto err;
81 } 81 } else
82 else 82 rnd = ret;
83 rnd=ret; 83 if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
84 if(!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
85 goto err; 84 goto err;
86 85
87 /* we have a prime :-) */ 86 /* we have a prime :-) */
88 found = 1; 87 found = 1;
88
89err: 89err:
90 if (!found && (ret == NULL) && (rnd != NULL)) BN_free(rnd); 90 if (!found && (ret == NULL) && (rnd != NULL))
91 return(found ? rnd : NULL); 91 BN_free(rnd);
92 } 92 return (found ? rnd : NULL);
93}
93 94
94int BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int,int,void *), 95int
95 BN_CTX *ctx_passed, void *cb_arg) 96BN_is_prime(const BIGNUM *a, int checks, void (*callback)(int, int, void *),
96 { 97 BN_CTX *ctx_passed, void *cb_arg)
98{
97 BN_GENCB cb; 99 BN_GENCB cb;
100
98 BN_GENCB_set_old(&cb, callback, cb_arg); 101 BN_GENCB_set_old(&cb, callback, cb_arg);
99 return BN_is_prime_ex(a, checks, ctx_passed, &cb); 102 return BN_is_prime_ex(a, checks, ctx_passed, &cb);
100 } 103}
101 104
102int BN_is_prime_fasttest(const BIGNUM *a, int checks, 105int
103 void (*callback)(int,int,void *), 106BN_is_prime_fasttest(const BIGNUM *a, int checks,
104 BN_CTX *ctx_passed, void *cb_arg, 107 void (*callback)(int, int, void *), BN_CTX *ctx_passed, void *cb_arg,
105 int do_trial_division) 108 int do_trial_division)
106 { 109{
107 BN_GENCB cb; 110 BN_GENCB cb;
111
108 BN_GENCB_set_old(&cb, callback, cb_arg); 112 BN_GENCB_set_old(&cb, callback, cb_arg);
109 return BN_is_prime_fasttest_ex(a, checks, ctx_passed, 113 return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
110 do_trial_division, &cb); 114 do_trial_division, &cb);
111 } 115}
112#endif 116#endif