DH_generate_key.pod 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. =pod
  2. =head1 NAME
  3. DH_generate_key, DH_compute_key - perform Diffie-Hellman key exchange
  4. =head1 SYNOPSIS
  5. #include <openssl/dh.h>
  6. Deprecated since OpenSSL 3.0, can be hidden entirely by defining
  7. B<OPENSSL_API_COMPAT> with a suitable version value, see
  8. L<openssl_user_macros(7)>:
  9. int DH_generate_key(DH *dh);
  10. int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
  11. =head1 DESCRIPTION
  12. Both of the functions described on this page are deprecated.
  13. Applications should instead use L<EVP_PKEY_derive_init(3)>
  14. and L<EVP_PKEY_derive(3)>.
  15. DH_generate_key() performs the first step of a Diffie-Hellman key
  16. exchange by generating private and public DH values. By calling
  17. DH_compute_key(), these are combined with the other party's public
  18. value to compute the shared key.
  19. DH_generate_key() expects B<dh> to contain the shared parameters
  20. B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
  21. unless B<dh-E<gt>priv_key> is already set, and computes the
  22. corresponding public value B<dh-E<gt>pub_key>, which can then be
  23. published.
  24. DH_compute_key() computes the shared secret from the private DH value
  25. in B<dh> and the other party's public value in B<pub_key> and stores
  26. it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
  27. =head1 RETURN VALUES
  28. DH_generate_key() returns 1 on success, 0 otherwise.
  29. DH_compute_key() returns the size of the shared secret on success, -1
  30. on error.
  31. The error codes can be obtained by L<ERR_get_error(3)>.
  32. =head1 SEE ALSO
  33. L<EVP_PKEY_derive(3)>,
  34. L<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<DH_size(3)>
  35. =head1 HISTORY
  36. Both of these functions were deprecated in OpenSSL 3.0.
  37. =head1 COPYRIGHT
  38. Copyright 2000-2020 The OpenSSL Project Authors. All Rights Reserved.
  39. Licensed under the Apache License 2.0 (the "License"). You may not use
  40. this file except in compliance with the License. You can obtain a copy
  41. in the file LICENSE in the source distribution or at
  42. L<https://www.openssl.org/source/license.html>.
  43. =cut