2
0

bn_depr.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright 2002-2021 The OpenSSL Project Authors. All Rights Reserved.
  3. *
  4. * Licensed under the Apache License 2.0 (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
  8. */
  9. /*
  10. * Support for deprecated functions goes here - static linkage will only
  11. * slurp this code if applications are using them directly.
  12. */
  13. #include <openssl/opensslconf.h>
  14. #include <stdio.h>
  15. #include <time.h>
  16. #include "internal/cryptlib.h"
  17. #include "bn_local.h"
  18. BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
  19. const BIGNUM *add, const BIGNUM *rem,
  20. void (*callback) (int, int, void *), void *cb_arg)
  21. {
  22. BN_GENCB cb;
  23. BIGNUM *rnd = NULL;
  24. BN_GENCB_set_old(&cb, callback, cb_arg);
  25. if (ret == NULL) {
  26. if ((rnd = BN_new()) == NULL)
  27. goto err;
  28. } else
  29. rnd = ret;
  30. if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
  31. goto err;
  32. /* we have a prime :-) */
  33. return rnd;
  34. err:
  35. BN_free(rnd);
  36. return NULL;
  37. }
  38. int BN_is_prime(const BIGNUM *a, int checks,
  39. void (*callback) (int, int, void *), BN_CTX *ctx_passed,
  40. void *cb_arg)
  41. {
  42. BN_GENCB cb;
  43. BN_GENCB_set_old(&cb, callback, cb_arg);
  44. return ossl_bn_check_prime(a, checks, ctx_passed, 0, &cb);
  45. }
  46. int BN_is_prime_fasttest(const BIGNUM *a, int checks,
  47. void (*callback) (int, int, void *),
  48. BN_CTX *ctx_passed, void *cb_arg,
  49. int do_trial_division)
  50. {
  51. BN_GENCB cb;
  52. BN_GENCB_set_old(&cb, callback, cb_arg);
  53. return ossl_bn_check_prime(a, checks, ctx_passed, do_trial_division, &cb);
  54. }