1EVP_PKEY_CTX_ctrl(3) OpenSSL EVP_PKEY_CTX_ctrl(3)
2
3
4
6 EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str,
7 EVP_PKEY_get_default_digest_nid, EVP_PKEY_CTX_set_signature_md,
8 EVP_PKEY_CTX_set_rsa_padding, EVP_PKEY_CTX_set_rsa_pss_saltlen,
9 EVP_PKEY_CTX_set_rsa_rsa_keygen_bits,
10 EVP_PKEY_CTX_set_rsa_keygen_pubexp, EVP_PKEY_CTX_set_dsa_paramgen_bits,
11 EVP_PKEY_CTX_set_dh_paramgen_prime_len,
12 EVP_PKEY_CTX_set_dh_paramgen_generator,
13 EVP_PKEY_CTX_set_ec_paramgen_curve_nid - algorithm specific control
14 operations
15
17 #include <openssl/evp.h>
18
19 int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype,
20 int cmd, int p1, void *p2);
21 int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type,
22 const char *value);
23
24 int EVP_PKEY_get_default_digest_nid(EVP_PKEY *pkey, int *pnid);
25
26 #include <openssl/rsa.h>
27
28 int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md);
29
30 int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad);
31 int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len);
32 int EVP_PKEY_CTX_set_rsa_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits);
33 int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp);
34
35 #include <openssl/dsa.h>
36 int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits);
37
38 #include <openssl/dh.h>
39 int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len);
40 int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen);
41
42 #include <openssl/ec.h>
43 int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid);
44
46 The function EVP_PKEY_CTX_ctrl() sends a control operation to the
47 context ctx. The key type used must match keytype if it is not -1. The
48 parameter optype is a mask indicating which operations the control can
49 be applied to. The control command is indicated in cmd and any
50 additional arguments in p1 and p2.
51
52 Applications will not normally call EVP_PKEY_CTX_ctrl() directly but
53 will instead call one of the algorithm specific macros below.
54
55 The function EVP_PKEY_CTX_ctrl_str() allows an application to send an
56 algorithm specific control operation to a context ctx in string form.
57 This is intended to be used for options specified on the command line
58 or in text files. The commands supported are documented in the openssl
59 utility command line pages for the option -pkeyopt which is supported
60 by the pkeyutl, genpkey and req commands.
61
62 All the remaining "functions" are implemented as macros.
63
64 The EVP_PKEY_CTX_set_signature_md() macro sets the message digest type
65 used in a signature. It can be used with any public key algorithm
66 supporting signature operations.
67
68 The macro EVP_PKEY_CTX_set_rsa_padding() sets the RSA padding mode for
69 ctx. The pad parameter can take the value RSA_PKCS1_PADDING for PKCS#1
70 padding, RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no
71 padding, RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt
72 only), RSA_X931_PADDING for X9.31 padding (signature operations only)
73 and RSA_PKCS1_PSS_PADDING (sign and verify only).
74
75 Two RSA padding modes behave differently if
76 EVP_PKEY_CTX_set_signature_md() is used. If this macro is called for
77 PKCS#1 padding the plaintext buffer is an actual digest value and is
78 encapsulated in a DigestInfo structure according to PKCS#1 when signing
79 and this structure is expected (and stripped off) when verifying. If
80 this control is not used with RSA and PKCS#1 padding then the supplied
81 data is used directly and not encapsulated. In the case of X9.31
82 padding for RSA the algorithm identifier byte is added or checked and
83 removed if this control is called. If it is not called then the first
84 byte of the plaintext buffer is expected to be the algorithm identifier
85 byte.
86
87 The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the RSA PSS salt
88 length to len as its name implies it is only supported for PSS padding.
89 Two special values are supported: -1 sets the salt length to the digest
90 length. When signing -2 sets the salt length to the maximum permissible
91 value. When verifying -2 causes the salt length to be automatically
92 determined based on the PSS block structure. If this macro is not
93 called a salt length value of -2 is used by default.
94
95 The EVP_PKEY_CTX_set_rsa_rsa_keygen_bits() macro sets the RSA key
96 length for RSA key genration to bits. If not specified 1024 bits is
97 used.
98
99 The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent
100 value for RSA key generation to pubexp currently it should be an odd
101 integer. The pubexp pointer is used internally by this function so it
102 should not be modified or free after the call. If this macro is not
103 called then 65537 is used.
104
105 The macro EVP_PKEY_CTX_set_dsa_paramgen_bits() sets the number of bits
106 used for DSA parameter generation to bits. If not specified 1024 is
107 used.
108
109 The macro EVP_PKEY_CTX_set_dh_paramgen_prime_len() sets the length of
110 the DH prime parameter p for DH parameter generation. If this macro is
111 not called then 1024 is used.
112
113 The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to
114 gen for DH parameter generation. If not specified 2 is used.
115
116 The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC
117 parameter generation to nid. For EC parameter generation this macro
118 must be called or an error occurs because there is no default curve.
119
121 EVP_PKEY_CTX_ctrl() and its macros return a positive value for success
122 and 0 or a negative value for failure. In particular a return value of
123 -2 indicates the operation is not supported by the public key
124 algorithm.
125
127 EVP_PKEY_CTX_new(3), EVP_PKEY_encrypt(3), EVP_PKEY_decrypt(3),
128 EVP_PKEY_sign(3), EVP_PKEY_verify(3), EVP_PKEY_verify_recover(3),
129 EVP_PKEY_derive(3) EVP_PKEY_keygen(3)
130
132 These functions were first added to OpenSSL 1.0.0.
133
134
135
1361.0.2o 2020-08-01 EVP_PKEY_CTX_ctrl(3)