diff options
author | schwarze <> | 2022-12-14 22:37:07 +0000 |
---|---|---|
committer | schwarze <> | 2022-12-14 22:37:07 +0000 |
commit | 7f2f732a1be4573b42d1fcc3b373c438f7ca8702 (patch) | |
tree | 7dd9a4ed3627fe6cdcf944fb6aa31c108a75a2c3 /src/lib | |
parent | d9e3943030541e040267eae757ca0e630396979b (diff) | |
download | openbsd-7f2f732a1be4573b42d1fcc3b373c438f7ca8702.tar.gz openbsd-7f2f732a1be4573b42d1fcc3b373c438f7ca8702.tar.bz2 openbsd-7f2f732a1be4573b42d1fcc3b373c438f7ca8702.zip |
In evp.h rev. 1.109 and 1.112, jsing@ and tb@ provided
EVP_PKEY_new_raw_private_key(3), EVP_PKEY_new_raw_public_key(3),
EVP_PKEY_get_raw_private_key(3), and EVP_PKEY_get_raw_public_key(3).
Merge the documentation from the OpenSSL 1.1.1 branch, which is
still under a free license. I tweaked the text somewhat for
conciseness, and argument names for uniformity.
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/man/EVP_PKEY_new.3 | 215 |
1 files changed, 154 insertions, 61 deletions
diff --git a/src/lib/libcrypto/man/EVP_PKEY_new.3 b/src/lib/libcrypto/man/EVP_PKEY_new.3 index c5673a66f3..3b9611990a 100644 --- a/src/lib/libcrypto/man/EVP_PKEY_new.3 +++ b/src/lib/libcrypto/man/EVP_PKEY_new.3 | |||
@@ -1,10 +1,26 @@ | |||
1 | .\" $OpenBSD: EVP_PKEY_new.3,v 1.17 2022/07/13 21:51:35 schwarze Exp $ | 1 | .\" $OpenBSD: EVP_PKEY_new.3,v 1.18 2022/12/14 22:37:07 schwarze Exp $ |
2 | .\" full merge up to: OpenSSL 99d63d46 Oct 26 13:56:48 2016 -0400 | 2 | .\" full merge up to: OpenSSL 4dcfdfce May 27 11:50:05 2020 +0100 |
3 | .\" selective merge up to: OpenSSL df75c2bf Dec 9 01:02:36 2018 +0100 | ||
4 | .\" | 3 | .\" |
5 | .\" This file was written by Dr. Stephen Henson <steve@openssl.org> | 4 | .\" This file is a derived work. |
5 | .\" The changes are covered by the following Copyright and license: | ||
6 | .\" | ||
7 | .\" Copyright (c) 2022 Ingo Schwarze <schwarze@openbsd.org> | ||
8 | .\" | ||
9 | .\" Permission to use, copy, modify, and distribute this software for any | ||
10 | .\" purpose with or without fee is hereby granted, provided that the above | ||
11 | .\" copyright notice and this permission notice appear in all copies. | ||
12 | .\" | ||
13 | .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES | ||
14 | .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF | ||
15 | .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR | ||
16 | .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES | ||
17 | .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN | ||
18 | .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF | ||
19 | .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
20 | .\" | ||
21 | .\" The original file was written by Dr. Stephen Henson <steve@openssl.org> | ||
6 | .\" and Matt Caswell <matt@openssl.org>. | 22 | .\" and Matt Caswell <matt@openssl.org>. |
7 | .\" Copyright (c) 2002, 2018 The OpenSSL Project. All rights reserved. | 23 | .\" Copyright (c) 2002, 2018, 2020 The OpenSSL Project. All rights reserved. |
8 | .\" | 24 | .\" |
9 | .\" Redistribution and use in source and binary forms, with or without | 25 | .\" Redistribution and use in source and binary forms, with or without |
10 | .\" modification, are permitted provided that the following conditions | 26 | .\" modification, are permitted provided that the following conditions |
@@ -50,47 +66,77 @@ | |||
50 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 66 | .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
51 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. | 67 | .\" OF THE POSSIBILITY OF SUCH DAMAGE. |
52 | .\" | 68 | .\" |
53 | .Dd $Mdocdate: July 13 2022 $ | 69 | .Dd $Mdocdate: December 14 2022 $ |
54 | .Dt EVP_PKEY_NEW 3 | 70 | .Dt EVP_PKEY_NEW 3 |
55 | .Os | 71 | .Os |
56 | .Sh NAME | 72 | .Sh NAME |
57 | .Nm EVP_PKEY_new , | 73 | .Nm EVP_PKEY_new , |
58 | .Nm EVP_PKEY_up_ref , | 74 | .Nm EVP_PKEY_up_ref , |
59 | .Nm EVP_PKEY_free , | 75 | .Nm EVP_PKEY_free , |
76 | .Nm EVP_PKEY_new_raw_private_key , | ||
77 | .Nm EVP_PKEY_new_raw_public_key , | ||
60 | .Nm EVP_PKEY_new_CMAC_key , | 78 | .Nm EVP_PKEY_new_CMAC_key , |
61 | .Nm EVP_PKEY_new_mac_key | 79 | .Nm EVP_PKEY_new_mac_key , |
62 | .Nd private key allocation functions | 80 | .Nm EVP_PKEY_get_raw_private_key , |
81 | .Nm EVP_PKEY_get_raw_public_key | ||
82 | .Nd public and private key allocation and raw key handling functions | ||
63 | .Sh SYNOPSIS | 83 | .Sh SYNOPSIS |
64 | .In openssl/evp.h | 84 | .In openssl/evp.h |
65 | .Ft EVP_PKEY * | 85 | .Ft EVP_PKEY * |
66 | .Fn EVP_PKEY_new void | 86 | .Fn EVP_PKEY_new void |
67 | .Ft int | 87 | .Ft int |
68 | .Fo EVP_PKEY_up_ref | 88 | .Fo EVP_PKEY_up_ref |
69 | .Fa "EVP_PKEY *key" | 89 | .Fa "EVP_PKEY *pkey" |
70 | .Fc | 90 | .Fc |
71 | .Ft void | 91 | .Ft void |
72 | .Fo EVP_PKEY_free | 92 | .Fo EVP_PKEY_free |
73 | .Fa "EVP_PKEY *key" | 93 | .Fa "EVP_PKEY *pkey" |
94 | .Fc | ||
95 | .Ft EVP_PKEY * | ||
96 | .Fo EVP_PKEY_new_raw_private_key | ||
97 | .Fa "int type" | ||
98 | .Fa "ENGINE *e" | ||
99 | .Fa "const unsigned char *rawpriv" | ||
100 | .Fa "size_t rawlen" | ||
101 | .Fc | ||
102 | .Ft EVP_PKEY * | ||
103 | .Fo EVP_PKEY_new_raw_public_key | ||
104 | .Fa "int type" | ||
105 | .Fa "ENGINE *e" | ||
106 | .Fa "const unsigned char *rawpub" | ||
107 | .Fa "size_t rawlen" | ||
74 | .Fc | 108 | .Fc |
75 | .Ft EVP_PKEY * | 109 | .Ft EVP_PKEY * |
76 | .Fo EVP_PKEY_new_CMAC_key | 110 | .Fo EVP_PKEY_new_CMAC_key |
77 | .Fa "ENGINE *e" | 111 | .Fa "ENGINE *e" |
78 | .Fa "const unsigned char *priv" | 112 | .Fa "const unsigned char *rawpriv" |
79 | .Fa "size_t len" | 113 | .Fa "size_t rawlen" |
80 | .Fa "const EVP_CIPHER *cipher" | 114 | .Fa "const EVP_CIPHER *cipher" |
81 | .Fc | 115 | .Fc |
82 | .Ft EVP_PKEY * | 116 | .Ft EVP_PKEY * |
83 | .Fo EVP_PKEY_new_mac_key | 117 | .Fo EVP_PKEY_new_mac_key |
84 | .Fa "int type" | 118 | .Fa "int type" |
85 | .Fa "ENGINE *e" | 119 | .Fa "ENGINE *e" |
86 | .Fa "const unsigned char *key" | 120 | .Fa "const unsigned char *rawpriv" |
87 | .Fa "int keylen" | 121 | .Fa "int rawlen" |
122 | .Fc | ||
123 | .Ft int | ||
124 | .Fo EVP_PKEY_get_raw_private_key | ||
125 | .Fa "const EVP_PKEY *pkey" | ||
126 | .Fa "unsigned char *rawpriv" | ||
127 | .Fa "size_t *rawlen" | ||
128 | .Fc | ||
129 | .Ft int | ||
130 | .Fo EVP_PKEY_get_raw_public_key | ||
131 | .Fa "const EVP_PKEY *pkey" | ||
132 | .Fa "unsigned char *rawpub" | ||
133 | .Fa "size_t *rawlen" | ||
88 | .Fc | 134 | .Fc |
89 | .Sh DESCRIPTION | 135 | .Sh DESCRIPTION |
90 | The | 136 | The |
91 | .Vt EVP_PKEY | 137 | .Vt EVP_PKEY |
92 | structure is used by various OpenSSL functions which require a general | 138 | structure is used by various OpenSSL functions which require a general |
93 | private key without reference to any particular algorithm. | 139 | private or public key without reference to any particular algorithm. |
94 | .Pp | 140 | .Pp |
95 | The | 141 | The |
96 | .Fn EVP_PKEY_new | 142 | .Fn EVP_PKEY_new |
@@ -103,72 +149,108 @@ To add a private or public key to it, use the functions described in | |||
103 | .Pp | 149 | .Pp |
104 | .Fn EVP_PKEY_up_ref | 150 | .Fn EVP_PKEY_up_ref |
105 | increments the reference count of | 151 | increments the reference count of |
106 | .Fa key | 152 | .Fa pkey |
107 | by 1. | 153 | by 1. |
108 | .Pp | 154 | .Pp |
109 | .Fn EVP_PKEY_free | 155 | .Fn EVP_PKEY_free |
110 | decrements the reference count of | 156 | decrements the reference count of |
111 | .Fa key | 157 | .Fa pkey |
112 | by 1, and if the reference count reaches zero, frees it up. | 158 | by 1, and if the reference count reaches zero, frees it up. |
113 | If | 159 | If |
114 | .Fa key | 160 | .Fa pkey |
115 | is a | 161 | is a |
116 | .Dv NULL | 162 | .Dv NULL |
117 | pointer, no action occurs. | 163 | pointer, no action occurs. |
118 | .Pp | 164 | .Pp |
119 | .Fn EVP_PKEY_new_CMAC_key | 165 | .Fn EVP_PKEY_new_raw_private_key |
120 | allocates a new | 166 | allocates a new |
121 | .Vt EVP_PKEY | 167 | .Vt EVP_PKEY . |
122 | for the | ||
123 | .Dv EVP_PKEY_CMAC | ||
124 | algorithm type. | ||
125 | If | 168 | If |
126 | .Fa e | 169 | .Fa e |
127 | is | 170 | is |
128 | .Pf non- Dv NULL , | 171 | .Pf non- Dv NULL , |
129 | then the new | 172 | the new structure is associated with the engine |
130 | .Vt EVP_PKEY | ||
131 | is associated with the engine | ||
132 | .Fa e . | 173 | .Fa e . |
133 | .Fa priv | 174 | The NID of a public key algorithm that supports raw private keys, i.e.\& |
134 | points to the raw private key data | 175 | .Dv EVP_PKEY_HMAC , |
135 | of length | 176 | .Dv EVP_PKEY_X25519 , |
136 | .Fa len | 177 | or |
137 | for this | 178 | .Dv EVP_PKEY_ED25519 , |
138 | .Vt EVP_PKEY . | 179 | is provided in the |
139 | .Fa cipher | 180 | .Fa type |
140 | specifies a cipher algorithm to be used during creation of the CMAC. | 181 | argument and |
182 | .Fa rawlen | ||
183 | bytes of raw private key data of that type in | ||
184 | .Fa rawpriv . | ||
185 | The public key data is automatically derived from the given private | ||
186 | key data, if appropriate for the algorithm type. | ||
187 | .Pp | ||
188 | .Fn EVP_PKEY_new_raw_public_key | ||
189 | works in the same way as | ||
190 | .Fn EVP_PKEY_new_raw_private_key | ||
191 | except that | ||
192 | .Fa rawpub | ||
193 | points to the raw public key data. | ||
194 | The | ||
195 | .Vt EVP_PKEY | ||
196 | structure is initialised without any private key information. | ||
197 | Algorithm types that support raw public keys are | ||
198 | .Dv EVP_PKEY_X25519 | ||
199 | and | ||
200 | .Dv EVP_PKEY_ED25519 . | ||
201 | .Pp | ||
202 | .Fn EVP_PKEY_new_CMAC_key | ||
203 | works in the same way as | ||
204 | .Fn EVP_PKEY_new_raw_private_key | ||
205 | except that it only handles the | ||
206 | .Dv EVP_PKEY_CMAC | ||
207 | algorithm type. | ||
208 | The additional | ||
141 | .Fa cipher | 209 | .Fa cipher |
142 | should be a standard encryption only cipher. | 210 | argument specifies the cipher algorithm |
211 | to be used during the creation of the CMAC. | ||
212 | It should be a standard encryption only cipher. | ||
143 | For example, AEAD and XTS ciphers should not be used. | 213 | For example, AEAD and XTS ciphers should not be used. |
144 | .Pp | 214 | .Pp |
145 | .Fn EVP_PKEY_new_mac_key | 215 | .Fn EVP_PKEY_new_mac_key |
146 | allocates a new | 216 | is a deprecated function that works in the same way as |
147 | .Vt EVP_PKEY . | 217 | .Fn EVP_PKEY_new_raw_private_key . |
148 | If | 218 | .Pp |
149 | .Fa e | 219 | .Fn EVP_PKEY_get_raw_private_key |
150 | is | 220 | writes up to |
151 | .Pf non- Dv NULL , | 221 | .Pf * Fa rawlen |
152 | then the new | 222 | bytes of raw private key data to the buffer starting at |
153 | .Vt EVP_PKEY | 223 | .Fa rawpriv |
154 | structure is associated with the engine | 224 | and stores the number of bytes written in |
155 | .Fa e . | 225 | .Pf * Fa rawlen . |
156 | The | 226 | The calling application is responsible for ensuring that the buffer |
157 | .Fa type | 227 | is large enough to receive the private key data. |
158 | argument indicates what kind of key this is. | 228 | If the |
159 | The value should be a NID for a public key algorithm that supports | 229 | .Fa rawpriv |
160 | raw private keys, for example | 230 | argument is |
161 | .Dv EVP_PKEY_HMAC . | 231 | .Dv NULL , |
162 | .Fa key | 232 | the number of bytes required to hold the key is stored in |
163 | points to the raw private key data for this | 233 | .Pf * Fa rawlen . |
164 | .Vt EVP_PKEY | 234 | This function only works for algorithms that support raw private keys. |
165 | which should be of length | 235 | Currently these are |
166 | .Fa keylen . | 236 | .Dv EVP_PKEY_HMAC , |
167 | The length should be appropriate for the type of the key. | 237 | .Dv EVP_PKEY_X25519 , |
168 | The public key data will be automatically derived from the given | 238 | and |
169 | private key data (if appropriate for the algorithm type). | 239 | .Dv EVP_PKEY_ED25519 . |
240 | .Pp | ||
241 | .Fn EVP_PKEY_get_raw_public_key | ||
242 | is similar to | ||
243 | .Fn EVP_PKEY_get_raw_private_key | ||
244 | except that it writes raw public key data. | ||
245 | This function only works for algorithms that support raw public keys. | ||
246 | Currently these are | ||
247 | .Dv EVP_PKEY_X25519 | ||
248 | and | ||
249 | .Dv EVP_PKEY_ED25519 . | ||
170 | .Sh RETURN VALUES | 250 | .Sh RETURN VALUES |
171 | .Fn EVP_PKEY_new , | 251 | .Fn EVP_PKEY_new , |
252 | .Fn EVP_PKEY_new_raw_private_key , | ||
253 | .Fn EVP_PKEY_new_raw_public_key , | ||
172 | .Fn EVP_PKEY_new_CMAC_key , | 254 | .Fn EVP_PKEY_new_CMAC_key , |
173 | and | 255 | and |
174 | .Fn EVP_PKEY_new_mac_key | 256 | .Fn EVP_PKEY_new_mac_key |
@@ -178,8 +260,11 @@ structure or | |||
178 | .Dv NULL | 260 | .Dv NULL |
179 | if an error occurred. | 261 | if an error occurred. |
180 | .Pp | 262 | .Pp |
181 | .Fn EVP_PKEY_up_ref | 263 | .Fn EVP_PKEY_up_ref , |
182 | returns 1 for success or 0 for failure. | 264 | .Fn EVP_PKEY_get_raw_private_key , |
265 | and | ||
266 | .Fn EVP_PKEY_get_raw_public_key | ||
267 | return 1 for success or 0 for failure. | ||
183 | .Sh SEE ALSO | 268 | .Sh SEE ALSO |
184 | .Xr CMAC_Init 3 , | 269 | .Xr CMAC_Init 3 , |
185 | .Xr d2i_PrivateKey 3 , | 270 | .Xr d2i_PrivateKey 3 , |
@@ -214,3 +299,11 @@ first appeared in OpenSSL 1.0.0 and has been available since | |||
214 | .Fn EVP_PKEY_up_ref | 299 | .Fn EVP_PKEY_up_ref |
215 | first appeared in OpenSSL 1.1.0 and has been available since | 300 | first appeared in OpenSSL 1.1.0 and has been available since |
216 | .Ox 6.3 . | 301 | .Ox 6.3 . |
302 | .Pp | ||
303 | .Fn EVP_PKEY_new_raw_private_key , | ||
304 | .Fn EVP_PKEY_new_raw_public_key , | ||
305 | .Fn EVP_PKEY_get_raw_private_key , | ||
306 | and | ||
307 | .Fn EVP_PKEY_get_raw_public_key | ||
308 | first appeared in OpenSSL 1.1.1 and have been available since | ||
309 | .Ox 7.3 . | ||