summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2016-12-05 20:30:12 +0000
committerschwarze <>2016-12-05 20:30:12 +0000
commit080b03e43a1c8826d03c1ea23208aca9f23af877 (patch)
treedb38eb70d7a7d3bd1616b842479614d783c0223e /src/lib
parent00809b788b39971ad83b57ace1803bf130b53a1e (diff)
downloadopenbsd-080b03e43a1c8826d03c1ea23208aca9f23af877.tar.gz
openbsd-080b03e43a1c8826d03c1ea23208aca9f23af877.tar.bz2
openbsd-080b03e43a1c8826d03c1ea23208aca9f23af877.zip
import d2i_PrivateKey(3) from OpenSSL
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/Makefile3
-rw-r--r--src/lib/libcrypto/man/d2i_PrivateKey.3155
2 files changed, 157 insertions, 1 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index f6c0ef249a..29e066614f 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.66 2016/12/05 18:24:08 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.67 2016/12/05 20:30:12 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -206,6 +206,7 @@ MAN= \
206 d2i_DSAPublicKey.3 \ 206 d2i_DSAPublicKey.3 \
207 d2i_ECPKParameters.3 \ 207 d2i_ECPKParameters.3 \
208 d2i_PKCS8PrivateKey_bio.3 \ 208 d2i_PKCS8PrivateKey_bio.3 \
209 d2i_PrivateKey.3 \
209 d2i_RSAPublicKey.3 \ 210 d2i_RSAPublicKey.3 \
210 d2i_X509.3 \ 211 d2i_X509.3 \
211 d2i_X509_ALGOR.3 \ 212 d2i_X509_ALGOR.3 \
diff --git a/src/lib/libcrypto/man/d2i_PrivateKey.3 b/src/lib/libcrypto/man/d2i_PrivateKey.3
new file mode 100644
index 0000000000..42dfe973e8
--- /dev/null
+++ b/src/lib/libcrypto/man/d2i_PrivateKey.3
@@ -0,0 +1,155 @@
1.\" $OpenBSD: d2i_PrivateKey.3,v 1.1 2016/12/05 20:30:12 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" 1. Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\"
14.\" 2. Redistributions in binary form must reproduce the above copyright
15.\" notice, this list of conditions and the following disclaimer in
16.\" the documentation and/or other materials provided with the
17.\" distribution.
18.\"
19.\" 3. All advertising materials mentioning features or use of this
20.\" software must display the following acknowledgment:
21.\" "This product includes software developed by the OpenSSL Project
22.\" for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
23.\"
24.\" 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
25.\" endorse or promote products derived from this software without
26.\" prior written permission. For written permission, please contact
27.\" openssl-core@openssl.org.
28.\"
29.\" 5. Products derived from this software may not be called "OpenSSL"
30.\" nor may "OpenSSL" appear in their names without prior written
31.\" permission of the OpenSSL Project.
32.\"
33.\" 6. Redistributions of any form whatsoever must retain the following
34.\" acknowledgment:
35.\" "This product includes software developed by the OpenSSL Project
36.\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
37.\"
38.\" THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
39.\" EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
40.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
41.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
42.\" ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
43.\" SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
44.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
45.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
47.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\"
51.Dd $Mdocdate: December 5 2016 $
52.Dt D2I_PRIVATEKEY 3
53.Os
54.Sh NAME
55.Nm d2i_PrivateKey ,
56.Nm d2i_AutoPrivateKey ,
57.Nm i2d_PrivateKey ,
58.Nm d2i_PrivateKey_bio ,
59.Nm d2i_PrivateKey_fp
60.Nd decode and encode functions for reading and saving EVP_PKEY structures
61.Sh SYNOPSIS
62.In openssl/evp.h
63.Ft EVP_PKEY *
64.Fo d2i_PrivateKey
65.Fa "int type"
66.Fa "EVP_PKEY **a"
67.Fa "const unsigned char **pp"
68.Fa "long length"
69.Fc
70.Ft EVP_PKEY *
71.Fo d2i_AutoPrivateKey
72.Fa "EVP_PKEY **a"
73.Fa "const unsigned char **pp"
74.Fa "long length"
75.Fc
76.Ft int
77.Fo i2d_PrivateKey
78.Fa "EVP_PKEY *a"
79.Fa "unsigned char **pp"
80.Fc
81.Ft EVP_PKEY *
82.Fo d2i_PrivateKey_bio
83.Fa "BIO *bp"
84.Fa "EVP_PKEY **a"
85.Fc
86.Ft EVP_PKEY *
87.Fo d2i_PrivateKey_fp
88.Fa "FILE *fp"
89.Fa "EVP_PKEY **a"
90.Fc
91.Sh DESCRIPTION
92.Fn d2i_PrivateKey
93decodes a private key using algorithm
94.Fa type .
95It attempts to use any key specific format or PKCS#8 unencrypted
96PrivateKeyInfo format.
97The
98.Fa type
99parameter should be a public key algorithm constant such as
100.Dv EVP_PKEY_RSA .
101An error occurs if the decoded key does not match
102.Fa type .
103.Pp
104.Fn d2i_AutoPrivateKey
105is similar to
106.Fn d2i_PrivateKey
107except that it attempts to automatically detect the private key format.
108.Pp
109.Fn i2d_PrivateKey
110encodes
111.Fa a .
112It uses a key specific format or, if none is defined for that key type,
113PKCS#8 unencrypted PrivateKeyInfo format.
114.Pp
115These functions are similar to the
116.Xr d2i_X509 3
117functions; see
118.Xr d2i_X509 3 .
119.Pp
120All these functions use DER format and unencrypted keys.
121Applications wishing to encrypt or decrypt private keys should use other
122functions such as
123.Xr d2i_PKC8PrivateKey 3
124instead.
125.Pp
126If
127.Pf * Fa a
128is not NULL when calling
129.Fn d2i_PrivateKey
130or
131.Fn d2i_AutoPrivateKey
132(i.e. an existing structure is being reused) and the key format is
133PKCS#8, then
134.Pf * Fa a
135will be freed and replaced on a successful call.
136.Sh RETURN VALUES
137.Fn d2i_PrivateKey
138and
139.Fn d2i_AutoPrivateKey
140return a valid
141.Vt EVP_KEY
142structure or
143.Dv NULL
144if an error occurs.
145The error code can be obtained by calling
146.Xr ERR_get_error 3 .
147.Pp
148.Fn i2d_PrivateKey
149returns the number of bytes successfully encoded or a negative value if
150an error occurs.
151The error code can be obtained by calling
152.Xr ERR_get_error 3 .
153.Sh SEE ALSO
154.Xr crypto 3 ,
155.Xr d2i_PKCS8PrivateKey 3