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