bn_depr.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2002-2016 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. #if OPENSSL_API_0_9_8
  15. NON_EMPTY_TRANSLATION_UNIT
  16. #else
  17. # include <stdio.h>
  18. # include <time.h>
  19. # include "internal/cryptlib.h"
  20. # include "bn_local.h"
  21. BIGNUM *BN_generate_prime(BIGNUM *ret, int bits, int safe,
  22. const BIGNUM *add, const BIGNUM *rem,
  23. void (*callback) (int, int, void *), void *cb_arg)
  24. {
  25. BN_GENCB cb;
  26. BIGNUM *rnd = NULL;
  27. BN_GENCB_set_old(&cb, callback, cb_arg);
  28. if (ret == NULL) {
  29. if ((rnd = BN_new()) == NULL)
  30. goto err;
  31. } else
  32. rnd = ret;
  33. if (!BN_generate_prime_ex(rnd, bits, safe, add, rem, &cb))
  34. goto err;
  35. /* we have a prime :-) */
  36. return rnd;
  37. err:
  38. BN_free(rnd);
  39. return NULL;
  40. }
  41. int BN_is_prime(const BIGNUM *a, int checks,
  42. void (*callback) (int, int, void *), BN_CTX *ctx_passed,
  43. void *cb_arg)
  44. {
  45. BN_GENCB cb;
  46. BN_GENCB_set_old(&cb, callback, cb_arg);
  47. return bn_check_prime_int(a, checks, ctx_passed, 0, &cb);
  48. }
  49. int BN_is_prime_fasttest(const BIGNUM *a, int checks,
  50. void (*callback) (int, int, void *),
  51. BN_CTX *ctx_passed, void *cb_arg,
  52. int do_trial_division)
  53. {
  54. BN_GENCB cb;
  55. BN_GENCB_set_old(&cb, callback, cb_arg);
  56. return bn_check_prime_int(a, checks, ctx_passed, do_trial_division, &cb);
  57. }
  58. #endif