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_get_method() returns a pointer to the method currently selected
42 DH_new_method() allocates and initializes a B<DH> structure so that
43 B<method> will be used for the DH operations. If B<method> is B<NULL>,
44 the default method is used.
46 =head1 THE DH_METHOD STRUCTURE
48 typedef struct dh_meth_st
50 /* name of the implementation */
53 /* generate private and public DH values for key agreement */
54 int (*generate_key)(DH *dh);
56 /* compute shared secret */
57 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
59 /* compute r = a ^ p mod m (May be NULL for some implementations) */
60 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
61 const BIGNUM *m, BN_CTX *ctx,
64 /* called at DH_new */
67 /* called at DH_free */
68 int (*finish)(DH *dh);
72 char *app_data; /* ?? */
78 DH_OpenSSL(), DH_get_default_method() and DH_get_method() return
79 pointers to the respective B<DH_METHOD>s.
81 DH_set_default_method() returns no value.
83 DH_set_method() returns a pointer to the B<DH_METHOD> previously
84 associated with B<dh>.
86 DH_new_method() returns B<NULL> and sets an error code that can be
87 obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails. Otherwise it
88 returns a pointer to the newly allocated structure.
92 L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
96 DH_set_default_method(), DH_get_default_method(), DH_set_method(),
97 DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.