summaryrefslogtreecommitdiff
path: root/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
diff options
context:
space:
mode:
authorschwarze <>2019-11-01 12:02:58 +0000
committerschwarze <>2019-11-01 12:02:58 +0000
commitc486619b21445153ea79c808f81279ffd3efde9c (patch)
tree1f232c188891f67b6d0a83b05dded6fdc2d84581 /src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
parent06b54e9217af744c680ff812191733948cfafa40 (diff)
downloadopenbsd-c486619b21445153ea79c808f81279ffd3efde9c.tar.gz
openbsd-c486619b21445153ea79c808f81279ffd3efde9c.tar.bz2
openbsd-c486619b21445153ea79c808f81279ffd3efde9c.zip
The EVP_PKEY_CTX_ctrl(3) manual page requires additions for RSA-PSS
but it is growing to excessive size, so split out RSA_pkey_ctx_ctrl(3).
Diffstat (limited to 'src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3')
-rw-r--r--src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3346
1 files changed, 346 insertions, 0 deletions
diff --git a/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3 b/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
new file mode 100644
index 0000000000..866c63ad81
--- /dev/null
+++ b/src/lib/libcrypto/man/RSA_pkey_ctx_ctrl.3
@@ -0,0 +1,346 @@
1.\" $OpenBSD: RSA_pkey_ctx_ctrl.3,v 1.1 2019/11/01 12:02:58 schwarze Exp $
2.\" full merge up to:
3.\" OpenSSL man3/EVP_PKEY_CTX_ctrl 99d63d46 Oct 26 13:56:48 2016 -0400
4.\" selective merge up to:
5.\" OpenSSL man3/EVP_PKEY_CTX_ctrl df75c2b f Dec 9 01:02:36 2018 +0100
6.\"
7.\" This file was written by Dr. Stephen Henson <steve@openssl.org>
8.\" and Antoine Salon <asalon@vmware.com>.
9.\" Copyright (c) 2006, 2009, 2013, 2014, 2015, 2018 The OpenSSL Project.
10.\" All rights reserved.
11.\"
12.\" Redistribution and use in source and binary forms, with or without
13.\" modification, are permitted provided that the following conditions
14.\" are met:
15.\"
16.\" 1. Redistributions of source code must retain the above copyright
17.\" notice, this list of conditions and the following disclaimer.
18.\"
19.\" 2. Redistributions in binary form must reproduce the above copyright
20.\" notice, this list of conditions and the following disclaimer in
21.\" the documentation and/or other materials provided with the
22.\" distribution.
23.\"
24.\" 3. All advertising materials mentioning features or use of this
25.\" software must display the following acknowledgment:
26.\" "This product includes software developed by the OpenSSL Project
27.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
28.\"
29.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
30.\" endorse or promote products derived from this software without
31.\" prior written permission. For written permission, please contact
32.\" openssl-core@openssl.org.
33.\"
34.\" 5. Products derived from this software may not be called "OpenSSL"
35.\" nor may "OpenSSL" appear in their names without prior written
36.\" permission of the OpenSSL Project.
37.\"
38.\" 6. Redistributions of any form whatsoever must retain the following
39.\" acknowledgment:
40.\" "This product includes software developed by the OpenSSL Project
41.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
42.\"
43.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
44.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
46.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
47.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
48.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
49.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
50.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54.\" OF THE POSSIBILITY OF SUCH DAMAGE.
55.\"
56.Dd $Mdocdate: November 1 2019 $
57.Dt RSA_PKEY_CTX_CTRL 3
58.Os
59.Sh NAME
60.Nm RSA_pkey_ctx_ctrl ,
61.Nm EVP_PKEY_CTX_set_rsa_padding ,
62.Nm EVP_PKEY_CTX_get_rsa_padding ,
63.Nm EVP_PKEY_CTX_set_rsa_pss_saltlen ,
64.Nm EVP_PKEY_CTX_get_rsa_pss_saltlen ,
65.Nm EVP_PKEY_CTX_set_rsa_keygen_bits ,
66.Nm EVP_PKEY_CTX_set_rsa_keygen_pubexp ,
67.Nm EVP_PKEY_CTX_set_rsa_mgf1_md ,
68.Nm EVP_PKEY_CTX_get_rsa_mgf1_md ,
69.Nm EVP_PKEY_CTX_set_rsa_oaep_md ,
70.Nm EVP_PKEY_CTX_get_rsa_oaep_md ,
71.Nm EVP_PKEY_CTX_set0_rsa_oaep_label ,
72.Nm EVP_PKEY_CTX_get0_rsa_oaep_label
73.Nd RSA private key control operations
74.Sh SYNOPSIS
75.In openssl/rsa.h
76.Ft int
77.Fo RSA_pkey_ctx_ctrl
78.Fa "EVP_PKEY_CTX *ctx"
79.Fa "int optype"
80.Fa "int cmd"
81.Fa "int p1"
82.Fa "void *p2"
83.Fc
84.Ft int
85.Fo EVP_PKEY_CTX_set_rsa_padding
86.Fa "EVP_PKEY_CTX *ctx"
87.Fa "int pad"
88.Fc
89.Ft int
90.Fo EVP_PKEY_CTX_get_rsa_padding
91.Fa "EVP_PKEY_CTX *ctx"
92.Fa "int *ppad"
93.Fc
94.Ft int
95.Fo EVP_PKEY_CTX_set_rsa_pss_saltlen
96.Fa "EVP_PKEY_CTX *ctx"
97.Fa "int len"
98.Fc
99.Ft int
100.Fo EVP_PKEY_CTX_get_rsa_pss_saltlen
101.Fa "EVP_PKEY_CTX *ctx"
102.Fa "int *plen"
103.Fc
104.Ft int
105.Fo EVP_PKEY_CTX_set_rsa_keygen_bits
106.Fa "EVP_PKEY_CTX *ctx"
107.Fa "int mbits"
108.Fc
109.Ft int
110.Fo EVP_PKEY_CTX_set_rsa_keygen_pubexp
111.Fa "EVP_PKEY_CTX *ctx"
112.Fa "BIGNUM *pubexp"
113.Fc
114.Ft int
115.Fo EVP_PKEY_CTX_set_rsa_mgf1_md
116.Fa "EVP_PKEY_CTX *ctx"
117.Fa "const EVP_MD *md"
118.Fc
119.Ft int
120.Fo EVP_PKEY_CTX_get_rsa_mgf1_md
121.Fa "EVP_PKEY_CTX *ctx"
122.Fa "const EVP_MD **pmd"
123.Fc
124.Ft int
125.Fo EVP_PKEY_CTX_set_rsa_oaep_md
126.Fa "EVP_PKEY_CTX *ctx"
127.Fa "const EVP_MD *md"
128.Fc
129.Ft int
130.Fo EVP_PKEY_CTX_get_rsa_oaep_md
131.Fa "EVP_PKEY_CTX *ctx"
132.Fa "const EVP_MD **pmd"
133.Fc
134.Ft int
135.Fo EVP_PKEY_CTX_set0_rsa_oaep_label
136.Fa "EVP_PKEY_CTX *ctx"
137.Fa "unsigned char *label"
138.Fa "int len"
139.Fc
140.Ft int
141.Fo EVP_PKEY_CTX_get0_rsa_oaep_label
142.Fa "EVP_PKEY_CTX *ctx"
143.Fa "unsigned char **plabel"
144.Fc
145.Sh DESCRIPTION
146The function
147.Fn RSA_pkey_ctx_ctrl
148is a shallow wrapper around
149.Xr EVP_PKEY_CTX_ctrl 3
150which only succeeds if
151.Fa ctx
152matches either
153.Dv EVP_PKEY_RSA
154or
155.Dv EVP_PKEY_RSA_PSS .
156.Pp
157All the remaining "functions" are implemented as macros.
158.Pp
159The
160.Fn EVP_PKEY_CTX_set_rsa_padding
161macro sets the RSA padding mode for
162.Fa ctx .
163The
164.Fa pad
165parameter can take the value
166.Dv RSA_PKCS1_PADDING
167for PKCS#1 padding,
168.Dv RSA_NO_PADDING
169for no padding,
170.Dv RSA_PKCS1_OAEP_PADDING
171for OAEP padding (encrypt and decrypt only),
172.Dv RSA_X931_PADDING
173for X9.31 padding (signature operations only) and
174.Dv RSA_PKCS1_PSS_PADDING
175(sign and verify only).
176.Pp
177Two RSA padding modes behave differently if
178.Fn EVP_PKEY_CTX_set_signature_md
179is used.
180If this macro is called for PKCS#1 padding, the plaintext buffer is an
181actual digest value and is encapsulated in a
182.Vt DigestInfo
183structure according to PKCS#1 when signing and this structure is
184expected (and stripped off) when verifying.
185If this control is not used with RSA and PKCS#1 padding then the
186supplied data is used directly and not encapsulated.
187In the case of X9.31 padding for RSA the algorithm identifier byte is
188added or checked and removed if this control is called.
189If it is not called then the first byte of the plaintext buffer is
190expected to be the algorithm identifier byte.
191.Pp
192The
193.Fn EVP_PKEY_CTX_get_rsa_padding
194macro retrieves the RSA padding mode for
195.Fa ctx .
196.Pp
197The
198.Fn EVP_PKEY_CTX_set_rsa_pss_saltlen
199macro sets the RSA PSS salt length to
200.Fa len .
201As its name implies, it is only supported for PSS padding.
202Two special values are supported: -1 sets the salt length to the digest
203length.
204When signing -2 sets the salt length to the maximum permissible value.
205When verifying -2 causes the salt length to be automatically determined
206based on the PSS block structure.
207If this macro is not called a salt length value of -2 is used by
208default.
209.Pp
210The
211.Fn EVP_PKEY_CTX_get_rsa_pss_saltlen
212macro retrieves the RSA PSS salt length for
213.Fa ctx .
214The padding mode must have been set to
215.Dv RSA_PKCS1_PSS_PADDING .
216.Pp
217The
218.Fn EVP_PKEY_CTX_set_rsa_keygen_bits
219macro sets the RSA key length for RSA key generation to
220.Fa mbits .
221The smallest supported value is 512 bits.
222If not specified, 1024 bits is used.
223.Pp
224The
225.Fn EVP_PKEY_CTX_set_rsa_keygen_pubexp
226macro sets the public exponent value for RSA key generation to
227.Fa pubexp .
228Currently, it should be an odd integer.
229The
230.Fa pubexp
231pointer is used internally by this function, so it should not be modified
232or freed after the call.
233If this macro is not called, then 65537 is used.
234.Pp
235The
236.Fn EVP_PKEY_CTX_set_rsa_mgf1_md
237macro sets the MGF1 digest for RSA padding schemes to
238.Fa md .
239Unless explicitly specified, the signing digest is used.
240The padding mode must have been set to
241.Dv RSA_PKCS1_OAEP_PADDING
242or
243.Dv RSA_PKCS1_PSS_PADDING .
244.Pp
245The
246.Fn EVP_PKEY_CTX_get_rsa_mgf1_md
247macro retrieves the MGF1 digest for
248.Fa ctx .
249Unless explicitly specified, the signing digest is used.
250The padding mode must have been set to
251.Dv RSA_PKCS1_OAEP_PADDING
252or
253.Dv RSA_PKCS1_PSS_PADDING .
254.Pp
255The
256.Fn EVP_PKEY_CTX_set_rsa_oaep_md
257macro sets the message digest type used in RSA OAEP to
258.Fa md .
259The padding mode must have been set to
260.Dv RSA_PKCS1_OAEP_PADDING .
261.Pp
262The
263.Fn EVP_PKEY_CTX_get_rsa_oaep_md
264macro gets the message digest type used in RSA OAEP to
265.Pf * Fa md .
266The padding mode must have been set to
267.Dv RSA_PKCS1_OAEP_PADDING .
268.Pp
269The
270.Fn EVP_PKEY_CTX_set0_rsa_oaep_label
271macro sets the RSA OAEP label to
272.Fa label
273and its length to
274.Fa len .
275If
276.Fa label
277is
278.Dv NULL
279or
280.Fa len
281is 0, the label is cleared.
282The library takes ownership of the label so the caller should not
283free the original memory pointed to by
284.Fa label .
285The padding mode must have been set to
286.Dv RSA_PKCS1_OAEP_PADDING .
287.Pp
288The
289.Fn EVP_PKEY_CTX_get0_rsa_oaep_label
290macro gets the RSA OAEP label to
291.Pf * Fa plabel .
292The return value is the label length.
293The padding mode must have been set to
294.Dv RSA_PKCS1_OAEP_PADDING .
295The resulting pointer is owned by the library and should not be
296freed by the caller.
297.Sh RETURN VALUES
298These functions return a positive value for success or 0 or a negative
299value for failure.
300In particular, a return value of -2 indicates the operation is not
301supported by the public key algorithm.
302.Sh SEE ALSO
303.Xr EVP_DigestInit 3 ,
304.Xr EVP_PKEY_CTX_ctrl 3 ,
305.Xr EVP_PKEY_CTX_new 3 ,
306.Xr EVP_PKEY_decrypt 3 ,
307.Xr EVP_PKEY_derive 3 ,
308.Xr EVP_PKEY_encrypt 3 ,
309.Xr EVP_PKEY_get_default_digest_nid 3 ,
310.Xr EVP_PKEY_keygen 3 ,
311.Xr EVP_PKEY_meth_set_ctrl 3 ,
312.Xr EVP_PKEY_sign 3 ,
313.Xr EVP_PKEY_verify 3 ,
314.Xr EVP_PKEY_verify_recover 3
315.Sh HISTORY
316The functions
317.Fn EVP_PKEY_CTX_set_rsa_padding ,
318.Fn EVP_PKEY_CTX_set_rsa_pss_saltlen ,
319.Fn EVP_PKEY_CTX_set_rsa_keygen_bits ,
320and
321.Fn EVP_PKEY_CTX_set_rsa_keygen_pubexp
322first appeared in OpenSSL 1.0.0 and have been available since
323.Ox 4.9 .
324.Pp
325The functions
326.Fn EVP_PKEY_CTX_get_rsa_padding ,
327.Fn EVP_PKEY_CTX_get_rsa_pss_saltlen ,
328.Fn EVP_PKEY_CTX_set_rsa_mgf1_md ,
329and
330.Fn EVP_PKEY_CTX_get_rsa_mgf1_md
331first appeared in OpenSSL 1.0.1 and have been available since
332.Ox 5.3 .
333.Pp
334The functions
335.Fn EVP_PKEY_CTX_set_rsa_oaep_md ,
336.Fn EVP_PKEY_CTX_get_rsa_oaep_md ,
337.Fn EVP_PKEY_CTX_set0_rsa_oaep_label ,
338and
339.Fn EVP_PKEY_CTX_get0_rsa_oaep_label
340first appeared in OpenSSL 1.0.2 and have been available since
341.Ox 6.7 .
342.Pp
343The function
344.Fn RSA_pkey_ctx_ctrl
345first appeared in OpenSSL 1.1.1 and has been available since
346.Ox 6.7 .