123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #include <stdio.h>
- #include <time.h>
- #include "cryptlib.h"
- #include "bn_lcl.h"
- #include <openssl/rand.h>
- static void *dummy = &dummy;
- #ifndef OPENSSL_NO_DEPRECATED
- BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
- const BIGNUM *add, const BIGNUM *rem,
- void (*callback) (int, int, void *), void *cb_arg)
- {
- BN_GENCB cb;
- BIGNUM *rnd = NULL;
- int found = 0;
- BN_GENCB_set_old(&cb, callback, cb_arg);
- if (ret == NULL) {
- if ((rnd = BN_new()) == NULL)
- goto err;
- } else
- rnd = ret;
- if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
- goto err;
-
- found = 1;
- err:
- if (!found && (ret == NULL) && (rnd != NULL))
- BN_free(rnd);
- return (found ? rnd : NULL);
- }
- int BN_is_prime(const BIGNUM *a, int checks,
- void (*callback) (int, int, void *), BN_CTX *ctx_passed,
- void *cb_arg)
- {
- BN_GENCB cb;
- BN_GENCB_set_old(&cb, callback, cb_arg);
- return BN_is_prime_ex(a, checks, ctx_passed, &cb);
- }
- int BN_is_prime_fasttest(const BIGNUM *a, int checks,
- void (*callback) (int, int, void *),
- BN_CTX *ctx_passed, void *cb_arg,
- int do_trial_division)
- {
- BN_GENCB cb;
- BN_GENCB_set_old(&cb, callback, cb_arg);
- return BN_is_prime_fasttest_ex(a, checks, ctx_passed,
- do_trial_division, &cb);
- }
- #endif
|