1 .\" $OpenBSD: X509_PUBKEY_new.3,v 1.5 2016/12/28 14:06:06 schwarze Exp $
2 .\" 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: December 28 2016 $
56 .Nm X509_PUBKEY_free ,
65 .Nm X509_PUBKEY_set0_param ,
66 .Nm X509_PUBKEY_get0_param
67 .Nd X.509 SubjectPublicKeyInfo structure
71 .Fn X509_PUBKEY_new void
83 .Fa "X509_PUBKEY *key"
88 .Fa "const unsigned char **pp"
94 .Fa "unsigned char **pp"
117 .Fo X509_PUBKEY_set0_param
118 .Fa "X509_PUBKEY *pub"
119 .Fa "ASN1_OBJECT *aobj"
122 .Fa "unsigned char *penc"
126 .Fo X509_PUBKEY_get0_param
127 .Fa "ASN1_OBJECT **ppkalg"
128 .Fa "const unsigned char **pk"
130 .Fa "X509_ALGOR **pa"
131 .Fa "X509_PUBKEY *pub"
136 structure represents the ASN.1
137 .Vt SubjectPublicKeyInfo
138 structure defined in RFC 5280 section 4.1 and used in certificates
139 and certificate requests.
142 allocates and initializes an
155 pointer, no action occurs.
158 sets the public key in
160 to the public key contained in the
168 any existing public key structure will be freed.
171 returns the public key contained in
174 count on the returned key is incremented so it must be freed using
184 .Vt SubjectPublicKeyInfo
186 For details about the semantics, examples, caveats, and bugs, see
187 .Xr ASN1_item_d2i 3 .
193 are similar except they decode or encode using a
199 .Fn X509_PUBKEY_set0_param
200 sets the public key parameters of
202 The OID associated with the algorithm is set to
204 The type of the algorithm parameters is set to
208 The encoding of the public key itself is set to the
210 bytes contained in buffer
212 On success ownership of all the supplied parameters is passed to
214 so they must not be freed after the call.
216 .Fn X509_PUBKEY_get0_param
217 retrieves the public key parameters from
220 is set to the associated OID and the encoding consists of
226 is set to the associated
227 .Vt AlgorithmIdentifier
229 If the value of any of these parameters is not required,
232 All of the retrieved pointers are internal and must not be freed after
235 If the allocation fails,
239 and sets an error code that can be obtained by
240 .Xr ERR_get_error 3 .
241 Otherwise it returns a pointer to the newly allocated structure.
243 .Fn X509_PUBKEY_get ,
248 return a pointer to an
255 returns the number of bytes successfully encoded or a negative value
258 .Fn X509_PUBKEY_set ,
259 .Fn X509_PUBKEY_set0_param ,
260 .Fn X509_PUBKEY_get0_param ,
264 return 1 for success and 0 if an error occurred.
267 .Xr ERR_get_error 3 ,
268 .Xr X509_ALGOR_new 3 ,
269 .Xr X509_get_pubkey 3
271 RFC 5280: Internet X.509 Public Key Infrastructure Certificate and
272 Certificate Revocation List (CRL) Profile