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