OpenSSL DH_generate_key(3openssl)
NNNNAAAAMMMMEEEEDH_generate_key, DH_compute_key - perform Diffie-Hellman key
exchange SSSSYYYYNNNNOOOOPPPPSSSSIIIISSSS#include
int DH_generate_key(DH *dh);
int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh);
DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNNDH_generate_key() performs the first step of a Diffie-
Hellman key exchange by generating private and public DHvalues. By calling DH_compute_key(), these are combined with
the other party's public value to compute the shared key.DH_generate_key() expects ddddhhhh to contain the shared
parameters ddddhhhh---->>>>pppp and ddddhhhh---->>>>gggg. It generates a random private DH
value unless ddddhhhh---->>>>pppprrrriiiivvvv_kkkkeeeeyyyy is already set, and computes the
corresponding public value ddddhhhh---->>>>ppppuuuubbbb_kkkkeeeeyyyy, which can then be
published.DH_compute_key() computes the shared secret from the private
DH value in ddddhhhh and the other party's public value in ppppuuuubbbb_kkkkeeeeyyyy
and stores it in kkkkeeeeyyyy. kkkkeeeeyyyy must point to DDDDHHHH_ssssiiiizzzzeeee((((ddddhhhh)))) bytes of
memory. RRRREEEETTTTUUUURRRRNNNN VVVVAAAALLLLUUUUEEEESSSSDH_generate_key() returns 1 on success, 0 otherwise.
DH_compute_key() returns the size of the shared secret on
success, -1 on error.
The error codes can be obtained by ERR_get_error(3).
SSSSEEEEEEEE AAAALLLLSSSSOOOOdh(3), ERR_get_error(3), rand(3), DH_size(3)
HHHHIIIISSSSTTTTOOOORRRRYYYYDH_generate_key() and DH_compute_key() are available in all
versions of SSLeay and OpenSSL.25/Sep/2002 Last change: 0.9.8o 1