summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorschwarze <>2016-12-25 20:01:48 +0000
committerschwarze <>2016-12-25 20:01:48 +0000
commit5667f2b73d8867280a0e2b3dd1d8068478634723 (patch)
treeda6c16fdc91f67f1ea7ed85cd3e3e2b23b728095 /src/lib
parentf75416634e50d0e872512d4248c52af59ba54ba3 (diff)
downloadopenbsd-5667f2b73d8867280a0e2b3dd1d8068478634723.tar.gz
openbsd-5667f2b73d8867280a0e2b3dd1d8068478634723.tar.bz2
openbsd-5667f2b73d8867280a0e2b3dd1d8068478634723.zip
Add missing functions d2i_PublicKey(3) and i2d_PublicKey(3)
found in OpenSSL doc/man3/d2i_X509.pod. Simplify one-line description. Use the same parameter names as in ASN1_item_d2i(3). Point to ASN1_item_d2i(3) for details. Add a STANDRADS reference regarding PKCS#8 PrivateKeyInfo. Mention d2i_PrivateKey_bio(3) and d2i_PrivateKey_fp(3) in the DESCRIPTION and below RETURN VALUES. Add some missing markup and tweak some wording. Add some cross references.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/libcrypto/man/d2i_PrivateKey.3148
1 files changed, 113 insertions, 35 deletions
diff --git a/src/lib/libcrypto/man/d2i_PrivateKey.3 b/src/lib/libcrypto/man/d2i_PrivateKey.3
index 10eb5ebeeb..3c5e9f8cc8 100644
--- a/src/lib/libcrypto/man/d2i_PrivateKey.3
+++ b/src/lib/libcrypto/man/d2i_PrivateKey.3
@@ -1,7 +1,24 @@
1.\" $OpenBSD: d2i_PrivateKey.3,v 1.3 2016/12/08 20:22:08 jmc Exp $ 1.\" $OpenBSD: d2i_PrivateKey.3,v 1.4 2016/12/25 20:01:48 schwarze Exp $
2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100 2.\" OpenSSL b97fdb57 Nov 11 09:33:09 2016 +0100
3.\" 3.\"
4.\" This file was written by Dr. Stephen Henson <steve@openssl.org>. 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 Dr. Stephen Henson <steve@openssl.org>.
5.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved. 22.\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
6.\" 23.\"
7.\" Redistribution and use in source and binary forms, with or without 24.\" Redistribution and use in source and binary forms, with or without
@@ -48,7 +65,7 @@
48.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
49.\" OF THE POSSIBILITY OF SUCH DAMAGE. 66.\" OF THE POSSIBILITY OF SUCH DAMAGE.
50.\" 67.\"
51.Dd $Mdocdate: December 8 2016 $ 68.Dd $Mdocdate: December 25 2016 $
52.Dt D2I_PRIVATEKEY 3 69.Dt D2I_PRIVATEKEY 3
53.Os 70.Os
54.Sh NAME 71.Sh NAME
@@ -56,44 +73,64 @@
56.Nm d2i_AutoPrivateKey , 73.Nm d2i_AutoPrivateKey ,
57.Nm i2d_PrivateKey , 74.Nm i2d_PrivateKey ,
58.Nm d2i_PrivateKey_bio , 75.Nm d2i_PrivateKey_bio ,
59.Nm d2i_PrivateKey_fp 76.Nm d2i_PrivateKey_fp ,
60.Nd decode and encode functions for reading and saving EVP_PKEY structures 77.Nm d2i_PublicKey ,
78.Nm i2d_PublicKey
79.Nd decode and encode EVP_PKEY objects
61.Sh SYNOPSIS 80.Sh SYNOPSIS
62.In openssl/evp.h 81.In openssl/evp.h
63.Ft EVP_PKEY * 82.Ft EVP_PKEY *
64.Fo d2i_PrivateKey 83.Fo d2i_PrivateKey
65.Fa "int type" 84.Fa "int type"
66.Fa "EVP_PKEY **a" 85.Fa "EVP_PKEY **val_out"
67.Fa "const unsigned char **pp" 86.Fa "const unsigned char **des_in"
68.Fa "long length" 87.Fa "long length"
69.Fc 88.Fc
70.Ft EVP_PKEY * 89.Ft EVP_PKEY *
71.Fo d2i_AutoPrivateKey 90.Fo d2i_AutoPrivateKey
72.Fa "EVP_PKEY **a" 91.Fa "EVP_PKEY **val_out"
73.Fa "const unsigned char **pp" 92.Fa "const unsigned char **des_in"
74.Fa "long length" 93.Fa "long length"
75.Fc 94.Fc
76.Ft int 95.Ft int
77.Fo i2d_PrivateKey 96.Fo i2d_PrivateKey
78.Fa "EVP_PKEY *a" 97.Fa "EVP_PKEY *val_in"
79.Fa "unsigned char **pp" 98.Fa "unsigned char **des_out"
80.Fc 99.Fc
81.Ft EVP_PKEY * 100.Ft EVP_PKEY *
82.Fo d2i_PrivateKey_bio 101.Fo d2i_PrivateKey_bio
83.Fa "BIO *bp" 102.Fa "BIO *in_bio"
84.Fa "EVP_PKEY **a" 103.Fa "EVP_PKEY **val_out"
85.Fc 104.Fc
86.Ft EVP_PKEY * 105.Ft EVP_PKEY *
87.Fo d2i_PrivateKey_fp 106.Fo d2i_PrivateKey_fp
88.Fa "FILE *fp" 107.Fa "FILE *in_fp"
89.Fa "EVP_PKEY **a" 108.Fa "EVP_PKEY **val_out"
109.Fc
110.Ft EVP_PKEY *
111.Fo d2i_PublicKey
112.Fa "int type"
113.Fa "EVP_PKEY **val_out"
114.Fa "const unsigned char **des_in"
115.Fa "long length"
116.Fc
117.Ft int
118.Fo i2d_PublicKey
119.Fa "EVP_PKEY *val_in"
120.Fa "unsigned char **des_out"
90.Fc 121.Fc
91.Sh DESCRIPTION 122.Sh DESCRIPTION
123These are algorithm-independent interfaces to decode and encode
124private and public keys.
125For details about the semantics, examples, caveats, and bugs, see
126.Xr ASN1_item_d2i 3 .
127.Pp
92.Fn d2i_PrivateKey 128.Fn d2i_PrivateKey
93decodes a private key using algorithm 129decodes a private key using algorithm
94.Fa type . 130.Fa type .
95It attempts to use any key specific format or PKCS#8 unencrypted 131It attempts to use any key specific format or the PKCS#8 unencrypted
96PrivateKeyInfo format. 132.Vt PrivateKeyInfo
133format defined in RFC 5208 section 5.
97The 134The
98.Fa type 135.Fa type
99parameter should be a public key algorithm constant such as 136parameter should be a public key algorithm constant such as
@@ -104,18 +141,26 @@ An error occurs if the decoded key does not match
104.Fn d2i_AutoPrivateKey 141.Fn d2i_AutoPrivateKey
105is similar to 142is similar to
106.Fn d2i_PrivateKey 143.Fn d2i_PrivateKey
107except that it attempts to automatically detect the private key format. 144except that it attempts to automatically detect the algorithm.
145.Pp
146.Fn d2i_PrivateKey_bio
147and
148.Fn d2i_PrivateKey_fp
149are similar to
150.Fn d2i_PrivateKey
151except that they read from a
152.Vt BIO
153or
154.Vt FILE
155pointer.
108.Pp 156.Pp
109.Fn i2d_PrivateKey 157.Fn i2d_PrivateKey
110encodes 158encodes
111.Fa a . 159.Fa val_in .
112It uses a key specific format or, if none is defined for that key type, 160It uses a key specific format or, if none is defined for that key type,
113PKCS#8 unencrypted PrivateKeyInfo format. 161the PKCS#8 unencrypted
114.Pp 162.Vt PrivateKeyInfo
115These functions are similar to the 163format.
116.Xr d2i_X509 3
117functions; see
118.Xr d2i_X509 3 .
119.Pp 164.Pp
120All these functions use DER format and unencrypted keys. 165All these functions use DER format and unencrypted keys.
121Applications wishing to encrypt or decrypt private keys should use other 166Applications wishing to encrypt or decrypt private keys should use other
@@ -124,31 +169,64 @@ functions such as
124instead. 169instead.
125.Pp 170.Pp
126If 171If
127.Pf * Fa a 172.Pf * Fa val_out
128is not NULL when calling 173is not
174.Dv NULL
175when calling
129.Fn d2i_PrivateKey 176.Fn d2i_PrivateKey
130or 177or
131.Fn d2i_AutoPrivateKey 178.Fn d2i_AutoPrivateKey
132(i.e. an existing structure is being reused) and the key format is 179(i.e. an existing structure is being reused) and the key format is
133PKCS#8, then 180PKCS#8, then
134.Pf * Fa a 181.Pf * Fa val_out
135will be freed and replaced on a successful call. 182will be freed and replaced on a successful call.
183.Pp
184.Fn d2i_PublicKey
185calls
186.Xr d2i_DSAPublicKey 3 ,
187.Xr o2i_ECPublicKey 3 ,
188or
189.Xr d2i_RSAPublicKey 3
190depending on
191.Fa type
192and stores the result in the returned
193.Vt EVP_PKEY
194object.
195.Pp
196.Fn i2d_PublicKey
197calls
198.Xr i2d_DSAPublicKey 3 ,
199.Xr i2o_ECPublicKey 3 ,
200or
201.Xr i2d_RSAPublicKey 3
202depending on the algorithm used by
203.Fa val_in .
136.Sh RETURN VALUES 204.Sh RETURN VALUES
137.Fn d2i_PrivateKey 205.Fn d2i_PrivateKey ,
206.Fn d2i_AutoPrivateKey ,
207.Fn d2i_PrivateKey_bio ,
208.Fn d2i_PrivateKey_fp ,
138and 209and
139.Fn d2i_AutoPrivateKey 210.Fn d2i_PublicKey
140return a valid 211return a valid
141.Vt EVP_KEY 212.Vt EVP_KEY
142structure or 213structure or
143.Dv NULL 214.Dv NULL
144if an error occurs. 215if an error occurs.
145The error code can be obtained by calling
146.Xr ERR_get_error 3 .
147.Pp 216.Pp
148.Fn i2d_PrivateKey 217.Fn i2d_PrivateKey
149returns the number of bytes successfully encoded or a negative value if 218and
219.Fn i2d_PublicKey
220return the number of bytes successfully encoded or a negative value if
150an error occurs. 221an error occurs.
151The error code can be obtained by calling 222.Pp
223For all functions, the error code can be obtained by calling
152.Xr ERR_get_error 3 . 224.Xr ERR_get_error 3 .
153.Sh SEE ALSO 225.Sh SEE ALSO
154.Xr d2i_PKCS8PrivateKey_bio 3 226.Xr d2i_PKCS8PrivateKey_bio 3 ,
227.Xr EVP_PKEY_type 3 ,
228.Xr PEM_write_PrivateKey 3 ,
229.Xr PKCS8_PRIV_KEY_INFO_new 3
230.Sh STANDARDS
231RFC 5208: Public-Key Cryptography Standards (PKCS) #8: Private-Key
232Information Syntax Specification