diff options
author | schwarze <> | 2016-12-05 12:50:07 +0000 |
---|---|---|
committer | schwarze <> | 2016-12-05 12:50:07 +0000 |
commit | b4d1ec20ad5908fd4285abede4f04da108b29a19 (patch) | |
tree | 0bfad1691cf4947164e12f51b9b25125c25958e4 /src/lib/libcrypto/man | |
parent | ae7f16971a387d9ae5aae5917cdc83bb6bf07e49 (diff) | |
download | openbsd-b4d1ec20ad5908fd4285abede4f04da108b29a19.tar.gz openbsd-b4d1ec20ad5908fd4285abede4f04da108b29a19.tar.bz2 openbsd-b4d1ec20ad5908fd4285abede4f04da108b29a19.zip |
import X509_PUBKEY_new(3) from OpenSSL
Diffstat (limited to 'src/lib/libcrypto/man')
-rw-r--r-- | src/lib/libcrypto/man/Makefile | 3 | ||||
-rw-r--r-- | src/lib/libcrypto/man/X509_PUBKEY_new.3 | 273 |
2 files changed, 275 insertions, 1 deletions
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile index c8eb806169..8491e94fa0 100644 --- a/src/lib/libcrypto/man/Makefile +++ b/src/lib/libcrypto/man/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.62 2016/12/04 20:51:47 schwarze Exp $ | 1 | # $OpenBSD: Makefile,v 1.63 2016/12/05 12:50:07 schwarze Exp $ |
2 | 2 | ||
3 | .include <bsd.own.mk> | 3 | .include <bsd.own.mk> |
4 | 4 | ||
@@ -179,6 +179,7 @@ MAN= \ | |||
179 | X509_NAME_add_entry_by_txt.3 \ | 179 | X509_NAME_add_entry_by_txt.3 \ |
180 | X509_NAME_get_index_by_NID.3 \ | 180 | X509_NAME_get_index_by_NID.3 \ |
181 | X509_NAME_print_ex.3 \ | 181 | X509_NAME_print_ex.3 \ |
182 | X509_PUBKEY_new.3 \ | ||
182 | X509_STORE_CTX_get_error.3 \ | 183 | X509_STORE_CTX_get_error.3 \ |
183 | X509_STORE_CTX_get_ex_new_index.3 \ | 184 | X509_STORE_CTX_get_ex_new_index.3 \ |
184 | X509_STORE_CTX_new.3 \ | 185 | X509_STORE_CTX_new.3 \ |
diff --git a/src/lib/libcrypto/man/X509_PUBKEY_new.3 b/src/lib/libcrypto/man/X509_PUBKEY_new.3 new file mode 100644 index 0000000000..59dc2fbf7a --- /dev/null +++ b/src/lib/libcrypto/man/X509_PUBKEY_new.3 | |||
@@ -0,0 +1,273 @@ | |||
1 | .\" $OpenBSD: X509_PUBKEY_new.3,v 1.1 2016/12/05 12:50:07 schwarze Exp $ | ||
2 | .\" OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 | ||
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 X509_PUBKEY_NEW 3 | ||
53 | .Os | ||
54 | .Sh NAME | ||
55 | .Nm X509_PUBKEY_new , | ||
56 | .Nm X509_PUBKEY_free , | ||
57 | .Nm X509_PUBKEY_set , | ||
58 | .Nm X509_PUBKEY_get , | ||
59 | .Nm d2i_PUBKEY , | ||
60 | .Nm i2d_PUBKEY , | ||
61 | .Nm d2i_PUBKEY_bio , | ||
62 | .Nm d2i_PUBKEY_fp , | ||
63 | .Nm i2d_PUBKEY_fp , | ||
64 | .Nm i2d_PUBKEY_bio , | ||
65 | .Nm X509_PUBKEY_set0_param , | ||
66 | .Nm X509_PUBKEY_get0_param | ||
67 | .Nd SubjectPublicKeyInfo public key functions | ||
68 | .Sh SYNOPSIS | ||
69 | .In openssl/x509.h | ||
70 | .Ft X509_PUBKEY * | ||
71 | .Fn X509_PUBKEY_new void | ||
72 | .Ft void | ||
73 | .Fo X509_PUBKEY_free | ||
74 | .Fa "X509_PUBKEY *a" | ||
75 | .Fc | ||
76 | .Ft int | ||
77 | .Fo X509_PUBKEY_set | ||
78 | .Fa "X509_PUBKEY **x" | ||
79 | .Fa "EVP_PKEY *pkey" | ||
80 | .Fc | ||
81 | .Ft EVP_PKEY * | ||
82 | .Fo X509_PUBKEY_get | ||
83 | .Fa "X509_PUBKEY *key" | ||
84 | .Fc | ||
85 | .Ft EVP_PKEY * | ||
86 | .Fo d2i_PUBKEY | ||
87 | .Fa "EVP_PKEY **a" | ||
88 | .Fa "const unsigned char **pp" | ||
89 | .Fa "long length" | ||
90 | .Fc | ||
91 | .Ft int | ||
92 | .Fo i2d_PUBKEY | ||
93 | .Fa "EVP_PKEY *a" | ||
94 | .Fa "unsigned char **pp" | ||
95 | .Fc | ||
96 | .Ft EVP_PKEY * | ||
97 | .Fo d2i_PUBKEY_bio | ||
98 | .Fa "BIO *bp" | ||
99 | .Fa "EVP_PKEY **a" | ||
100 | .Fc | ||
101 | .Ft EVP_PKEY * | ||
102 | .Fo d2i_PUBKEY_fp | ||
103 | .Fa "FILE *fp" | ||
104 | .Fa "EVP_PKEY **a" | ||
105 | .Fc | ||
106 | .Ft int | ||
107 | .Fo i2d_PUBKEY_fp | ||
108 | .Fa "FILE *fp" | ||
109 | .Fa "EVP_PKEY *pkey" | ||
110 | .Fc | ||
111 | .Ft int | ||
112 | .Fo i2d_PUBKEY_bio | ||
113 | .Fa "BIO *bp" | ||
114 | .Fa "EVP_PKEY *pkey" | ||
115 | .Fc | ||
116 | .Ft int | ||
117 | .Fo X509_PUBKEY_set0_param | ||
118 | .Fa "X509_PUBKEY *pub" | ||
119 | .Fa "ASN1_OBJECT *aobj" | ||
120 | .Fa "int ptype" | ||
121 | .Fa "void *pval" | ||
122 | .Fa "unsigned char *penc" | ||
123 | .Fa "int penclen" | ||
124 | .Fc | ||
125 | .Ft int | ||
126 | .Fo X509_PUBKEY_get0_param | ||
127 | .Fa "ASN1_OBJECT **ppkalg" | ||
128 | .Fa "const unsigned char **pk" | ||
129 | .Fa "int *ppklen" | ||
130 | .Fa "X509_ALGOR **pa" | ||
131 | .Fa "X509_PUBKEY *pub" | ||
132 | .Fc | ||
133 | .Sh DESCRIPTION | ||
134 | The | ||
135 | .Vt X509_PUBKEY | ||
136 | structure represents the ASN.1 | ||
137 | .Sy SubjectPublicKeyInfo | ||
138 | structure defined in RFC 5280 and used in certificates and certificate | ||
139 | requests. | ||
140 | .Pp | ||
141 | .Fn X509_PUBKEY_new | ||
142 | allocates and initializes an | ||
143 | .Vt X509_PUBKEY | ||
144 | structure. | ||
145 | .Pp | ||
146 | .Fn X509_PUBKEY_free | ||
147 | frees up the | ||
148 | .Vt X509_PUBKEY | ||
149 | structure | ||
150 | .Fa a . | ||
151 | If | ||
152 | .Fa a | ||
153 | is a | ||
154 | .Dv NULL | ||
155 | pointer, nothing is done. | ||
156 | .Pp | ||
157 | .Fn X509_PUBKEY_set | ||
158 | sets the public key in | ||
159 | .Pf * Fa x | ||
160 | to the public key contained in the | ||
161 | .Vt EVP_PKEY | ||
162 | structure | ||
163 | .Fa pkey . | ||
164 | If | ||
165 | .Pf * Fa x | ||
166 | is not | ||
167 | .Dv NULL , | ||
168 | any existing public key structure will be freed. | ||
169 | .Pp | ||
170 | .Fn X509_PUBKEY_get | ||
171 | returns the public key contained in | ||
172 | .Fa key . | ||
173 | The reference | ||
174 | count on the returned key is incremented so it must be freed using | ||
175 | .Xr EVP_PKEY_free | ||
176 | after use. | ||
177 | .Pp | ||
178 | .Fn d2i_PUBKEY | ||
179 | and | ||
180 | .Fn i2d_PUBKEY | ||
181 | decode and encode an | ||
182 | .Vt EVP_PKEY | ||
183 | structure using | ||
184 | .Sy SubjectPublicKeyInfo | ||
185 | format. | ||
186 | They otherwise follow the conventions of other ASN.1 functions such as | ||
187 | .Xr d2i_X509 3 . | ||
188 | .Pp | ||
189 | .Fn d2i_PUBKEY_bio , | ||
190 | .Fn d2i_PUBKEY_fp , | ||
191 | .Fn i2d_PUBKEY_bio | ||
192 | and | ||
193 | .Fn i2d_PUBKEY_fp | ||
194 | are similar to | ||
195 | .Fn d2i_PUBKEY | ||
196 | and | ||
197 | .Fn i2d_PUBKEY | ||
198 | except they decode or encode using a | ||
199 | .Vt BIO | ||
200 | or | ||
201 | .Vt FILE | ||
202 | pointer. | ||
203 | .Pp | ||
204 | .Fn X509_PUBKEY_set0_param | ||
205 | sets the public key parameters of | ||
206 | .Fa pub . | ||
207 | The OID associated with the algorithm is set to | ||
208 | .Fa aobj . | ||
209 | The type of the algorithm parameters is set to | ||
210 | .Fa ptype | ||
211 | using the structure | ||
212 | .Fa pval . | ||
213 | The encoding of the public key itself is set to the | ||
214 | .Fa penclen | ||
215 | bytes contained in buffer | ||
216 | .Fa penc . | ||
217 | On success ownership of all the supplied parameters is passed to | ||
218 | .Fa pub | ||
219 | so they must not be freed after the call. | ||
220 | .Pp | ||
221 | .Fn X509_PUBKEY_get0_param | ||
222 | retrieves the public key parameters from | ||
223 | .Fa pub , | ||
224 | .Pf * Fa ppkalg | ||
225 | is set to the associated OID and the encoding consists of | ||
226 | .Pf * Fa ppklen | ||
227 | bytes at | ||
228 | .Pf * Fa pk , | ||
229 | .Pf * Fa pa | ||
230 | is set to the associated AlgorithmIdentifier for the public key. | ||
231 | If the value of any of these parameters is not required, | ||
232 | it can be set to | ||
233 | .Dv NULL . | ||
234 | All of the retrieved pointers are internal and must not be freed after | ||
235 | the call. | ||
236 | .Pp | ||
237 | The | ||
238 | .Vt X509_PUBKEY | ||
239 | functions can be used to encode and decode public keys in a standard | ||
240 | format. | ||
241 | .Pp | ||
242 | In many cases applications will not call the | ||
243 | .Vt X509_PUBKEY | ||
244 | functions directly: they will instead call wrapper functions such as | ||
245 | .Xr X509_get0_pubkey 3 . | ||
246 | .Sh RETURN VALUES | ||
247 | If the allocation fails, | ||
248 | .Fn X509_PUBKEY_new | ||
249 | returns | ||
250 | .Dv NULL | ||
251 | and sets an error code that can be obtained by | ||
252 | .Xr ERR_get_error 3 . | ||
253 | .Pp | ||
254 | Otherwise it returns a pointer to the newly allocated structure. | ||
255 | .Pp | ||
256 | .Fn X509_PUBKEY_get0 | ||
257 | and | ||
258 | .Fn X509_PUBKEY_get | ||
259 | return a pointer to an | ||
260 | .Vt EVP_PKEY | ||
261 | structure or | ||
262 | .Dv NULL | ||
263 | if an error occurs. | ||
264 | .Pp | ||
265 | .Fn X509_PUBKEY_set , | ||
266 | .Fn X509_PUBKEY_set0_param | ||
267 | and | ||
268 | .Fn X509_PUBKEY_get0_param | ||
269 | return 1 for success and 0 if an error occurred. | ||
270 | .Sh SEE ALSO | ||
271 | .Xr d2i_X509 3 , | ||
272 | .Xr ERR_get_error 3 , | ||
273 | .Xr X509_get_pubkey 3 | ||