typo
[openssl.git] / doc / crypto / DH_set_method.pod
1 =pod
2
3 =head1 NAME
4
5 DH_set_default_method, DH_get_default_method, DH_set_method,
6 DH_new_method, DH_OpenSSL - select DH method
7
8 =head1 SYNOPSIS
9
10  #include <openssl/dh.h>
11
12  void DH_set_default_method(DH_METHOD *meth);
13
14  DH_METHOD *DH_get_default_method(void);
15
16  DH_METHOD *DH_set_method(DH *dh, DH_METHOD *meth);
17
18  DH *DH_new_method(DH_METHOD *meth);
19
20  DH_METHOD *DH_OpenSSL(void);
21
22 =head1 DESCRIPTION
23
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.
27
28 Initially, the default is to use the OpenSSL internal implementation.
29 DH_OpenSSL() returns a pointer to that method.
30
31 DH_set_default_method() makes B<meth> the default method for all B<DH>
32 structures created later.
33
34 DH_get_default_method() returns a pointer to the current default
35 method.
36
37 DH_set_method() selects B<meth> for all operations using the structure B<dh>.
38
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.
42
43 =head1 THE DH_METHOD STRUCTURE
44
45  typedef struct dh_meth_st
46  {
47      /* name of the implementation */
48         const char *name;
49
50      /* generate private and public DH values for key agreement */
51         int (*generate_key)(DH *dh);
52
53      /* compute shared secret */
54         int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
55
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,
59                                 BN_MONT_CTX *m_ctx);
60
61      /* called at DH_new */
62         int (*init)(DH *dh);
63
64      /* called at DH_free */
65         int (*finish)(DH *dh);
66
67         int flags;
68
69         char *app_data; /* ?? */
70
71  } DH_METHOD;
72
73 =head1 RETURN VALUES
74
75 DH_OpenSSL() and DH_get_default_method() return pointers to the respective
76 B<DH_METHOD>s.
77
78 DH_set_default_method() returns no value.
79
80 DH_set_method() returns a pointer to the B<DH_METHOD> previously
81 associated with B<dh>.
82
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.
86
87 =head1 SEE ALSO
88
89 L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
90
91 =head1 HISTORY
92
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.
95
96 =cut