Add support for -1, -2 salt lengths for PSS only keys.
[openssl.git] / doc / man3 / EVP_PKEY_CTX_set_rsa_pss_keygen_md.pod
1 =pod
2
3 =head1 NAME
4
5 EVP_PKEY_CTX_set_rsa_pss_keygen_md, EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md,
6 EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen - RSA PSS signature algorithm
7
8 =head1 SYNOPSIS
9
10  #include <openssl/rsa.h>
11
12  int EVP_PKEY_CTX_set_rsa_pss_keygen_md(EVP_PKEY_CTX *pctx,
13                                         const EVP_MD *md);
14  int EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md(EVP_PKEY_CTX *pctx,
15                                              const EVP_MD *md);
16  int EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen(EVP_PKEY_CTX *pctx,
17                                              int saltlen);
18
19 =head1 DESCRIPTION
20
21 The B<EVP_PKEY_RSA_PSS> algorithm implements the RSA PSS signature algorithm.
22 It is a restricted version of the RSA algorithm which only supports signing,
23 verification and key generation using PSS padding modes with optional
24 parameter restrictions.
25
26 It has associated private key and public key formats.
27
28 This algorithm shares several control operations with the B<RSA> algorithm
29 but with some restrictions described below.
30
31 =head1 SIGNING AND VERIFICATION
32
33 Siging and verification is similar to the B<RSA> algorithm except the
34 padding mode is always PSS. If the key in use has parameter restrictions then
35 the corresponding signature parameters are set to the restrictions:
36 for example, if the key can only be used with digest SHA256, MGF1 SHA256
37 and minimum salt length 32 then the digest, MGF1 digest and salt length
38 will be set to SHA256, SHA256 and 32 respectively.
39
40 The macro EVP_PKEY_CTX_set_rsa_padding() is supported but an error is
41 returned if an attempt is made to set the padding mode to anything other
42 than B<PSS>. It is otherwise similar to the B<RSA> version.
43
44 The EVP_PKEY_CTX_set_rsa_pss_saltlen() macro is used to set the salt length.
45 If the key has usage restrictions then an error is returned if an attempt is
46 made to set the salt length below the minimum value. It is otherwise similar
47 to the B<RSA> operation except detection of the salt length (using -2) is
48 not supported for verification if the key has usage restrictions.
49
50 The EVP_PKEY_CTX_set_signature_md() and EVP_PKEY_CTX_set_rsa_mgf1_md() macros
51 are used to set the digest and MGF1 algorithms respectively. If the key has
52 usage restrictions then an error is returned if an attempt is made to set the
53 digest to anything other than the restricted value. Otherwise these are
54 similar to the B<RSA> versions.
55
56 =head1 KEY GENERATION
57
58 As with RSA key generation the EVP_PKEY_CTX_set_rsa_rsa_keygen_bits()
59 and EVP_PKEY_CTX_set_rsa_keygen_pubexp() macros are supported for RSA PSS:
60 they have exactly the same meaning as for the RSA algorithm.
61
62 Optional parameter restrictions can be specified when generating a PSS key. By
63 default no parameter restrictions are placed on the generated key. If any
64 restrictions are set (using the macros described below) then B<all> parameters
65 are restricted. For example, setting a minimum salt length also restricts the
66 digest and MGF1 algorithms. If any restrictions are in place then they are
67 reflected in the corresponding parameters of the public key when (for example)
68 a certificate request is signed.
69
70 EVP_PKEY_CTX_set_rsa_pss_keygen_md() restricts the digest algorithm the
71 generated key can use to B<md>.
72
73 EVP_PKEY_CTX_set_rsa_pss_keygen_mgf1_md() restricts the MGF1 algorithm the
74 generated key can use to B<md>.
75
76 EVP_PKEY_CTX_set_rsa_pss_keygen_saltlen() restricts the minimum salt length
77 to B<saltlen>.
78
79 =head1 RETURN VALUES
80
81 All these functions return 1 for success and 0 or a negative value for failure.
82 In particular a return value of -2 indicates the operation is not supported by
83 the public key algorithm.
84
85 =head1 SEE ALSO
86
87 L<EVP_PKEY_CTX_new(3)>,
88 L<EVP_PKEY_CTX_ctrl_str(3)>,
89 L<EVP_PKEY_derive(3)>
90
91 =head1 COPYRIGHT
92
93 Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
94
95 Licensed under the OpenSSL license (the "License").  You may not use
96 this file except in compliance with the License.  You can obtain a copy
97 in the file LICENSE in the source distribution or at
98 L<https://www.openssl.org/source/license.html>.
99
100 =cut