]>
Commit | Line | Data |
---|---|---|
90ccf05f DSH |
1 | =pod |
2 | ||
3 | =head1 NAME | |
4 | ||
e03af178 | 5 | EVP_PKEY_CTX_ctrl, EVP_PKEY_CTX_ctrl_str, |
aafbe1cc | 6 | EVP_PKEY_CTX_set_signature_md, EVP_PKEY_CTX_set_rsa_padding, |
1722496f | 7 | EVP_PKEY_CTX_set_rsa_pss_saltlen, EVP_PKEY_CTX_set_rsa_keygen_bits, |
aafbe1cc MC |
8 | EVP_PKEY_CTX_set_rsa_keygen_pubexp, EVP_PKEY_CTX_set_dsa_paramgen_bits, |
9 | EVP_PKEY_CTX_set_dh_paramgen_prime_len, | |
10 | EVP_PKEY_CTX_set_dh_paramgen_generator, | |
5368bf05 | 11 | EVP_PKEY_CTX_set_dh_pad, EVP_PKEY_CTX_set_dh_nid, |
146ca72c DSH |
12 | EVP_PKEY_CTX_set_ec_paramgen_curve_nid, |
13 | EVP_PKEY_CTX_set_ec_param_enc - algorithm specific control operations | |
90ccf05f DSH |
14 | |
15 | =head1 SYNOPSIS | |
16 | ||
17 | #include <openssl/evp.h> | |
18 | ||
19 | int EVP_PKEY_CTX_ctrl(EVP_PKEY_CTX *ctx, int keytype, int optype, | |
e9b77246 | 20 | int cmd, int p1, void *p2); |
90ccf05f | 21 | int EVP_PKEY_CTX_ctrl_str(EVP_PKEY_CTX *ctx, const char *type, |
e9b77246 | 22 | const char *value); |
90ccf05f | 23 | |
90ccf05f DSH |
24 | #include <openssl/rsa.h> |
25 | ||
26 | int EVP_PKEY_CTX_set_signature_md(EVP_PKEY_CTX *ctx, const EVP_MD *md); | |
27 | ||
28 | int EVP_PKEY_CTX_set_rsa_padding(EVP_PKEY_CTX *ctx, int pad); | |
29 | int EVP_PKEY_CTX_set_rsa_pss_saltlen(EVP_PKEY_CTX *ctx, int len); | |
1722496f | 30 | int EVP_PKEY_CTX_set_rsa_keygen_bits(EVP_PKEY_CTX *ctx, int mbits); |
90ccf05f DSH |
31 | int EVP_PKEY_CTX_set_rsa_keygen_pubexp(EVP_PKEY_CTX *ctx, BIGNUM *pubexp); |
32 | ||
33 | #include <openssl/dsa.h> | |
34 | int EVP_PKEY_CTX_set_dsa_paramgen_bits(EVP_PKEY_CTX *ctx, int nbits); | |
35 | ||
36 | #include <openssl/dh.h> | |
37 | int EVP_PKEY_CTX_set_dh_paramgen_prime_len(EVP_PKEY_CTX *ctx, int len); | |
38 | int EVP_PKEY_CTX_set_dh_paramgen_generator(EVP_PKEY_CTX *ctx, int gen); | |
5368bf05 DSH |
39 | int EVP_PKEY_CTX_set_dh_pad(EVP_PKEY_CTX *ctx, int pad); |
40 | int EVP_PKEY_CTX_set_dh_nid(EVP_PKEY_CTX *ctx, int nid); | |
90ccf05f DSH |
41 | |
42 | #include <openssl/ec.h> | |
43 | int EVP_PKEY_CTX_set_ec_paramgen_curve_nid(EVP_PKEY_CTX *ctx, int nid); | |
146ca72c | 44 | int EVP_PKEY_CTX_set_ec_param_enc(EVP_PKEY_CTX *ctx, int param_enc); |
90ccf05f DSH |
45 | |
46 | =head1 DESCRIPTION | |
47 | ||
48 | The function EVP_PKEY_CTX_ctrl() sends a control operation to the context | |
f0288f05 | 49 | B<ctx>. The key type used must match B<keytype> if it is not -1. The parameter |
90ccf05f DSH |
50 | B<optype> is a mask indicating which operations the control can be applied to. |
51 | The control command is indicated in B<cmd> and any additional arguments in | |
52 | B<p1> and B<p2>. | |
53 | ||
52ad5b60 | 54 | For B<cmd> = B<EVP_PKEY_CTRL_SET_MAC_KEY>, B<p1> is the length of the MAC key, |
3f5616d7 | 55 | and B<p2> is MAC key. This is used by Poly1305, SipHash, HMAC and CMAC. |
52ad5b60 | 56 | |
90ccf05f DSH |
57 | Applications will not normally call EVP_PKEY_CTX_ctrl() directly but will |
58 | instead call one of the algorithm specific macros below. | |
59 | ||
aafbe1cc | 60 | The function EVP_PKEY_CTX_ctrl_str() allows an application to send an algorithm |
90ccf05f DSH |
61 | specific control operation to a context B<ctx> in string form. This is |
62 | intended to be used for options specified on the command line or in text | |
63 | files. The commands supported are documented in the openssl utility | |
64 | command line pages for the option B<-pkeyopt> which is supported by the | |
65 | B<pkeyutl>, B<genpkey> and B<req> commands. | |
66 | ||
67 | All the remaining "functions" are implemented as macros. | |
68 | ||
69 | The EVP_PKEY_CTX_set_signature_md() macro sets the message digest type used | |
70 | in a signature. It can be used with any public key algorithm supporting | |
71 | signature operations. | |
72 | ||
73 | The macro EVP_PKEY_CTX_set_rsa_padding() sets the RSA padding mode for B<ctx>. | |
74 | The B<pad> parameter can take the value RSA_PKCS1_PADDING for PKCS#1 padding, | |
75 | RSA_SSLV23_PADDING for SSLv23 padding, RSA_NO_PADDING for no padding, | |
76 | RSA_PKCS1_OAEP_PADDING for OAEP padding (encrypt and decrypt only), | |
146ca72c | 77 | RSA_X931_PADDING for X9.31 padding (signature operations only) and |
90ccf05f DSH |
78 | RSA_PKCS1_PSS_PADDING (sign and verify only). |
79 | ||
80 | Two RSA padding modes behave differently if EVP_PKEY_CTX_set_signature_md() | |
81 | is used. If this macro is called for PKCS#1 padding the plaintext buffer is | |
82 | an actual digest value and is encapsulated in a DigestInfo structure according | |
83 | to PKCS#1 when signing and this structure is expected (and stripped off) when | |
84 | verifying. If this control is not used with RSA and PKCS#1 padding then the | |
85 | supplied data is used directly and not encapsulated. In the case of X9.31 | |
86 | padding for RSA the algorithm identifier byte is added or checked and removed | |
9d22666e F |
87 | if this control is called. If it is not called then the first byte of the plaintext |
88 | buffer is expected to be the algorithm identifier byte. | |
90ccf05f DSH |
89 | |
90 | The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro sets the RSA PSS salt length to | |
137096a7 DSH |
91 | B<len> as its name implies it is only supported for PSS padding. Three special |
92 | values are supported: RSA_PSS_SALTLEN_DIGEST sets the salt length to the | |
93 | digest length, RSA_PSS_SALTLEN_MAX sets the salt length to the maximum | |
94 | permissible value. When verifying RSA_PSS_SALTLEN_AUTO causes the salt length | |
95 | to be automatically determined based on the B<PSS> block structure. If this | |
96 | macro is not called maximum salt length is used when signing and auto detection | |
97 | when verifying is used by default. | |
90ccf05f | 98 | |
1722496f | 99 | The EVP_PKEY_CTX_set_rsa_keygen_bits() macro sets the RSA key length for |
186bb907 | 100 | RSA key generation to B<bits>. If not specified 1024 bits is used. |
90ccf05f DSH |
101 | |
102 | The EVP_PKEY_CTX_set_rsa_keygen_pubexp() macro sets the public exponent value | |
103 | for RSA key generation to B<pubexp> currently it should be an odd integer. The | |
146ca72c | 104 | B<pubexp> pointer is used internally by this function so it should not be |
90ccf05f DSH |
105 | modified or free after the call. If this macro is not called then 65537 is used. |
106 | ||
107 | The macro EVP_PKEY_CTX_set_dsa_paramgen_bits() sets the number of bits used | |
108 | for DSA parameter generation to B<bits>. If not specified 1024 is used. | |
109 | ||
110 | The macro EVP_PKEY_CTX_set_dh_paramgen_prime_len() sets the length of the DH | |
111 | prime parameter B<p> for DH parameter generation. If this macro is not called | |
112 | then 1024 is used. | |
113 | ||
114 | The EVP_PKEY_CTX_set_dh_paramgen_generator() macro sets DH generator to B<gen> | |
115 | for DH parameter generation. If not specified 2 is used. | |
116 | ||
5368bf05 DSH |
117 | The EVP_PKEY_CTX_set_dh_pad() macro sets the DH padding mode. If B<pad> is |
118 | 1 the shared secret is padded with zeroes up to the size of the DH prime B<p>. | |
119 | If B<pad> is zero (the default) then no padding is performed. | |
120 | ||
121 | EVP_PKEY_CTX_set_dh_nid() sets the DH parameters to values corresponding to | |
122 | B<nid>. The B<nid> parameter must be B<NID_ffdhe2048>, B<NID_ffdhe3072>, | |
123 | B<NID_ffdhe4096>, B<NID_ffdhe6144> or B<NID_ffdhe8192>. This macro can be | |
124 | called during parameter or key generation. | |
125 | ||
90ccf05f DSH |
126 | The EVP_PKEY_CTX_set_ec_paramgen_curve_nid() sets the EC curve for EC parameter |
127 | generation to B<nid>. For EC parameter generation this macro must be called | |
a528d4f0 RS |
128 | or an error occurs because there is no default curve. |
129 | This function can also be called to set the curve explicitly when | |
146ca72c DSH |
130 | generating an EC key. |
131 | ||
132 | The EVP_PKEY_CTX_set_ec_param_enc() sets the EC parameter encoding to | |
133 | B<param_enc> when generating EC parameters or an EC key. The encoding can be | |
134 | B<OPENSSL_EC_EXPLICIT_CURVE> for explicit parameters (the default in versions | |
135 | of OpenSSL before 1.1.0) or B<OPENSSL_EC_NAMED_CURVE> to use named curve form. | |
136 | For maximum compatibility the named curve form should be used. Note: the | |
a528d4f0 | 137 | B<OPENSSL_EC_NAMED_CURVE> value was only added to OpenSSL 1.1.0; previous |
146ca72c | 138 | versions should use 0 instead. |
90ccf05f DSH |
139 | |
140 | =head1 RETURN VALUES | |
141 | ||
142 | EVP_PKEY_CTX_ctrl() and its macros return a positive value for success and 0 | |
143 | or a negative value for failure. In particular a return value of -2 | |
144 | indicates the operation is not supported by the public key algorithm. | |
145 | ||
146 | =head1 SEE ALSO | |
147 | ||
9b86974e RS |
148 | L<EVP_PKEY_CTX_new(3)>, |
149 | L<EVP_PKEY_encrypt(3)>, | |
150 | L<EVP_PKEY_decrypt(3)>, | |
151 | L<EVP_PKEY_sign(3)>, | |
152 | L<EVP_PKEY_verify(3)>, | |
153 | L<EVP_PKEY_verify_recover(3)>, | |
154 | L<EVP_PKEY_derive(3)> | |
155 | L<EVP_PKEY_keygen(3)> | |
90ccf05f DSH |
156 | |
157 | =head1 HISTORY | |
158 | ||
fb552ac6 | 159 | These functions were first added to OpenSSL 1.0.0. |
90ccf05f | 160 | |
e2f92610 RS |
161 | =head1 COPYRIGHT |
162 | ||
163 | Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. | |
164 | ||
165 | Licensed under the OpenSSL license (the "License"). You may not use | |
166 | this file except in compliance with the License. You can obtain a copy | |
167 | in the file LICENSE in the source distribution or at | |
168 | L<https://www.openssl.org/source/license.html>. | |
169 | ||
170 | =cut |