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