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