5 DH_set_default_method, DH_get_default_method, DH_set_method,
6 DH_new_method, DH_OpenSSL - select DH method
10 #include <openssl/dh.h>
12 void DH_set_default_method(DH_METHOD *meth);
14 DH_METHOD *DH_get_default_method(void);
16 DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
18 DH *DH_new_method(DH_METHOD *meth);
20 DH_METHOD *DH_OpenSSL(void);
24 A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman
25 operations. By modifying the method, alternative implementations
26 such as hardware accelerators may be used.
28 Initially, the default is to use the OpenSSL internal implementation.
29 DH_OpenSSL() returns a pointer to that method.
31 DH_set_default_method() makes B<meth> the default method for all B<DH>
32 structures created later.
34 DH_get_default_method() returns a pointer to the current default
37 DH_set_method() selects B<meth> for all operations using the structure B<dh>.
39 DH_new_method() allocates and initializes a B<DH> structure so that
40 B<method> will be used for the DH operations. If B<method> is B<NULL>,
41 the default method is used.
43 =head1 THE DH_METHOD STRUCTURE
45 typedef struct dh_meth_st
47 /* name of the implementation */
50 /* generate private and public DH values for key agreement */
51 int (*generate_key)(DH *dh);
53 /* compute shared secret */
54 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
56 /* compute r = a ^ p mod m (May be NULL for some implementations) */
57 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
58 const BIGNUM *m, BN_CTX *ctx,
61 /* called at DH_new */
64 /* called at DH_free */
65 int (*finish)(DH *dh);
69 char *app_data; /* ?? */
75 DH_OpenSSL() and DH_get_default_method() return pointers to the respective
78 DH_set_default_method() returns no value.
80 DH_set_method() returns a pointer to the B<DH_METHOD> previously
81 associated with B<dh>.
83 DH_new_method() returns B<NULL> and sets an error code that can be
84 obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
85 returns a pointer to the newly allocated structure.
89 L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
93 DH_set_default_method(), DH_get_default_method(), DH_set_method(),
94 DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.