above.
=head2 DH parameters
The EVP_PKEY_CTX_set_dh_paramgen_prime_len() macro sets the length of the DH
prime parameter B for DH parameter generation. If this macro is not called
then 1024 is used. Only accepts lengths greater than or equal to 256.
The EVP_PKEY_CTX_set_dh_paramgen_subprime_len() macro sets the length of the DH
optional subprime parameter B for DH parameter generation. The default is
256 if the prime is at least 2048 bits long or 160 otherwise. The DH
paramgen type must have been set to x9.42.
The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to B
for DH parameter generation. If not specified 2 is used.
The EVP_PKEY_CTX_set_dh_paramgen_type() macro sets the key type for DH
parameter generation. Use 0 for PKCS#3 DH and 1 for X9.42 DH.
The default is 0.
The EVP_PKEY_CTX_set_dh_pad() macro sets the DH padding mode. If B is
1 the shared secret is padded with zeros up to the size of the DH prime B.
If B is zero (the default) then no padding is performed.
EVP_PKEY_CTX_set_dh_nid() sets the DH parameters to values corresponding to
B as defined in RFC7919. The B parameter must be B,
B, B, B, B
or B to clear the stored value. This macro can be called during
parameter or key generation.
The nid parameter and the rfc5114 parameter are mutually exclusive.
The EVP_PKEY_CTX_set_dh_rfc5114() and EVP_PKEY_CTX_set_dhx_rfc5114() macros are
synonymous. They set the DH parameters to the values defined in RFC5114. The
B parameter must be 1, 2 or 3 corresponding to RFC5114 sections
2.1, 2.2 and 2.3. or 0 to clear the stored value. This macro can be called
during parameter generation. The B must have a key type of
B.
The rfc5114 parameter and the nid parameter are mutually exclusive.
=head2 DH key derivation function parameters
Note that all of the following functions require that the B parameter has
a private key type of B. When using key derivation, the output of
EVP_PKEY_derive() is the output of the KDF instead of the DH shared secret.
The KDF output is typically used as a Key Encryption Key (KEK) that in turn
encrypts a Content Encryption Key (CEK).
The EVP_PKEY_CTX_set_dh_kdf_type() macro sets the key derivation function type
to B for DH key derivation. Possible values are B
and B which uses the key derivation specified in RFC2631
(based on the keying algorithm described in X9.42). When using key derivation,
the B, B and B parameters must also be specified.
The EVP_PKEY_CTX_get_dh_kdf_type() macro gets the key derivation function type
for B used for DH key derivation. Possible values are B
and B.
The EVP_PKEY_CTX_set0_dh_kdf_oid() macro sets the key derivation function
object identifier to B for DH key derivation. This OID should identify
the algorithm to be used with the Content Encryption Key.
The library takes ownership of the object identifier so the caller should not
free the original memory pointed to by B.
The EVP_PKEY_CTX_get0_dh_kdf_oid() macro gets the key derivation function oid
for B used for DH key derivation. The resulting pointer is owned by the
library and should not be freed by the caller.
The EVP_PKEY_CTX_set_dh_kdf_md() macro sets the key derivation function
message digest to B for DH key derivation. Note that RFC2631 specifies
that this digest should be SHA1 but OpenSSL tolerates other digests.
The EVP_PKEY_CTX_get_dh_kdf_md() macro gets the key derivation function
message digest for B used for DH key derivation.
The EVP_PKEY_CTX_set_dh_kdf_outlen() macro sets the key derivation function
output length to B for DH key derivation.
The EVP_PKEY_CTX_get_dh_kdf_outlen() macro gets the key derivation function
output length for B used for DH key derivation.
The EVP_PKEY_CTX_set0_dh_kdf_ukm() macro sets the user key material to
B and its length to B for DH key derivation. This parameter is optional
and corresponds to the partyAInfo field in RFC2631 terms. The specification
requires that it is 512 bits long but this is not enforced by OpenSSL.
The library takes ownership of the user key material so the caller should not
free the original memory pointed to by B.
The EVP_PKEY_CTX_get0_dh_kdf_ukm() macro gets the user key material for B.
The return value is the user key material length. The resulting pointer is owned
by the library and should not be freed by the caller.
=head2 EC parameters
The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter
generation to B. For EC parameter generation this macro must be called
or an error occurs because there is no default curve.
This function can also be called to set the curve explicitly when
generating an EC key.
The EVP_PKEY_CTX_set_ec_param_enc() macro sets the EC parameter encoding to
B when generating EC parameters or an EC key. The encoding can be
B for explicit parameters (the default in versions
of OpenSSL before 1.1.0) or B to use named curve form.
For maximum compatibility the named curve form should be used. Note: the
B value was added in OpenSSL 1.1.0; previous
versions should use 0 instead.
=head2 ECDH parameters
The EVP_PKEY_CTX_set_ecdh_cofactor_mode() macro sets the cofactor mode to
B for ECDH key derivation. Possible values are 1 to enable
cofactor key derivation, 0 to disable it and -1 to clear the stored cofactor
mode and fallback to the private key cofactor mode.
The EVP_PKEY_CTX_get_ecdh_cofactor_mode() macro returns the cofactor mode for
B used for ECDH key derivation. Possible values are 1 when cofactor key
derivation is enabled and 0 otherwise.
=head2 ECDH key derivation function parameters
The EVP_PKEY_CTX_set_ecdh_kdf_type() macro sets the key derivation function type
to B for ECDH key derivation. Possible values are B
and B which uses the key derivation specified in X9.63.
When using key derivation, the B and B parameters must
also be specified.
The EVP_PKEY_CTX_get_ecdh_kdf_type() macro returns the key derivation function
type for B used for ECDH key derivation. Possible values are
B and B.
The EVP_PKEY_CTX_set_ecdh_kdf_md() macro sets the key derivation function
message digest to B for ECDH key derivation. Note that X9.63 specifies
that this digest should be SHA1 but OpenSSL tolerates other digests.
The EVP_PKEY_CTX_get_ecdh_kdf_md() macro gets the key derivation function
message digest for B used for ECDH key derivation.
The EVP_PKEY_CTX_set_ecdh_kdf_outlen() macro sets the key derivation function
output length to B for ECDH key derivation.
The EVP_PKEY_CTX_get_ecdh_kdf_outlen() macro gets the key derivation function
output length for B used for ECDH key derivation.
The EVP_PKEY_CTX_set0_ecdh_kdf_ukm() macro sets the user key material to B
for ECDH key derivation. This parameter is optional and corresponds to the
shared info in X9.63 terms. The library takes ownership of the user key material
so the caller should not free the original memory pointed to by B.
The EVP_PKEY_CTX_get0_ecdh_kdf_ukm() macro gets the user key material for B.
The return value is the user key material length. The resulting pointer is owned
by the library and should not be freed by the caller.
=head2 Other parameters
The EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id() and EVP_PKEY_CTX_get1_id_len()
macros are used to manipulate the special identifier field for specific signature
algorithms such as SM2. The EVP_PKEY_CTX_set1_id() sets an ID pointed by B with
the length B to the library. The library takes a copy of the id so that
the caller can safely free the original memory pointed to by B. The
EVP_PKEY_CTX_get1_id_len() macro returns the length of the ID set via a previous
call to EVP_PKEY_CTX_set1_id(). The length is usually used to allocate adequate
memory for further calls to EVP_PKEY_CTX_get1_id(). The EVP_PKEY_CTX_get1_id()
macro returns the previously set ID value to caller in B. The caller should
allocate adequate memory space for the B before calling EVP_PKEY_CTX_get1_id().
=head1 RETURN VALUES
EVP_PKEY_CTX_ctrl() and its macros return a positive value for success and 0
or a negative value for failure. In particular a return value of -2
indicates the operation is not supported by the public key algorithm.
=head1 SEE ALSO
L,
L,
L,
L,
L,
L,
L,
L
=head1 HISTORY
The
EVP_PKEY_CTX_set1_id(), EVP_PKEY_CTX_get1_id() and EVP_PKEY_CTX_get1_id_len()
macros were added in 1.1.1, other functions were added in OpenSSL 1.0.0.
=head1 COPYRIGHT
Copyright 2006-2020 The OpenSSL Project Authors. All Rights Reserved.
Licensed under the OpenSSL license (the "License"). You may not use
this file except in compliance with the License. You can obtain a copy
in the file LICENSE in the source distribution or at
L.
=cut