1 .\" $OpenBSD: X509_PUBKEY_new.3,v 1.13 2018/03/27 17:35:50 schwarze Exp $
2 .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400
4 .\" This file was written by Dr. Stephen Henson <steve@openssl.org>.
5 .\" Copyright (c) 2016 The OpenSSL Project. All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
11 .\" 1. Redistributions of source code must retain the above copyright
12 .\" notice, this list of conditions and the following disclaimer.
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
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/)"
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.
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.
33 .\" 6. Redistributions of any form whatsoever must retain the following
35 .\" "This product includes software developed by the OpenSSL Project
36 .\" for use in the OpenSSL Toolkit (http://www.openssl.org/)"
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.
51 .Dd $Mdocdate: March 27 2018 $
56 .Nm X509_PUBKEY_free ,
58 .Nm X509_PUBKEY_get0 ,
66 .Nm X509_PUBKEY_set0_param ,
67 .Nm X509_PUBKEY_get0_param
68 .Nd X.509 SubjectPublicKeyInfo structure
72 .Fn X509_PUBKEY_new void
84 .Fa "X509_PUBKEY *key"
88 .Fa "X509_PUBKEY *key"
93 .Fa "const unsigned char **pp"
99 .Fa "unsigned char **pp"
122 .Fo X509_PUBKEY_set0_param
123 .Fa "X509_PUBKEY *pub"
124 .Fa "ASN1_OBJECT *aobj"
127 .Fa "unsigned char *penc"
131 .Fo X509_PUBKEY_get0_param
132 .Fa "ASN1_OBJECT **ppkalg"
133 .Fa "const unsigned char **pk"
135 .Fa "X509_ALGOR **pa"
136 .Fa "X509_PUBKEY *pub"
141 structure represents the ASN.1
142 .Vt SubjectPublicKeyInfo
143 structure defined in RFC 5280 section 4.1 and used in certificates
144 and certificate requests.
147 allocates and initializes an
160 pointer, no action occurs.
163 sets the public key in
165 to the public key contained in the
173 any existing public key structure will be freed.
176 returns the public key contained in
178 The returned value is an internal pointer which must not be freed after use.
183 except that the reference
184 count on the returned key is incremented so it must be freed using
194 .Vt SubjectPublicKeyInfo
196 For details about the semantics, examples, caveats, and bugs, see
197 .Xr ASN1_item_d2i 3 .
203 are similar except they decode or encode using a
209 .Fn X509_PUBKEY_set0_param
210 sets the public key parameters of
212 The OID associated with the algorithm is set to
214 The type of the algorithm parameters is set to
218 The encoding of the public key itself is set to the
220 bytes contained in buffer
222 On success ownership of all the supplied parameters is passed to
224 so they must not be freed after the call.
226 .Fn X509_PUBKEY_get0_param
227 retrieves the public key parameters from
230 is set to the associated OID and the encoding consists of
236 is set to the associated
237 .Vt AlgorithmIdentifier
239 If the value of any of these parameters is not required,
242 All of the retrieved pointers are internal and must not be freed after
245 If the allocation fails,
249 and sets an error code that can be obtained by
250 .Xr ERR_get_error 3 .
251 Otherwise it returns a pointer to the newly allocated structure.
253 .Fn X509_PUBKEY_get0 ,
254 .Fn X509_PUBKEY_get ,
259 return a pointer to an
266 returns the number of bytes successfully encoded or a negative value
269 .Fn X509_PUBKEY_set ,
270 .Fn X509_PUBKEY_set0_param ,
271 .Fn X509_PUBKEY_get0_param ,
275 return 1 for success and 0 if an error occurred.
278 .Xr ERR_get_error 3 ,
279 .Xr EVP_PKEY_asn1_set_public 3 ,
280 .Xr X509_ALGOR_new 3 ,
281 .Xr X509_get_pubkey 3
283 RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
284 Certificate Revocation List (CRL) Profile
289 appeared in SSLeay 0.4 or earlier.
293 first appeared in SSLeay 0.8.0.
294 These functions have been available since
300 first appeared in OpenSSL 0.9.5 and have been available since
308 first appeared in OpenSSL 0.9.6 and have been available since
311 .Fn X509_PUBKEY_set0_param
313 .Fn X509_PUBKEY_get0_param
314 first appeared in OpenSSL 1.0.0 and have been available since
318 first appeared in OpenSSL 1.1.0 and has been available since