2
0

DH_generate_key.pod 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. int DH_generate_key(DH *dh);
  7. int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
  8. =head1 DESCRIPTION
  9. DH_generate_key() performs the first step of a Diffie-Hellman key
  10. exchange by generating private and public DH values. By calling
  11. DH_compute_key(), these are combined with the other party's public
  12. value to compute the shared key.
  13. DH_generate_key() expects B<dh> to contain the shared parameters
  14. B<dh-E<gt>p> and B<dh-E<gt>g>. It generates a random private DH value
  15. unless B<dh-E<gt>priv_key> is already set, and computes the
  16. corresponding public value B<dh-E<gt>pub_key>, which can then be
  17. published.
  18. DH_compute_key() computes the shared secret from the private DH value
  19. in B<dh> and the other party's public value in B<pub_key> and stores
  20. it in B<key>. B<key> must point to B<DH_size(dh)> bytes of memory.
  21. =head1 RETURN VALUES
  22. DH_generate_key() returns 1 on success, 0 otherwise.
  23. DH_compute_key() returns the size of the shared secret on success, -1
  24. on error.
  25. The error codes can be obtained by L<ERR_get_error(3)>.
  26. =head1 SEE ALSO
  27. L<DH_new(3)>, L<ERR_get_error(3)>, L<RAND_bytes(3)>, L<DH_size(3)>
  28. =head1 COPYRIGHT
  29. Copyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved.
  30. Licensed under the OpenSSL license (the "License"). You may not use
  31. this file except in compliance with the License. You can obtain a copy
  32. in the file LICENSE in the source distribution or at
  33. L<https://www.openssl.org/source/license.html>.
  34. =cut