2
0

DH_generate_key.pod 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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)|ERR_get_error(3)>.
  26. =head1 SEE ALSO
  27. L<dh(3)|dh(3)>, L<ERR_get_error(3)|ERR_get_error(3)>, L<rand(3)|rand(3)>, L<DH_size(3)|DH_size(3)>
  28. =head1 HISTORY
  29. DH_generate_key() and DH_compute_key() are available in all versions
  30. of SSLeay and OpenSSL.
  31. =cut