1*e71b7053SJung-uk Kim=pod 2*e71b7053SJung-uk Kim 3*e71b7053SJung-uk Kim=head1 NAME 4*e71b7053SJung-uk Kim 5*e71b7053SJung-uk KimDH_set_default_method, DH_get_default_method, 6*e71b7053SJung-uk KimDH_set_method, DH_new_method, DH_OpenSSL - select DH method 7*e71b7053SJung-uk Kim 8*e71b7053SJung-uk Kim=head1 SYNOPSIS 9*e71b7053SJung-uk Kim 10*e71b7053SJung-uk Kim #include <openssl/dh.h> 11*e71b7053SJung-uk Kim 12*e71b7053SJung-uk Kim void DH_set_default_method(const DH_METHOD *meth); 13*e71b7053SJung-uk Kim 14*e71b7053SJung-uk Kim const DH_METHOD *DH_get_default_method(void); 15*e71b7053SJung-uk Kim 16*e71b7053SJung-uk Kim int DH_set_method(DH *dh, const DH_METHOD *meth); 17*e71b7053SJung-uk Kim 18*e71b7053SJung-uk Kim DH *DH_new_method(ENGINE *engine); 19*e71b7053SJung-uk Kim 20*e71b7053SJung-uk Kim const DH_METHOD *DH_OpenSSL(void); 21*e71b7053SJung-uk Kim 22*e71b7053SJung-uk Kim=head1 DESCRIPTION 23*e71b7053SJung-uk Kim 24*e71b7053SJung-uk KimA B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman 25*e71b7053SJung-uk Kimoperations. By modifying the method, alternative implementations 26*e71b7053SJung-uk Kimsuch as hardware accelerators may be used. IMPORTANT: See the NOTES section for 27*e71b7053SJung-uk Kimimportant information about how these DH API functions are affected by the use 28*e71b7053SJung-uk Kimof B<ENGINE> API calls. 29*e71b7053SJung-uk Kim 30*e71b7053SJung-uk KimInitially, the default DH_METHOD is the OpenSSL internal implementation, as 31*e71b7053SJung-uk Kimreturned by DH_OpenSSL(). 32*e71b7053SJung-uk Kim 33*e71b7053SJung-uk KimDH_set_default_method() makes B<meth> the default method for all DH 34*e71b7053SJung-uk Kimstructures created later. 35*e71b7053SJung-uk KimB<NB>: This is true only whilst no ENGINE has been set 36*e71b7053SJung-uk Kimas a default for DH, so this function is no longer recommended. 37*e71b7053SJung-uk KimThis function is not thread-safe and should not be called at the same time 38*e71b7053SJung-uk Kimas other OpenSSL functions. 39*e71b7053SJung-uk Kim 40*e71b7053SJung-uk KimDH_get_default_method() returns a pointer to the current default DH_METHOD. 41*e71b7053SJung-uk KimHowever, the meaningfulness of this result is dependent on whether the ENGINE 42*e71b7053SJung-uk KimAPI is being used, so this function is no longer recommended. 43*e71b7053SJung-uk Kim 44*e71b7053SJung-uk KimDH_set_method() selects B<meth> to perform all operations using the key B<dh>. 45*e71b7053SJung-uk KimThis will replace the DH_METHOD used by the DH key and if the previous method 46*e71b7053SJung-uk Kimwas supplied by an ENGINE, the handle to that ENGINE will be released during the 47*e71b7053SJung-uk Kimchange. It is possible to have DH keys that only work with certain DH_METHOD 48*e71b7053SJung-uk Kimimplementations (eg. from an ENGINE module that supports embedded 49*e71b7053SJung-uk Kimhardware-protected keys), and in such cases attempting to change the DH_METHOD 50*e71b7053SJung-uk Kimfor the key can have unexpected results. 51*e71b7053SJung-uk Kim 52*e71b7053SJung-uk KimDH_new_method() allocates and initializes a DH structure so that B<engine> will 53*e71b7053SJung-uk Kimbe used for the DH operations. If B<engine> is NULL, the default ENGINE for DH 54*e71b7053SJung-uk Kimoperations is used, and if no default ENGINE is set, the DH_METHOD controlled by 55*e71b7053SJung-uk KimDH_set_default_method() is used. 56*e71b7053SJung-uk Kim 57*e71b7053SJung-uk KimA new DH_METHOD object may be constructed using DH_meth_new() (see 58*e71b7053SJung-uk KimL<DH_meth_new(3)>). 59*e71b7053SJung-uk Kim 60*e71b7053SJung-uk Kim=head1 RETURN VALUES 61*e71b7053SJung-uk Kim 62*e71b7053SJung-uk KimDH_OpenSSL() and DH_get_default_method() return pointers to the respective 63*e71b7053SJung-uk KimB<DH_METHOD>s. 64*e71b7053SJung-uk Kim 65*e71b7053SJung-uk KimDH_set_default_method() returns no value. 66*e71b7053SJung-uk Kim 67*e71b7053SJung-uk KimDH_set_method() returns non-zero if the provided B<meth> was successfully set as 68*e71b7053SJung-uk Kimthe method for B<dh> (including unloading the ENGINE handle if the previous 69*e71b7053SJung-uk Kimmethod was supplied by an ENGINE). 70*e71b7053SJung-uk Kim 71*e71b7053SJung-uk KimDH_new_method() returns NULL and sets an error code that can be obtained by 72*e71b7053SJung-uk KimL<ERR_get_error(3)> if the allocation fails. Otherwise it 73*e71b7053SJung-uk Kimreturns a pointer to the newly allocated structure. 74*e71b7053SJung-uk Kim 75*e71b7053SJung-uk Kim=head1 SEE ALSO 76*e71b7053SJung-uk Kim 77*e71b7053SJung-uk KimL<DH_new(3)>, L<DH_new(3)>, L<DH_meth_new(3)> 78*e71b7053SJung-uk Kim 79*e71b7053SJung-uk Kim=head1 COPYRIGHT 80*e71b7053SJung-uk Kim 81*e71b7053SJung-uk KimCopyright 2000-2016 The OpenSSL Project Authors. All Rights Reserved. 82*e71b7053SJung-uk Kim 83*e71b7053SJung-uk KimLicensed under the OpenSSL license (the "License"). You may not use 84*e71b7053SJung-uk Kimthis file except in compliance with the License. You can obtain a copy 85*e71b7053SJung-uk Kimin the file LICENSE in the source distribution or at 86*e71b7053SJung-uk KimL<https://www.openssl.org/source/license.html>. 87*e71b7053SJung-uk Kim 88*e71b7053SJung-uk Kim=cut 89