Debian Codegraph @

upstream/debian-unstable/man3/EVP_PKEY_is_a.3ssl

raw
1 .\" -*- mode: troff; coding: utf-8 -*-
2 .\" Automatically generated by Pod::Man 5.0102 (Pod::Simple 3.45)
3 .\"
4 .\" Standard preamble:
5 .\" ========================================================================
6 .de Sp \" Vertical space (when we can't use .PP)
7 .if t .sp .5v
8 .if n .sp
9 ..
10 .de Vb \" Begin verbatim text
11 .ft CW
12 .nf
13 .ne \\$1
14 ..
15 .de Ve \" End verbatim text
16 .ft R
17 .fi
18 ..
19 .\" \*(C` and \*(C' are quotes in nroff, nothing in troff, for use with C<>.
20 .ie n \{\
21 . ds C` ""
22 . ds C' ""
23 'br\}
24 .el\{\
25 . ds C`
26 . ds C'
27 'br\}
28 .\"
29 .\" Escape single quotes in literal strings from groff's Unicode transform.
30 .ie \n(.g .ds Aq \(aq
31 .el .ds Aq '
32 .\"
33 .\" If the F register is >0, we'll generate index entries on stderr for
34 .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index
35 .\" entries marked with X<> in POD. Of course, you'll have to process the
36 .\" output yourself in some meaningful fashion.
37 .\"
38 .\" Avoid warning from groff about undefined register 'F'.
39 .de IX
40 ..
41 .nr rF 0
42 .if \n(.g .if rF .nr rF 1
43 .if (\n(rF:(\n(.g==0)) \{\
44 . if \nF \{\
45 . de IX
46 . tm Index:\\$1\t\\n%\t"\\$2"
47 ..
48 . if !\nF==2 \{\
49 . nr % 0
50 . nr F 2
51 . \}
52 . \}
53 .\}
54 .rr rF
55 .\" ========================================================================
56 .\"
57 .IX Title "EVP_PKEY_IS_A 3SSL"
58 .TH EVP_PKEY_IS_A 3SSL 2026-04-07 3.6.2 OpenSSL
59 .\" For nroff, turn off justification. Always turn off hyphenation; it makes
60 .\" way too many mistakes in technical documents.
61 .if n .ad l
62 .nh
63 .SH NAME
64 EVP_PKEY_is_a, EVP_PKEY_can_sign, EVP_PKEY_type_names_do_all,
65 EVP_PKEY_get0_type_name, EVP_PKEY_get0_description, EVP_PKEY_get0_provider
66 \&\- key type and capabilities functions
67 .SH SYNOPSIS
68 .IX Header "SYNOPSIS"
69 .Vb 1
70 \& #include <openssl/evp.h>
71 \&
72 \& int EVP_PKEY_is_a(const EVP_PKEY *pkey, const char *name);
73 \& int EVP_PKEY_can_sign(const EVP_PKEY *pkey);
74 \& int EVP_PKEY_type_names_do_all(const EVP_PKEY *pkey,
75 \& void (*fn)(const char *name, void *data),
76 \& void *data);
77 \& const char *EVP_PKEY_get0_type_name(const EVP_PKEY *key);
78 \& const char *EVP_PKEY_get0_description(const EVP_PKEY *key);
79 \& const OSSL_PROVIDER *EVP_PKEY_get0_provider(const EVP_PKEY *key);
80 .Ve
81 .SH DESCRIPTION
82 .IX Header "DESCRIPTION"
83 \&\fBEVP_PKEY_is_a()\fR checks if the key type of \fIpkey\fR is \fIname\fR.
84 .PP
85 \&\fBEVP_PKEY_can_sign()\fR checks if the functionality for the key type of
86 \&\fIpkey\fR supports signing. No other check is done, such as whether
87 \&\fIpkey\fR contains a private key.
88 .PP
89 \&\fBEVP_PKEY_type_names_do_all()\fR traverses all names for \fIpkey\fR's key type, and
90 calls \fIfn\fR with each name and \fIdata\fR. For example, an RSA \fBEVP_PKEY\fR may
91 be named both \f(CW\*(C`RSA\*(C'\fR and \f(CW\*(C`rsaEncryption\*(C'\fR.
92 The order of the names depends on the provider implementation that holds
93 the key.
94 .PP
95 \&\fBEVP_PKEY_get0_type_name()\fR returns the first key type name that is found
96 for the given \fIpkey\fR. Note that the \fIpkey\fR may have multiple synonyms
97 associated with it. In this case it depends on the provider implementation
98 that holds the key which one will be returned.
99 Ownership of the returned string is retained by the \fIpkey\fR object and should
100 not be freed by the caller.
101 .PP
102 \&\fBEVP_PKEY_get0_description()\fR returns a description of the type of \fBEVP_PKEY\fR,
103 meant for display and human consumption. The description is at the
104 discretion of the key type implementation.
105 .PP
106 \&\fBEVP_PKEY_get0_provider()\fR returns the provider of the \fBEVP_PKEY\fR's
107 \&\fBEVP_KEYMGMT\fR\|(3).
108 .SH "RETURN VALUES"
109 .IX Header "RETURN VALUES"
110 \&\fBEVP_PKEY_is_a()\fR returns 1 if \fIpkey\fR has the key type \fIname\fR,
111 otherwise 0.
112 .PP
113 \&\fBEVP_PKEY_can_sign()\fR returns 1 if the \fIpkey\fR key type functionality
114 supports signing, otherwise 0.
115 .PP
116 \&\fBEVP_PKEY_get0_type_name()\fR returns the name that is found or NULL on error.
117 .PP
118 \&\fBEVP_PKEY_get0_description()\fR returns the description if found or NULL if not.
119 .PP
120 \&\fBEVP_PKEY_get0_provider()\fR returns the provider if found or NULL if not.
121 .PP
122 \&\fBEVP_PKEY_type_names_do_all()\fR returns 1 if the callback was called for all
123 names. A return value of 0 means that the callback was not called for any
124 names.
125 .SH EXAMPLES
126 .IX Header "EXAMPLES"
127 .SS \fBEVP_PKEY_is_a()\fP
128 .IX Subsection "EVP_PKEY_is_a()"
129 The loaded providers and what key types they support will ultimately
130 determine what \fIname\fR is possible to use with \fBEVP_PKEY_is_a()\fR. We do know
131 that the default provider supports RSA, DH, DSA and EC keys, so we can use
132 this as an crude example:
133 .PP
134 .Vb 1
135 \& #include <openssl/evp.h>
136 \&
137 \& ...
138 \& /* |pkey| is an EVP_PKEY* */
139 \& if (EVP_PKEY_is_a(pkey, "RSA")) {
140 \& BIGNUM *modulus = NULL;
141 \& if (EVP_PKEY_get_bn_param(pkey, "n", &modulus))
142 \& /* do whatever with the modulus */
143 \& BN_free(modulus);
144 \& }
145 .Ve
146 .SS \fBEVP_PKEY_can_sign()\fP
147 .IX Subsection "EVP_PKEY_can_sign()"
148 .Vb 1
149 \& #include <openssl/evp.h>
150 \&
151 \& ...
152 \& /* |pkey| is an EVP_PKEY* */
153 \& if (!EVP_PKEY_can_sign(pkey)) {
154 \& fprintf(stderr, "Not a signing key!");
155 \& exit(1);
156 \& }
157 \& /* Sign something... */
158 .Ve
159 .SH HISTORY
160 .IX Header "HISTORY"
161 The functions described here were added in OpenSSL 3.0.
162 .SH COPYRIGHT
163 .IX Header "COPYRIGHT"
164 Copyright 2020\-2021 The OpenSSL Project Authors. All Rights Reserved.
165 .PP
166 Licensed under the Apache License 2.0 (the "License"). You may not use
167 this file except in compliance with the License. You can obtain a copy
168 in the file LICENSE in the source distribution or at
169 <https://www.openssl.org/source/license.html>.