update libressl to v2.7.4
[unleashed.git] / lib / libcrypto / man / d2i_RSAPublicKey.3
bloba98fd44018650a91ec56ec7df6f07d60d294702e
1 .\"     $OpenBSD: d2i_RSAPublicKey.3,v 1.12 2018/03/23 05:48:56 schwarze Exp $
2 .\"     OpenSSL bb9ad09e Jun 6 00:43:05 2016 -0400
3 .\"
4 .\" This file is a derived work.
5 .\" The changes are covered by the following Copyright and license:
6 .\"
7 .\" Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org>
8 .\"
9 .\" Permission to use, copy, modify, and distribute this software for any
10 .\" purpose with or without fee is hereby granted, provided that the above
11 .\" copyright notice and this permission notice appear in all copies.
12 .\"
13 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
14 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
15 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
16 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
17 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
18 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
19 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
20 .\"
21 .\" The original file was written by Ulf Moeller <ulf@openssl.org> and
22 .\" Dr. Stephen Henson <steve@openssl.org>.
23 .\" Copyright (c) 2000, 2002, 2003, 2009, 2016 The OpenSSL Project.
24 .\" All rights reserved.
25 .\"
26 .\" Redistribution and use in source and binary forms, with or without
27 .\" modification, are permitted provided that the following conditions
28 .\" are met:
29 .\"
30 .\" 1. Redistributions of source code must retain the above copyright
31 .\"    notice, this list of conditions and the following disclaimer.
32 .\"
33 .\" 2. Redistributions in binary form must reproduce the above copyright
34 .\"    notice, this list of conditions and the following disclaimer in
35 .\"    the documentation and/or other materials provided with the
36 .\"    distribution.
37 .\"
38 .\" 3. All advertising materials mentioning features or use of this
39 .\"    software must display the following acknowledgment:
40 .\"    "This product includes software developed by the OpenSSL Project
41 .\"    for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
42 .\"
43 .\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
44 .\"    endorse or promote products derived from this software without
45 .\"    prior written permission. For written permission, please contact
46 .\"    openssl-core@openssl.org.
47 .\"
48 .\" 5. Products derived from this software may not be called "OpenSSL"
49 .\"    nor may "OpenSSL" appear in their names without prior written
50 .\"    permission of the OpenSSL Project.
51 .\"
52 .\" 6. Redistributions of any form whatsoever must retain the following
53 .\"    acknowledgment:
54 .\"    "This product includes software developed by the OpenSSL Project
55 .\"    for use in the OpenSSL Toolkit (http://www.openssl.org/)"
56 .\"
57 .\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
58 .\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
59 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
60 .\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE OpenSSL PROJECT OR
61 .\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
62 .\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
63 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
64 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
66 .\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
67 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
68 .\" OF THE POSSIBILITY OF SUCH DAMAGE.
69 .\"
70 .Dd $Mdocdate: March 23 2018 $
71 .Dt D2I_RSAPUBLICKEY 3
72 .Os
73 .Sh NAME
74 .Nm d2i_RSAPublicKey ,
75 .Nm i2d_RSAPublicKey ,
76 .Nm d2i_RSAPrivateKey ,
77 .Nm i2d_RSAPrivateKey ,
78 .Nm d2i_Netscape_RSA ,
79 .Nm i2d_Netscape_RSA ,
80 .Nm d2i_RSA_PSS_PARAMS ,
81 .Nm i2d_RSA_PSS_PARAMS ,
82 .Nm d2i_RSAPublicKey_bio ,
83 .Nm d2i_RSAPublicKey_fp ,
84 .Nm i2d_RSAPublicKey_bio ,
85 .Nm i2d_RSAPublicKey_fp ,
86 .Nm d2i_RSAPrivateKey_bio ,
87 .Nm d2i_RSAPrivateKey_fp ,
88 .Nm i2d_RSAPrivateKey_bio ,
89 .Nm i2d_RSAPrivateKey_fp ,
90 .Nm d2i_RSA_PUBKEY ,
91 .Nm i2d_RSA_PUBKEY ,
92 .Nm d2i_RSA_PUBKEY_bio ,
93 .Nm d2i_RSA_PUBKEY_fp ,
94 .Nm i2d_RSA_PUBKEY_bio ,
95 .Nm i2d_RSA_PUBKEY_fp
96 .Nd decode and encode RSA keys and parameters
97 .Sh SYNOPSIS
98 .In openssl/rsa.h
99 .Ft RSA *
100 .Fo d2i_RSAPublicKey
101 .Fa "RSA **val_out"
102 .Fa "const unsigned char **der_in"
103 .Fa "long length"
105 .Ft int
106 .Fo i2d_RSAPublicKey
107 .Fa "RSA *val_in"
108 .Fa "unsigned char **der_out"
110 .Ft RSA *
111 .Fo d2i_RSAPrivateKey
112 .Fa "RSA **val_out"
113 .Fa "const unsigned char **der_in"
114 .Fa "long length"
116 .Ft int
117 .Fo i2d_RSAPrivateKey
118 .Fa "RSA *val_in"
119 .Fa "unsigned char **der_out"
121 .Ft RSA *
122 .Fo d2i_Netscape_RSA
123 .Fa "RSA **val_out"
124 .Fa "const unsigned char **der_in"
125 .Fa "long length"
126 .Fa "int (*cb)()"
128 .Ft int
129 .Fo i2d_Netscape_RSA
130 .Fa "RSA *val_in"
131 .Fa "unsigned char **der_out"
132 .Fa "int (*cb)()"
134 .Ft RSA_PSS_PARAMS *
135 .Fo d2i_RSA_PSS_PARAMS
136 .Fa "RSA_PSS_PARAMS **val_out"
137 .Fa "const unsigned char **der_in"
138 .Fa "long length"
140 .Ft int
141 .Fo i2d_RSA_PSS_PARAMS
142 .Fa "RSA_PSS_PARAMS *val_in"
143 .Fa "unsigned char **der_out"
145 .In openssl/x509.h
146 .Ft RSA *
147 .Fo d2i_RSAPublicKey_bio
148 .Fa "BIO *in_bio"
149 .Fa "RSA **val_out"
151 .Ft RSA *
152 .Fo d2i_RSAPublicKey_fp
153 .Fa "FILE *in_fp"
154 .Fa "RSA **val_out"
156 .Ft int
157 .Fo i2d_RSAPublicKey_bio
158 .Fa "BIO *out_bio"
159 .Fa "RSA *val_in"
161 .Ft int
162 .Fo i2d_RSAPublicKey_fp
163 .Fa "FILE *out_fp"
164 .Fa "RSA *val_in"
166 .Ft RSA *
167 .Fo d2i_RSAPrivateKey_bio
168 .Fa "BIO *in_bio"
169 .Fa "RSA **val_out"
171 .Ft RSA *
172 .Fo d2i_RSAPrivateKey_fp
173 .Fa "FILE *in_fp"
174 .Fa "RSA **val_out"
176 .Ft int
177 .Fo i2d_RSAPrivateKey_bio
178 .Fa "BIO *out_bio"
179 .Fa "RSA *val_in"
181 .Ft int
182 .Fo i2d_RSAPrivateKey_fp
183 .Fa "FILE *out_fp"
184 .Fa "RSA *val_in"
186 .Ft RSA *
187 .Fo d2i_RSA_PUBKEY
188 .Fa "RSA **val_out"
189 .Fa "const unsigned char **der_in"
190 .Fa "long length"
192 .Ft int
193 .Fo i2d_RSA_PUBKEY
194 .Fa "RSA *val_in"
195 .Fa "unsigned char **der_out"
197 .Ft RSA *
198 .Fo d2i_RSA_PUBKEY_bio
199 .Fa "BIO *in_bio"
200 .Fa "RSA **val_out"
202 .Ft RSA *
203 .Fo d2i_RSA_PUBKEY_fp
204 .Fa "FILE *in_fp"
205 .Fa "RSA **val_out"
207 .Ft int
208 .Fo i2d_RSA_PUBKEY_bio
209 .Fa "BIO *out_bio"
210 .Fa "RSA *val_in"
212 .Ft int
213 .Fo i2d_RSA_PUBKEY_fp
214 .Fa "FILE *out_fp"
215 .Fa "RSA *val_in"
217 .Sh DESCRIPTION
218 These functions decode and encode RSA private and public keys.
219 For details about the semantics, examples, caveats, and bugs, see
220 .Xr ASN1_item_d2i 3 .
222 .Fn d2i_RSAPublicKey
224 .Fn i2d_RSAPublicKey
225 decode and encode a PKCS#1
226 .Vt RSAPublicKey
227 structure defined in RFC 8017 appendix A.1.1.
228 .Fn d2i_RSAPublicKey_bio ,
229 .Fn d2i_RSAPublicKey_fp ,
230 .Fn i2d_RSAPublicKey_bio ,
232 .Fn i2d_RSAPublicKey_fp
233 are similar except that they decode or encode using a
234 .Vt BIO
236 .Vt FILE
237 pointer.
239 .Fn d2i_RSAPrivateKey
241 .Fn i2d_RSAPrivateKey
242 decode and encode a PKCS#1
243 .Vt RSAPrivateKey
244 structure defined in RFC 8017 appendix A.1.2.
246 .Vt RSA
247 structure passed to the private key encoding functions should have
248 all the PKCS#1 private key components present.
249 The data encoded by the private key functions is unencrypted and
250 therefore offers no private key security.
251 .Fn d2i_RSAPrivateKey_bio ,
252 .Fn d2i_RSAPrivateKey_fp ,
253 .Fn i2d_RSAPrivateKey_bio ,
255 .Fn i2d_RSAPrivateKey_fp
256 are similar except that they decode or encode using a
257 .Vt BIO
259 .Vt FILE
260 pointer.
262 .Fn d2i_Netscape_RSA
264 .Fn i2d_Netscape_RSA
265 decode and encode an RSA private key in NET format.
266 These functions are present to provide compatibility with
267 certain very old software.
268 The NET format has some severe security weaknesses and should be
269 avoided if possible.
271 .Fn d2i_RSA_PSS_PARAMS
273 .Fn i2d_RSA_PSS_PARAMS
274 decode and encode a PKCS#1
275 .Vt RSASSA-PSS-params
276 structure defined in RFC 8017 appendix A.2.3 and documented in
277 .Xr RSA_PSS_PARAMS_new 3 .
279 .Fn d2i_RSA_PUBKEY
281 .Fn i2d_RSA_PUBKEY
282 decode and encode an RSA public key using an ASN.1
283 .Vt SubjectPublicKeyInfo
284 structure defined in RFC 5280 section 4.1 and documented in
285 .Xr X509_PUBKEY_new 3 .
286 .Fn d2i_RSA_PUBKEY_bio ,
287 .Fn d2i_RSA_PUBKEY_fp ,
288 .Fn i2d_RSA_PUBKEY_bio ,
290 .Fn i2d_RSA_PUBKEY_fp
291 are similar except that they decode or encode using a
292 .Vt BIO
294 .Vt FILE
295 pointer.
296 .Sh RETURN VALUES
297 .Fn d2i_RSAPublicKey ,
298 .Fn d2i_RSAPublicKey_bio ,
299 .Fn d2i_RSAPublicKey_fp ,
300 .Fn d2i_RSAPrivateKey ,
301 .Fn d2i_RSAPrivateKey_bio ,
302 .Fn d2i_RSAPrivateKey_fp ,
303 .Fn d2i_Netscape_RSA ,
304 .Fn d2i_RSA_PUBKEY ,
305 .Fn d2i_RSA_PUBKEY_bio ,
307 .Fn d2i_RSA_PUBKEY_fp
308 return a valid
309 .Vt RSA
310 object or
311 .Dv NULL
312 if an error occurs.
314 .Fn d2i_RSA_PSS_PARAMS
315 returns a valid
316 .Vt RSA_PSS_PARAMS
317 object or
318 .Dv NULL
319 if an error occurs.
321 .Fn i2d_RSAPublicKey ,
322 .Fn i2d_RSAPrivateKey ,
323 .Fn i2d_Netscape_RSA ,
324 .Fn i2d_RSA_PSS_PARAMS ,
326 .Fn i2d_RSA_PUBKEY
327 return the number of bytes successfully encoded or a negative value
328 if an error occurs.
330 .Fn i2d_RSAPublicKey_bio ,
331 .Fn i2d_RSAPublicKey_fp ,
332 .Fn i2d_RSAPrivateKey_bio ,
333 .Fn i2d_RSAPrivateKey_fp ,
334 .Fn i2d_RSA_PUBKEY_bio ,
336 .Fn i2d_RSA_PUBKEY_fp
337 return 1 for success or 0 if an error occurs.
338 .Sh SEE ALSO
339 .Xr ASN1_item_d2i 3 ,
340 .Xr EVP_PKEY_set1_RSA 3 ,
341 .Xr PEM_write_RSAPrivateKey 3 ,
342 .Xr RSA_new 3 ,
343 .Xr RSA_PSS_PARAMS_new 3 ,
344 .Xr X509_PUBKEY_new 3
345 .Sh STANDARDS
346 RFC 8017: PKCS #1: RSA Cryptography Specifications
348 RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
349 Certificate Revocation List (CRL) Profile,
350 section 4.1: Basic Certificate Fields
351 .Sh HISTORY
352 .Fn d2i_RSAPublicKey ,
353 .Fn i2d_RSAPublicKey ,
354 .Fn d2i_RSAPrivateKey ,
355 .Fn i2d_RSAPrivateKey ,
356 .Fn d2i_Netscape_RSA ,
357 .Fn i2d_Netscape_RSA ,
358 .Fn d2i_RSAPublicKey_bio ,
359 .Fn d2i_RSAPublicKey_fp ,
360 .Fn i2d_RSAPublicKey_bio ,
361 .Fn i2d_RSAPublicKey_fp ,
362 .Fn d2i_RSAPrivateKey_bio ,
363 .Fn d2i_RSAPrivateKey_fp ,
364 .Fn i2d_RSAPrivateKey_bio ,
366 .Fn i2d_RSAPrivateKey_fp
367 appeared before SSLeay 0.8 and have been available since
368 .Ox 2.4 .
370 .Fn d2i_RSA_PUBKEY ,
371 .Fn i2d_RSA_PUBKEY ,
372 .Fn d2i_RSA_PUBKEY_bio ,
373 .Fn d2i_RSA_PUBKEY_fp ,
374 .Fn i2d_RSA_PUBKEY_bio ,
376 .Fn i2d_RSA_PUBKEY_fp
377 first appeared in OpenSSL 0.9.5 and have been available since
378 .Ox 2.7 .
380 .Fn d2i_RSA_PSS_PARAMS
382 .Fn i2d_RSA_PSS_PARAMS
383 first appeared in OpenSSL 1.0.1 and have been available since
384 .Ox 5.3 .