1.\" $OpenBSD: EVP_PKEY_asn1_get_count.3,v 1.4 2019/06/06 01:06:58 schwarze Exp $
2.\" full merge up to: OpenSSL 751148e2 Oct 27 00:11:11 2017 +0200
3.\"
4.\" This file was written by Richard Levitte <levitte@openssl.org>.
5.\" Copyright (c) 2017 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: June 6 2019 $
52.Dt EVP_PKEY_ASN1_GET_COUNT 3
53.Os
54.Sh NAME
55.Nm EVP_PKEY_asn1_get_count ,
56.Nm EVP_PKEY_asn1_get0 ,
57.Nm EVP_PKEY_get0_asn1 ,
58.Nm EVP_PKEY_asn1_find ,
59.Nm EVP_PKEY_asn1_find_str ,
60.Nm EVP_PKEY_asn1_get0_info
61.Nd enumerate public key ASN.1 methods
62.Sh SYNOPSIS
63.In openssl/evp.h
64.Ft int
65.Fn EVP_PKEY_asn1_get_count void
66.Ft const EVP_PKEY_ASN1_METHOD *
67.Fo EVP_PKEY_asn1_get0
68.Fa "int idx"
69.Fc
70.Ft const EVP_PKEY_ASN1_METHOD *
71.Fo EVP_PKEY_get0_asn1
72.Fa "const EVP_PKEY *pkey"
73.Fc
74.Ft const EVP_PKEY_ASN1_METHOD *
75.Fo EVP_PKEY_asn1_find
76.Fa "ENGINE **pe"
77.Fa "int type"
78.Fc
79.Ft const EVP_PKEY_ASN1_METHOD *
80.Fo EVP_PKEY_asn1_find_str
81.Fa "ENGINE **pe"
82.Fa "const char *str"
83.Fa "int len"
84.Fc
85.Ft int
86.Fo EVP_PKEY_asn1_get0_info
87.Fa "int *ppkey_id"
88.Fa "int *pkey_base_id"
89.Fa "int *ppkey_flags"
90.Fa "const char **pinfo"
91.Fa "const char **ppem_str"
92.Fa "const EVP_PKEY_ASN1_METHOD *ameth"
93.Fc
94.Sh DESCRIPTION
95.Fn EVP_PKEY_asn1_get_count
96returns a count of the number of public key ASN.1 methods available.
97It includes standard methods and any methods added by the application.
98.Pp
99.Fn EVP_PKEY_asn1_get0
100returns the public key ASN.1 method
101.Fa idx .
102The value of
103.Fa idx
104must be in the range from zero to
105.Fn EVP_PKEY_asn1_get_count
106\- 1.
107.Pp
108.Fn EVP_PKEY_asn1_find
109looks up the method with NID
110.Fa type .
111If
112.Fa pe
113is not
114.Dv NULL ,
115it first looks for an engine implementing a method for the NID
116.Fa type .
117If one is found,
118.Pf * Fa pe
119is set to that engine and the method from that engine is returned instead.
120.Pp
121.Fn EVP_PKEY_asn1_find_str
122looks up the method with PEM type string
123.Fa str .
124Just like
125.Fn EVP_PKEY_asn1_find ,
126if
127.Fa pe
128is not
129.Dv NULL ,
130methods from engines are preferred.
131.Pp
132.Fn EVP_PKEY_asn1_get0_info
133retrieves the public key ID, the base public key ID (both NIDs), any flags,
134the method description and the PEM type string associated with the public
135key ASN.1 method
136.Sy *ameth .
137.Pp
138.Fn EVP_PKEY_asn1_get_count ,
139.Fn EVP_PKEY_asn1_get0 ,
140.Fn EVP_PKEY_asn1_find
141and
142.Fn EVP_PKEY_asn1_find_str
143are not thread safe, but as long as all
144.Vt EVP_PKEY_ASN1_METHOD
145objects are added before the application gets threaded, using them is
146safe.
147See
148.Xr EVP_PKEY_asn1_add0 3 .
149.Sh RETURN VALUES
150.Fn EVP_PKEY_asn1_get_count
151returns the number of available public key methods.
152.Pp
153.Fn EVP_PKEY_asn1_get0
154returns a public key method or
155.Dv NULL
156if
157.Fa idx
158is out of range.
159.Pp
160.Fn EVP_PKEY_get0_asn1
161returns the public key method used by
162.Fa pkey .
163.Pp
164.Fn EVP_PKEY_asn1_get0_info
165returns 1 on success or 0 on failure.
166.Sh SEE ALSO
167.Xr EVP_PKEY_asn1_new 3 ,
168.Xr EVP_PKEY_base_id 3 ,
169.Xr EVP_PKEY_new 3
170.Sh HISTORY
171These functions first appeared in OpenSSL 1.0.0
172and have been available since
173.Ox 4.9 .
174