summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/doc/DH_set_method.pod
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/libcrypto/doc/DH_set_method.pod')
-rw-r--r--src/lib/libcrypto/doc/DH_set_method.pod111
1 files changed, 111 insertions, 0 deletions
diff --git a/src/lib/libcrypto/doc/DH_set_method.pod b/src/lib/libcrypto/doc/DH_set_method.pod
new file mode 100644
index 0000000000..d990bf8786
--- /dev/null
+++ b/src/lib/libcrypto/doc/DH_set_method.pod
@@ -0,0 +1,111 @@
1=pod
2
3=head1 NAME
4
5DH_set_default_openssl_method, DH_get_default_openssl_method,
6DH_set_method, DH_new_method, DH_OpenSSL - select DH method
7
8=head1 SYNOPSIS
9
10 #include <openssl/dh.h>
11 #include <openssl/engine.h>
12
13 void DH_set_default_openssl_method(DH_METHOD *meth);
14
15 DH_METHOD *DH_get_default_openssl_method(void);
16
17 int DH_set_method(DH *dh, ENGINE *engine);
18
19 DH *DH_new_method(ENGINE *engine);
20
21 DH_METHOD *DH_OpenSSL(void);
22
23=head1 DESCRIPTION
24
25A B<DH_METHOD> specifies the functions that OpenSSL uses for Diffie-Hellman
26operations. By modifying the method, alternative implementations
27such as hardware accelerators may be used.
28
29Initially, the default is to use the OpenSSL internal implementation.
30DH_OpenSSL() returns a pointer to that method.
31
32DH_set_default_openssl_method() makes B<meth> the default method for all DH
33structures created later. B<NB:> This is true only whilst the default engine
34for Diffie-Hellman operations remains as "openssl". ENGINEs provide an
35encapsulation for implementations of one or more algorithms, and all the DH
36functions mentioned here operate within the scope of the default
37"openssl" engine.
38
39DH_get_default_openssl_method() returns a pointer to the current default
40method for the "openssl" engine.
41
42DH_set_method() selects B<engine> as the engine that will be responsible for
43all operations using the structure B<dh>. If this function completes successfully,
44then the B<dh> structure will have its own functional reference of B<engine>, so
45the caller should remember to free their own reference to B<engine> when they are
46finished with it. NB: An ENGINE's DH_METHOD can be retrieved (or set) by
47ENGINE_get_DH() or ENGINE_set_DH().
48
49DH_new_method() allocates and initializes a DH structure so that
50B<engine> will be used for the DH operations. If B<engine> is NULL,
51the default engine for Diffie-Hellman opertaions is used.
52
53=head1 THE DH_METHOD STRUCTURE
54
55 typedef struct dh_meth_st
56 {
57 /* name of the implementation */
58 const char *name;
59
60 /* generate private and public DH values for key agreement */
61 int (*generate_key)(DH *dh);
62
63 /* compute shared secret */
64 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
65
66 /* compute r = a ^ p mod m (May be NULL for some implementations) */
67 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
68 const BIGNUM *m, BN_CTX *ctx,
69 BN_MONT_CTX *m_ctx);
70
71 /* called at DH_new */
72 int (*init)(DH *dh);
73
74 /* called at DH_free */
75 int (*finish)(DH *dh);
76
77 int flags;
78
79 char *app_data; /* ?? */
80
81 } DH_METHOD;
82
83=head1 RETURN VALUES
84
85DH_OpenSSL() and DH_get_default_openssl_method() return pointers to the
86respective B<DH_METHOD>s.
87
88DH_set_default_openssl_method() returns no value.
89
90DH_set_method() returns non-zero if the ENGINE associated with B<dh>
91was successfully changed to B<engine>.
92
93DH_new_method() returns NULL and sets an error code that can be
94obtained by L<ERR_get_error(3)|ERR_get_error(3)> if the allocation fails.
95Otherwise it returns a pointer to the newly allocated structure.
96
97=head1 SEE ALSO
98
99L<dh(3)|dh(3)>, L<DH_new(3)|DH_new(3)>
100
101=head1 HISTORY
102
103DH_set_default_method(), DH_get_default_method(), DH_set_method(),
104DH_new_method() and DH_OpenSSL() were added in OpenSSL 0.9.4.
105
106DH_set_default_openssl_method() and DH_get_default_openssl_method()
107replaced DH_set_default_method() and DH_get_default_method() respectively,
108and DH_set_method() and DH_new_method() were altered to use B<ENGINE>s
109rather than B<DH_METHOD>s during development of OpenSSL 0.9.6.
110
111=cut