1EVP_PKEY_CTX_CTRL(3) OpenSSL EVP_PKEY_CTX_CTRL(3)
2
3
4
6 EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str, EVP_PKEY_CTX_ctrl_uint64,
7 EVP_PKEY_CTX_md, EVP_PKEY_CTX_set_signature_md,
8 EVP_PKEY_CTX_get_signature_md, EVP_PKEY_CTX_set_mac_key,
9 EVP_PKEY_CTX_set_rsa_padding, EVP_PKEY_CTX_get_rsa_padding,
10 EVP_PKEY_CTX_set_rsa_pss_saltlen, EVP_PKEY_CTX_get_rsa_pss_saltlen,
11 EVP_PKEY_CTX_set_rsa_keygen_bits, EVP_PKEY_CTX_set_rsa_keygen_pubexp,
12 EVP_PKEY_CTX_set_rsa_keygen_primes, EVP_PKEY_CTX_set_rsa_mgf1_md,
13 EVP_PKEY_CTX_get_rsa_mgf1_md, EVP_PKEY_CTX_set_rsa_oaep_md,
14 EVP_PKEY_CTX_get_rsa_oaep_md, EVP_PKEY_CTX_set0_rsa_oaep_label,
15 EVP_PKEY_CTX_get0_rsa_oaep_label, EVP_PKEY_CTX_set_dsa_paramgen_bits,
16 EVP_PKEY_CTX_set_dsa_paramgen_q_bits, EVP_PKEY_CTX_set_dsa_paramgen_md,
17 EVP_PKEY_CTX_set_dh_paramgen_prime_len,
18 EVP_PKEY_CTX_set_dh_paramgen_subprime_len,
19 EVP_PKEY_CTX_set_dh_paramgen_generator,
20 EVP_PKEY_CTX_set_dh_paramgen_type, EVP_PKEY_CTX_set_dh_rfc5114,
21 EVP_PKEY_CTX_set_dhx_rfc5114, EVP_PKEY_CTX_set_dh_pad,
22 EVP_PKEY_CTX_set_dh_nid, EVP_PKEY_CTX_set_dh_kdf_type,
23 EVP_PKEY_CTX_get_dh_kdf_type, EVP_PKEY_CTX_set0_dh_kdf_oid,
24 EVP_PKEY_CTX_get0_dh_kdf_oid, EVP_PKEY_CTX_set_dh_kdf_md,
25 EVP_PKEY_CTX_get_dh_kdf_md, EVP_PKEY_CTX_set_dh_kdf_outlen,
26 EVP_PKEY_CTX_get_dh_kdf_outlen, EVP_PKEY_CTX_set0_dh_kdf_ukm,
27 EVP_PKEY_CTX_get0_dh_kdf_ukm, EVP_PKEY_CTX_set_ec_paramgen_curve_nid,
28 EVP_PKEY_CTX_set_ec_param_enc, EVP_PKEY_CTX_set_ecdh_cofactor_mode,
29 EVP_PKEY_CTX_get_ecdh_cofactor_mode, EVP_PKEY_CTX_set_ecdh_kdf_type,
30 EVP_PKEY_CTX_get_ecdh_kdf_type, EVP_PKEY_CTX_set_ecdh_kdf_md,
31 EVP_PKEY_CTX_get_ecdh_kdf_md, EVP_PKEY_CTX_set_ecdh_kdf_outlen,
32 EVP_PKEY_CTX_get_ecdh_kdf_outlen, EVP_PKEY_CTX_set0_ecdh_kdf_ukm,
33 EVP_PKEY_CTX_get0_ecdh_kdf_ukm, EVP_PKEY_CTX_set1_id,
34 EVP_PKEY_CTX_get1_id, EVP_PKEY_CTX_get1_id_len - algorithm specific
35 control operations
36
38 #include <openssl/evp.h>
39
40 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
41 int cmd, int p1, void *p2);
42 int EVP_PKEY_CTX_ctrl_uint64(EVP_PKEY_CTX *ctx, int keytype, int optype,
43 int cmd, uint64_t value);
44 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
45 const char *value);
46
47 int EVP_PKEY_CTX_md(EVP_PKEY_CTX *ctx, int optype, int cmd, const char *md);
48
49 int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
50 int EVP_PKEY_CTX_get_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD **pmd);
51
52 int EVP_PKEY_CTX_set_mac_key(EVP_PKEY_CTX *ctx, unsigned char *key, int len);
53
54 #include <openssl/rsa.h>
55
56 int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad);
57 int EVP_PKEY_CTX_get_rsa_padding(EVP_PKEY_CTX *ctx, int *pad);
58 int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len);
59 int EVP_PKEY_CTX_get_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int *len);
60 int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits);
61 int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
62 int EVP_PKEY_CTX_set_rsa_keygen_primes(EVP_PKEY_CTX *ctx, int primes);
63 int EVP_PKEY_CTX_set_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
64 int EVP_PKEY_CTX_get_rsa_mgf1_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
65 int EVP_PKEY_CTX_set_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
66 int EVP_PKEY_CTX_get_rsa_oaep_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
67 int EVP_PKEY_CTX_set0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char *label, int len);
68 int EVP_PKEY_CTX_get0_rsa_oaep_label(EVP_PKEY_CTX *ctx, unsigned char **label);
69
70 #include <openssl/dsa.h>
71
72 int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits);
73 int EVP_PKEY_CTX_set_dsa_paramgen_q_bits(EVP_PKEY_CTX *ctx, int qbits);
74 int EVP_PKEY_CTX_set_dsa_paramgen_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
75
76 #include <openssl/dh.h>
77
78 int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len);
79 int EVP_PKEY_CTX_set_dh_paramgen_subprime_len(EVP_PKEY_CTX *ctx, int len);
80 int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen);
81 int EVP_PKEY_CTX_set_dh_paramgen_type(EVP_PKEY_CTX *ctx, int type);
82 int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad);
83 int EVP_PKEY_CTX_set_dh_nid(EVP_PKEY_CTX *ctx, int nid);
84 int EVP_PKEY_CTX_set_dh_rfc5114(EVP_PKEY_CTX *ctx, int rfc5114);
85 int EVP_PKEY_CTX_set_dhx_rfc5114(EVP_PKEY_CTX *ctx, int rfc5114);
86 int EVP_PKEY_CTX_set_dh_kdf_type(EVP_PKEY_CTX *ctx, int kdf);
87 int EVP_PKEY_CTX_get_dh_kdf_type(EVP_PKEY_CTX *ctx);
88 int EVP_PKEY_CTX_set0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT *oid);
89 int EVP_PKEY_CTX_get0_dh_kdf_oid(EVP_PKEY_CTX *ctx, ASN1_OBJECT **oid);
90 int EVP_PKEY_CTX_set_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
91 int EVP_PKEY_CTX_get_dh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
92 int EVP_PKEY_CTX_set_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int len);
93 int EVP_PKEY_CTX_get_dh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len);
94 int EVP_PKEY_CTX_set0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len);
95 int EVP_PKEY_CTX_get0_dh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm);
96
97 #include <openssl/ec.h>
98
99 int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid);
100 int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc);
101 int EVP_PKEY_CTX_set_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx, int cofactor_mode);
102 int EVP_PKEY_CTX_get_ecdh_cofactor_mode(EVP_PKEY_CTX *ctx);
103 int EVP_PKEY_CTX_set_ecdh_kdf_type(EVP_PKEY_CTX *ctx, int kdf);
104 int EVP_PKEY_CTX_get_ecdh_kdf_type(EVP_PKEY_CTX *ctx);
105 int EVP_PKEY_CTX_set_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
106 int EVP_PKEY_CTX_get_ecdh_kdf_md(EVP_PKEY_CTX *ctx, const EVP_MD **md);
107 int EVP_PKEY_CTX_set_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int len);
108 int EVP_PKEY_CTX_get_ecdh_kdf_outlen(EVP_PKEY_CTX *ctx, int *len);
109 int EVP_PKEY_CTX_set0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char *ukm, int len);
110 int EVP_PKEY_CTX_get0_ecdh_kdf_ukm(EVP_PKEY_CTX *ctx, unsigned char **ukm);
111
112 int EVP_PKEY_CTX_set1_id(EVP_PKEY_CTX *ctx, void *id, size_t id_len);
113 int EVP_PKEY_CTX_get1_id(EVP_PKEY_CTX *ctx, void *id);
114 int EVP_PKEY_CTX_get1_id_len(EVP_PKEY_CTX *ctx, size_t *id_len);
115
117 The function EVP_PKEY_CTX_ctrl() sends a control operation to the
118 context ctx. The key type used must match keytype if it is not -1. The
119 parameter optype is a mask indicating which operations the control can
120 be applied to. The control command is indicated in cmd and any
121 additional arguments in p1 and p2.
122
123 For cmd = EVP_PKEY_CTRL_SET_MAC_KEY, p1 is the length of the MAC key,
124 and p2 is MAC key. This is used by Poly1305, SipHash, HMAC and CMAC.
125
126 Applications will not normally call EVP_PKEY_CTX_ctrl() directly but
127 will instead call one of the algorithm specific macros below.
128
129 The function EVP_PKEY_CTX_ctrl_uint64() is a wrapper that directly
130 passes a uint64 value as p2 to EVP_PKEY_CTX_ctrl().
131
132 The function EVP_PKEY_CTX_ctrl_str() allows an application to send an
133 algorithm specific control operation to a context ctx in string form.
134 This is intended to be used for options specified on the command line
135 or in text files. The commands supported are documented in the openssl
136 utility command line pages for the option -pkeyopt which is supported
137 by the pkeyutl, genpkey and req commands.
138
139 The function EVP_PKEY_CTX_md() sends a message digest control operation
140 to the context ctx. The message digest is specified by its name md.
141
142 All the remaining "functions" are implemented as macros.
143
144 The EVP_PKEY_CTX_set_signature_md() macro sets the message digest type
145 used in a signature. It can be used in the RSA, DSA and ECDSA
146 algorithms.
147
148 The EVP_PKEY_CTX_get_signature_md() macro gets the message digest type
149 used in a signature. It can be used in the RSA, DSA and ECDSA
150 algorithms.
151
152 Key generation typically involves setting up parameters to be used and
153 generating the private and public key data. Some algorithm
154 implementations allow private key data to be set explicitly using the
155 EVP_PKEY_CTX_set_mac_key() macro. In this case key generation is simply
156 the process of setting up the parameters for the key and then setting
157 the raw key data to the value explicitly provided by that macro.
158 Normally applications would call EVP_PKEY_new_raw_private_key(3) or
159 similar functions instead of this macro.
160
161 The EVP_PKEY_CTX_set_mac_key() macro can be used with any of the
162 algorithms supported by the EVP_PKEY_new_raw_private_key(3) function.
163
164 RSA parameters
165 The EVP_PKEY_CTX_set_rsa_padding() macro sets the RSA padding mode for
166 ctx. The pad parameter can take the value RSA_PKCS1_PADDING for PKCS#1
167 padding, RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no
168 padding, RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt
169 only), RSA_X931_PADDING for X9.31 padding (signature operations only)
170 and RSA_PKCS1_PSS_PADDING (sign and verify only).
171
172 Two RSA padding modes behave differently if
173 EVP_PKEY_CTX_set_signature_md() is used. If this macro is called for
174 PKCS#1 padding the plaintext buffer is an actual digest value and is
175 encapsulated in a DigestInfo structure according to PKCS#1 when signing
176 and this structure is expected (and stripped off) when verifying. If
177 this control is not used with RSA and PKCS#1 padding then the supplied
178 data is used directly and not encapsulated. In the case of X9.31
179 padding for RSA the algorithm identifier byte is added or checked and
180 removed if this control is called. If it is not called then the first
181 byte of the plaintext buffer is expected to be the algorithm identifier
182 byte.
183
184 The EVP_PKEY_CTX_get_rsa_padding() macro gets the RSA padding mode for
185 ctx.
186
187 The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the RSA PSS salt
188 length to len. As its name implies it is only supported for PSS
189 padding. Three special values are supported: RSA_PSS_SALTLEN_DIGEST
190 sets the salt length to the digest length, RSA_PSS_SALTLEN_MAX sets the
191 salt length to the maximum permissible value. When verifying
192 RSA_PSS_SALTLEN_AUTO causes the salt length to be automatically
193 determined based on the PSS block structure. If this macro is not
194 called maximum salt length is used when signing and auto detection when
195 verifying is used by default.
196
197 The EVP_PKEY_CTX_get_rsa_pss_saltlen() macro gets the RSA PSS salt
198 length for ctx. The padding mode must have been set to
199 RSA_PKCS1_PSS_PADDING.
200
201 The EVP_PKEY_CTX_set_rsa_keygen_bits() macro sets the RSA key length
202 for RSA key generation to bits. If not specified 1024 bits is used.
203
204 The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent
205 value for RSA key generation to pubexp. Currently it should be an odd
206 integer. The pubexp pointer is used internally by this function so it
207 should not be modified or freed after the call. If not specified 65537
208 is used.
209
210 The EVP_PKEY_CTX_set_rsa_keygen_primes() macro sets the number of
211 primes for RSA key generation to primes. If not specified 2 is used.
212
213 The EVP_PKEY_CTX_set_rsa_mgf1_md() macro sets the MGF1 digest for RSA
214 padding schemes to md. If not explicitly set the signing digest is
215 used. The padding mode must have been set to RSA_PKCS1_OAEP_PADDING or
216 RSA_PKCS1_PSS_PADDING.
217
218 The EVP_PKEY_CTX_get_rsa_mgf1_md() macro gets the MGF1 digest for ctx.
219 If not explicitly set the signing digest is used. The padding mode must
220 have been set to RSA_PKCS1_OAEP_PADDING or RSA_PKCS1_PSS_PADDING.
221
222 The EVP_PKEY_CTX_set_rsa_oaep_md() macro sets the message digest type
223 used in RSA OAEP to md. The padding mode must have been set to
224 RSA_PKCS1_OAEP_PADDING.
225
226 The EVP_PKEY_CTX_get_rsa_oaep_md() macro gets the message digest type
227 used in RSA OAEP to md. The padding mode must have been set to
228 RSA_PKCS1_OAEP_PADDING.
229
230 The EVP_PKEY_CTX_set0_rsa_oaep_label() macro sets the RSA OAEP label to
231 label and its length to len. If label is NULL or len is 0, the label is
232 cleared. The library takes ownership of the label so the caller should
233 not free the original memory pointed to by label. The padding mode
234 must have been set to RSA_PKCS1_OAEP_PADDING.
235
236 The EVP_PKEY_CTX_get0_rsa_oaep_label() macro gets the RSA OAEP label to
237 label. The return value is the label length. The padding mode must have
238 been set to RSA_PKCS1_OAEP_PADDING. The resulting pointer is owned by
239 the library and should not be freed by the caller.
240
241 DSA parameters
242 The EVP_PKEY_CTX_set_dsa_paramgen_bits() macro sets the number of bits
243 used for DSA parameter generation to nbits. If not specified, 1024 is
244 used.
245
246 The EVP_PKEY_CTX_set_dsa_paramgen_q_bits() macro sets the number of
247 bits in the subprime parameter q for DSA parameter generation to qbits.
248 If not specified, 160 is used. If a digest function is specified below,
249 this parameter is ignored and instead, the number of bits in q matches
250 the size of the digest.
251
252 The EVP_PKEY_CTX_set_dsa_paramgen_md() macro sets the digest function
253 used for DSA parameter generation to md. If not specified, one of
254 SHA-1, SHA-224, or SHA-256 is selected to match the bit length of q
255 above.
256
257 DH parameters
258 The EVP_PKEY_CTX_set_dh_paramgen_prime_len() macro sets the length of
259 the DH prime parameter p for DH parameter generation. If this macro is
260 not called then 1024 is used. Only accepts lengths greater than or
261 equal to 256.
262
263 The EVP_PKEY_CTX_set_dh_paramgen_subprime_len() macro sets the length
264 of the DH optional subprime parameter q for DH parameter generation.
265 The default is 256 if the prime is at least 2048 bits long or 160
266 otherwise. The DH paramgen type must have been set to x9.42.
267
268 The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to
269 gen for DH parameter generation. If not specified 2 is used.
270
271 The EVP_PKEY_CTX_set_dh_paramgen_type() macro sets the key type for DH
272 parameter generation. Use 0 for PKCS#3 DH and 1 for X9.42 DH. The
273 default is 0.
274
275 The EVP_PKEY_CTX_set_dh_pad() macro sets the DH padding mode. If pad is
276 1 the shared secret is padded with zeros up to the size of the DH prime
277 p. If pad is zero (the default) then no padding is performed.
278
279 EVP_PKEY_CTX_set_dh_nid() sets the DH parameters to values
280 corresponding to nid as defined in RFC7919 or RFC3526. The nid
281 parameter must be NID_ffdhe2048, NID_ffdhe3072, NID_ffdhe4096,
282 NID_ffdhe6144, NID_ffdhe8192, NID_modp_1536, NID_modp_2048,
283 NID_modp_3072, NID_modp_4096, NID_modp_6144, NID_modp_8192 or NID_undef
284 to clear the stored value. This macro can be called during parameter or
285 key generation. The nid parameter and the rfc5114 parameter are
286 mutually exclusive.
287
288 The EVP_PKEY_CTX_set_dh_rfc5114() and EVP_PKEY_CTX_set_dhx_rfc5114()
289 macros are synonymous. They set the DH parameters to the values defined
290 in RFC5114. The rfc5114 parameter must be 1, 2 or 3 corresponding to
291 RFC5114 sections 2.1, 2.2 and 2.3. or 0 to clear the stored value. This
292 macro can be called during parameter generation. The ctx must have a
293 key type of EVP_PKEY_DHX. The rfc5114 parameter and the nid parameter
294 are mutually exclusive.
295
296 DH key derivation function parameters
297 Note that all of the following functions require that the ctx parameter
298 has a private key type of EVP_PKEY_DHX. When using key derivation, the
299 output of EVP_PKEY_derive() is the output of the KDF instead of the DH
300 shared secret. The KDF output is typically used as a Key Encryption
301 Key (KEK) that in turn encrypts a Content Encryption Key (CEK).
302
303 The EVP_PKEY_CTX_set_dh_kdf_type() macro sets the key derivation
304 function type to kdf for DH key derivation. Possible values are
305 EVP_PKEY_DH_KDF_NONE and EVP_PKEY_DH_KDF_X9_42 which uses the key
306 derivation specified in RFC2631 (based on the keying algorithm
307 described in X9.42). When using key derivation, the kdf_oid, kdf_md and
308 kdf_outlen parameters must also be specified.
309
310 The EVP_PKEY_CTX_get_dh_kdf_type() macro gets the key derivation
311 function type for ctx used for DH key derivation. Possible values are
312 EVP_PKEY_DH_KDF_NONE and EVP_PKEY_DH_KDF_X9_42.
313
314 The EVP_PKEY_CTX_set0_dh_kdf_oid() macro sets the key derivation
315 function object identifier to oid for DH key derivation. This OID
316 should identify the algorithm to be used with the Content Encryption
317 Key. The library takes ownership of the object identifier so the
318 caller should not free the original memory pointed to by oid.
319
320 The EVP_PKEY_CTX_get0_dh_kdf_oid() macro gets the key derivation
321 function oid for ctx used for DH key derivation. The resulting pointer
322 is owned by the library and should not be freed by the caller.
323
324 The EVP_PKEY_CTX_set_dh_kdf_md() macro sets the key derivation function
325 message digest to md for DH key derivation. Note that RFC2631 specifies
326 that this digest should be SHA1 but OpenSSL tolerates other digests.
327
328 The EVP_PKEY_CTX_get_dh_kdf_md() macro gets the key derivation function
329 message digest for ctx used for DH key derivation.
330
331 The EVP_PKEY_CTX_set_dh_kdf_outlen() macro sets the key derivation
332 function output length to len for DH key derivation.
333
334 The EVP_PKEY_CTX_get_dh_kdf_outlen() macro gets the key derivation
335 function output length for ctx used for DH key derivation.
336
337 The EVP_PKEY_CTX_set0_dh_kdf_ukm() macro sets the user key material to
338 ukm and its length to len for DH key derivation. This parameter is
339 optional and corresponds to the partyAInfo field in RFC2631 terms. The
340 specification requires that it is 512 bits long but this is not
341 enforced by OpenSSL. The library takes ownership of the user key
342 material so the caller should not free the original memory pointed to
343 by ukm.
344
345 The EVP_PKEY_CTX_get0_dh_kdf_ukm() macro gets the user key material for
346 ctx. The return value is the user key material length. The resulting
347 pointer is owned by the library and should not be freed by the caller.
348
349 EC parameters
350 The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC
351 parameter generation to nid. For EC parameter generation this macro
352 must be called or an error occurs because there is no default curve.
353 This function can also be called to set the curve explicitly when
354 generating an EC key.
355
356 The EVP_PKEY_CTX_set_ec_param_enc() macro sets the EC parameter
357 encoding to param_enc when generating EC parameters or an EC key. The
358 encoding can be OPENSSL_EC_EXPLICIT_CURVE for explicit parameters (the
359 default in versions of OpenSSL before 1.1.0) or OPENSSL_EC_NAMED_CURVE
360 to use named curve form. For maximum compatibility the named curve
361 form should be used. Note: the OPENSSL_EC_NAMED_CURVE value was added
362 in OpenSSL 1.1.0; previous versions should use 0 instead.
363
364 ECDH parameters
365 The EVP_PKEY_CTX_set_ecdh_cofactor_mode() macro sets the cofactor mode
366 to cofactor_mode for ECDH key derivation. Possible values are 1 to
367 enable cofactor key derivation, 0 to disable it and -1 to clear the
368 stored cofactor mode and fallback to the private key cofactor mode.
369
370 The EVP_PKEY_CTX_get_ecdh_cofactor_mode() macro returns the cofactor
371 mode for ctx used for ECDH key derivation. Possible values are 1 when
372 cofactor key derivation is enabled and 0 otherwise.
373
374 ECDH key derivation function parameters
375 The EVP_PKEY_CTX_set_ecdh_kdf_type() macro sets the key derivation
376 function type to kdf for ECDH key derivation. Possible values are
377 EVP_PKEY_ECDH_KDF_NONE and EVP_PKEY_ECDH_KDF_X9_63 which uses the key
378 derivation specified in X9.63. When using key derivation, the kdf_md
379 and kdf_outlen parameters must also be specified.
380
381 The EVP_PKEY_CTX_get_ecdh_kdf_type() macro returns the key derivation
382 function type for ctx used for ECDH key derivation. Possible values are
383 EVP_PKEY_ECDH_KDF_NONE and EVP_PKEY_ECDH_KDF_X9_63.
384
385 The EVP_PKEY_CTX_set_ecdh_kdf_md() macro sets the key derivation
386 function message digest to md for ECDH key derivation. Note that X9.63
387 specifies that this digest should be SHA1 but OpenSSL tolerates other
388 digests.
389
390 The EVP_PKEY_CTX_get_ecdh_kdf_md() macro gets the key derivation
391 function message digest for ctx used for ECDH key derivation.
392
393 The EVP_PKEY_CTX_set_ecdh_kdf_outlen() macro sets the key derivation
394 function output length to len for ECDH key derivation.
395
396 The EVP_PKEY_CTX_get_ecdh_kdf_outlen() macro gets the key derivation
397 function output length for ctx used for ECDH key derivation.
398
399 The EVP_PKEY_CTX_set0_ecdh_kdf_ukm() macro sets the user key material
400 to ukm for ECDH key derivation. This parameter is optional and
401 corresponds to the shared info in X9.63 terms. The library takes
402 ownership of the user key material so the caller should not free the
403 original memory pointed to by ukm.
404
405 The EVP_PKEY_CTX_get0_ecdh_kdf_ukm() macro gets the user key material
406 for ctx. The return value is the user key material length. The
407 resulting pointer is owned by the library and should not be freed by
408 the caller.
409
410 Other parameters
411 The EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id() and
412 EVP_PKEY_CTX_get1_id_len() macros are used to manipulate the special
413 identifier field for specific signature algorithms such as SM2. The
414 EVP_PKEY_CTX_set1_id() sets an ID pointed by id with the length id_len
415 to the library. The library takes a copy of the id so that the caller
416 can safely free the original memory pointed to by id. The
417 EVP_PKEY_CTX_get1_id_len() macro returns the length of the ID set via a
418 previous call to EVP_PKEY_CTX_set1_id(). The length is usually used to
419 allocate adequate memory for further calls to EVP_PKEY_CTX_get1_id().
420 The EVP_PKEY_CTX_get1_id() macro returns the previously set ID value to
421 caller in id. The caller should allocate adequate memory space for the
422 id before calling EVP_PKEY_CTX_get1_id().
423
425 EVP_PKEY_CTX_ctrl() and its macros return a positive value for success
426 and 0 or a negative value for failure. In particular a return value of
427 -2 indicates the operation is not supported by the public key
428 algorithm.
429
431 EVP_PKEY_CTX_new(3), EVP_PKEY_encrypt(3), EVP_PKEY_decrypt(3),
432 EVP_PKEY_sign(3), EVP_PKEY_verify(3), EVP_PKEY_verify_recover(3),
433 EVP_PKEY_derive(3), EVP_PKEY_keygen(3)
434
436 The EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id() and
437 EVP_PKEY_CTX_get1_id_len() macros were added in 1.1.1, other functions
438 were added in OpenSSL 1.0.0.
439
441 Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
442
443 Licensed under the OpenSSL license (the "License"). You may not use
444 this file except in compliance with the License. You can obtain a copy
445 in the file LICENSE in the source distribution or at
446 <https://www.openssl.org/source/license.html>.
447
448
449
4501.1.1i 2021-01-26 EVP_PKEY_CTX_CTRL(3)