1*ebfedea0SLionel Sambuc=pod 2*ebfedea0SLionel Sambuc 3*ebfedea0SLionel Sambuc=head1 NAME 4*ebfedea0SLionel Sambuc 5*ebfedea0SLionel Sambucdh - Diffie-Hellman key agreement 6*ebfedea0SLionel Sambuc 7*ebfedea0SLionel Sambuc=head1 SYNOPSIS 8*ebfedea0SLionel Sambuc 9*ebfedea0SLionel Sambuc #include <openssl/dh.h> 10*ebfedea0SLionel Sambuc #include <openssl/engine.h> 11*ebfedea0SLionel Sambuc 12*ebfedea0SLionel Sambuc DH * DH_new(void); 13*ebfedea0SLionel Sambuc void DH_free(DH *dh); 14*ebfedea0SLionel Sambuc 15*ebfedea0SLionel Sambuc int DH_size(const DH *dh); 16*ebfedea0SLionel Sambuc 17*ebfedea0SLionel Sambuc DH * DH_generate_parameters(int prime_len, int generator, 18*ebfedea0SLionel Sambuc void (*callback)(int, int, void *), void *cb_arg); 19*ebfedea0SLionel Sambuc int DH_check(const DH *dh, int *codes); 20*ebfedea0SLionel Sambuc 21*ebfedea0SLionel Sambuc int DH_generate_key(DH *dh); 22*ebfedea0SLionel Sambuc int DH_compute_key(unsigned char *key, BIGNUM *pub_key, DH *dh); 23*ebfedea0SLionel Sambuc 24*ebfedea0SLionel Sambuc void DH_set_default_method(const DH_METHOD *meth); 25*ebfedea0SLionel Sambuc const DH_METHOD *DH_get_default_method(void); 26*ebfedea0SLionel Sambuc int DH_set_method(DH *dh, const DH_METHOD *meth); 27*ebfedea0SLionel Sambuc DH *DH_new_method(ENGINE *engine); 28*ebfedea0SLionel Sambuc const DH_METHOD *DH_OpenSSL(void); 29*ebfedea0SLionel Sambuc 30*ebfedea0SLionel Sambuc int DH_get_ex_new_index(long argl, char *argp, int (*new_func)(), 31*ebfedea0SLionel Sambuc int (*dup_func)(), void (*free_func)()); 32*ebfedea0SLionel Sambuc int DH_set_ex_data(DH *d, int idx, char *arg); 33*ebfedea0SLionel Sambuc char *DH_get_ex_data(DH *d, int idx); 34*ebfedea0SLionel Sambuc 35*ebfedea0SLionel Sambuc DH * d2i_DHparams(DH **a, unsigned char **pp, long length); 36*ebfedea0SLionel Sambuc int i2d_DHparams(const DH *a, unsigned char **pp); 37*ebfedea0SLionel Sambuc 38*ebfedea0SLionel Sambuc int DHparams_print_fp(FILE *fp, const DH *x); 39*ebfedea0SLionel Sambuc int DHparams_print(BIO *bp, const DH *x); 40*ebfedea0SLionel Sambuc 41*ebfedea0SLionel Sambuc=head1 DESCRIPTION 42*ebfedea0SLionel Sambuc 43*ebfedea0SLionel SambucThese functions implement the Diffie-Hellman key agreement protocol. 44*ebfedea0SLionel SambucThe generation of shared DH parameters is described in 45*ebfedea0SLionel SambucL<DH_generate_parameters(3)|DH_generate_parameters(3)>; L<DH_generate_key(3)|DH_generate_key(3)> describes how 46*ebfedea0SLionel Sambucto perform a key agreement. 47*ebfedea0SLionel Sambuc 48*ebfedea0SLionel SambucThe B<DH> structure consists of several BIGNUM components. 49*ebfedea0SLionel Sambuc 50*ebfedea0SLionel Sambuc struct 51*ebfedea0SLionel Sambuc { 52*ebfedea0SLionel Sambuc BIGNUM *p; // prime number (shared) 53*ebfedea0SLionel Sambuc BIGNUM *g; // generator of Z_p (shared) 54*ebfedea0SLionel Sambuc BIGNUM *priv_key; // private DH value x 55*ebfedea0SLionel Sambuc BIGNUM *pub_key; // public DH value g^x 56*ebfedea0SLionel Sambuc // ... 57*ebfedea0SLionel Sambuc }; 58*ebfedea0SLionel Sambuc DH 59*ebfedea0SLionel Sambuc 60*ebfedea0SLionel SambucNote that DH keys may use non-standard B<DH_METHOD> implementations, 61*ebfedea0SLionel Sambuceither directly or by the use of B<ENGINE> modules. In some cases (eg. an 62*ebfedea0SLionel SambucENGINE providing support for hardware-embedded keys), these BIGNUM values 63*ebfedea0SLionel Sambucwill not be used by the implementation or may be used for alternative data 64*ebfedea0SLionel Sambucstorage. For this reason, applications should generally avoid using DH 65*ebfedea0SLionel Sambucstructure elements directly and instead use API functions to query or 66*ebfedea0SLionel Sambucmodify keys. 67*ebfedea0SLionel Sambuc 68*ebfedea0SLionel Sambuc=head1 SEE ALSO 69*ebfedea0SLionel Sambuc 70*ebfedea0SLionel SambucL<dhparam(1)|dhparam(1)>, L<bn(3)|bn(3)>, L<dsa(3)|dsa(3)>, L<err(3)|err(3)>, 71*ebfedea0SLionel SambucL<rand(3)|rand(3)>, L<rsa(3)|rsa(3)>, L<engine(3)|engine(3)>, 72*ebfedea0SLionel SambucL<DH_set_method(3)|DH_set_method(3)>, L<DH_new(3)|DH_new(3)>, 73*ebfedea0SLionel SambucL<DH_get_ex_new_index(3)|DH_get_ex_new_index(3)>, 74*ebfedea0SLionel SambucL<DH_generate_parameters(3)|DH_generate_parameters(3)>, 75*ebfedea0SLionel SambucL<DH_compute_key(3)|DH_compute_key(3)>, L<d2i_DHparams(3)|d2i_DHparams(3)>, 76*ebfedea0SLionel SambucL<RSA_print(3)|RSA_print(3)> 77*ebfedea0SLionel Sambuc 78*ebfedea0SLionel Sambuc=cut 79