dh_depr.c 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*
  2. * Copyright 2002-2020 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. /* This file contains deprecated functions as wrappers to the new ones */
  10. /*
  11. * DH low level APIs are deprecated for public use, but still ok for
  12. * internal use.
  13. */
  14. #include "internal/deprecated.h"
  15. #include <openssl/opensslconf.h>
  16. #include <stdio.h>
  17. #include "internal/cryptlib.h"
  18. #include <openssl/bn.h>
  19. #include <openssl/dh.h>
  20. DH *DH_generate_parameters(int prime_len, int generator,
  21. void (*callback) (int, int, void *), void *cb_arg)
  22. {
  23. BN_GENCB *cb;
  24. DH *ret = NULL;
  25. if ((ret = DH_new()) == NULL)
  26. return NULL;
  27. cb = BN_GENCB_new();
  28. if (cb == NULL) {
  29. DH_free(ret);
  30. return NULL;
  31. }
  32. BN_GENCB_set_old(cb, callback, cb_arg);
  33. if (DH_generate_parameters_ex(ret, prime_len, generator, cb)) {
  34. BN_GENCB_free(cb);
  35. return ret;
  36. }
  37. BN_GENCB_free(cb);
  38. DH_free(ret);
  39. return NULL;
  40. }