1 .\" $OpenBSD: DH_set_method.3,v 1.5 2016/12/10 22:22:59 schwarze Exp $
2 .\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
4 .\" This file was written by Ulf Moeller <ulf@openssl.org>.
5 .\" Copyright (c) 2000, 2002, 2007 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
14 .\" 2. Redistributions in binary form must reproduce the above copyright
15 .\" notice, this list of conditions and the following disclaimer in
16 .\" the documentation and/or other materials provided with the
19 .\" 3. All advertising materials mentioning features or use of this
20 .\" software must display the following acknowledgment:
21 .\" "This product includes software developed by the OpenSSL Project
22 .\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25 .\" endorse or promote products derived from this software without
26 .\" prior written permission. For written permission, please contact
27 .\" openssl-core@openssl.org.
29 .\" 5. Products derived from this software may not be called "OpenSSL"
30 .\" nor may "OpenSSL" appear in their names without prior written
31 .\" permission of the OpenSSL Project.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41 .\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
51 .Dd $Mdocdate: December 10 2016 $
55 .Nm DH_set_default_method ,
56 .Nm DH_get_default_method ,
64 .Fo DH_set_default_method
65 .Fa "const DH_METHOD *meth"
68 .Fo DH_get_default_method
74 .Fa "const DH_METHOD *meth"
87 specifies the functions that OpenSSL uses for Diffie-Hellman operations.
88 By modifying the method, alternative implementations such as hardware
89 accelerators may be used.
92 section for how these DH API functions are affected by the use of
96 Initially, the default
98 is the OpenSSL internal implementation as returned by
101 .Fn DH_set_default_method
104 the default method for all
106 structures created later.
108 This is true only whilst no
110 has been set as a default for DH, so this function is no longer
113 .Fn DH_get_default_method
114 returns a pointer to the current default
116 However, the meaningfulness of this result is dependent on whether the
118 API is being used, so this function is no longer recommended.
123 to perform all operations using the key
125 This will replace the
129 key and if the previous method was supplied by an
133 will be released during the change.
134 It is possible to have
136 keys that only work with certain
138 implementations (e.g. from an
140 module that supports embedded hardware-protected keys),
141 and in such cases attempting to change the
143 for the key can have unexpected results.
146 allocates and initializes a
150 will be used for the DH operations.
157 for DH operations is used and, if no default
162 .Fn DH_set_default_method
167 structure is defined as follows:
169 typedef struct dh_meth_st
171 /* name of the implementation */
174 /* generate private and public DH values for key agreement */
175 int (*generate_key)(DH *dh);
177 /* compute shared secret */
178 int (*compute_key)(unsigned char *key, BIGNUM *pub_key, DH *dh);
180 /* compute r = a ^ p mod m (May be NULL for some implementations) */
181 int (*bn_mod_exp)(DH *dh, BIGNUM *r, BIGNUM *a, const BIGNUM *p,
182 const BIGNUM *m, BN_CTX *ctx,
185 /* called at DH_new */
188 /* called at DH_free */
189 int (*finish)(DH *dh);
193 char *app_data; /* ?? */
200 .Fn DH_get_default_method
201 return pointers to the respective
205 returns non-zero if the provided
207 was successfully set as the method for
209 (including unloading the
211 handle if the previous method was supplied by an
217 and sets an error code that can be obtained by
219 if the allocation fails.
220 Otherwise it returns a pointer to the newly allocated structure.
224 .Fn DH_set_default_method ,
225 .Fn DH_get_default_method ,
230 were added in OpenSSL 0.9.4.
234 implementations are grouped together with other algorithmic APIs
235 (e.g. RSA_METHOD, EVP_CIPHER) in
240 is specified for DH functionality using an
242 API function, that will override any DH defaults set using the DH API
243 .Pq i.e. Fn DH_set_default_method .
246 API is the recommended way to control default implementations
247 for use in DH and other cryptographic algorithms.