summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/libcrypto/man/EVP_PKEY_new.3215
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
90The 136The
91.Vt EVP_PKEY 137.Vt EVP_PKEY
92structure is used by various OpenSSL functions which require a general 138structure is used by various OpenSSL functions which require a general
93private key without reference to any particular algorithm. 139private or public key without reference to any particular algorithm.
94.Pp 140.Pp
95The 141The
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
105increments the reference count of 151increments the reference count of
106.Fa key 152.Fa pkey
107by 1. 153by 1.
108.Pp 154.Pp
109.Fn EVP_PKEY_free 155.Fn EVP_PKEY_free
110decrements the reference count of 156decrements the reference count of
111.Fa key 157.Fa pkey
112by 1, and if the reference count reaches zero, frees it up. 158by 1, and if the reference count reaches zero, frees it up.
113If 159If
114.Fa key 160.Fa pkey
115is a 161is a
116.Dv NULL 162.Dv NULL
117pointer, no action occurs. 163pointer, no action occurs.
118.Pp 164.Pp
119.Fn EVP_PKEY_new_CMAC_key 165.Fn EVP_PKEY_new_raw_private_key
120allocates a new 166allocates a new
121.Vt EVP_PKEY 167.Vt EVP_PKEY .
122for the
123.Dv EVP_PKEY_CMAC
124algorithm type.
125If 168If
126.Fa e 169.Fa e
127is 170is
128.Pf non- Dv NULL , 171.Pf non- Dv NULL ,
129then the new 172the new structure is associated with the engine
130.Vt EVP_PKEY
131is associated with the engine
132.Fa e . 173.Fa e .
133.Fa priv 174The NID of a public key algorithm that supports raw private keys, i.e.\&
134points to the raw private key data 175.Dv EVP_PKEY_HMAC ,
135of length 176.Dv EVP_PKEY_X25519 ,
136.Fa len 177or
137for this 178.Dv EVP_PKEY_ED25519 ,
138.Vt EVP_PKEY . 179is provided in the
139.Fa cipher 180.Fa type
140specifies a cipher algorithm to be used during creation of the CMAC. 181argument and
182.Fa rawlen
183bytes of raw private key data of that type in
184.Fa rawpriv .
185The public key data is automatically derived from the given private
186key data, if appropriate for the algorithm type.
187.Pp
188.Fn EVP_PKEY_new_raw_public_key
189works in the same way as
190.Fn EVP_PKEY_new_raw_private_key
191except that
192.Fa rawpub
193points to the raw public key data.
194The
195.Vt EVP_PKEY
196structure is initialised without any private key information.
197Algorithm types that support raw public keys are
198.Dv EVP_PKEY_X25519
199and
200.Dv EVP_PKEY_ED25519 .
201.Pp
202.Fn EVP_PKEY_new_CMAC_key
203works in the same way as
204.Fn EVP_PKEY_new_raw_private_key
205except that it only handles the
206.Dv EVP_PKEY_CMAC
207algorithm type.
208The additional
141.Fa cipher 209.Fa cipher
142should be a standard encryption only cipher. 210argument specifies the cipher algorithm
211to be used during the creation of the CMAC.
212It should be a standard encryption only cipher.
143For example, AEAD and XTS ciphers should not be used. 213For 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
146allocates a new 216is a deprecated function that works in the same way as
147.Vt EVP_PKEY . 217.Fn EVP_PKEY_new_raw_private_key .
148If 218.Pp
149.Fa e 219.Fn EVP_PKEY_get_raw_private_key
150is 220writes up to
151.Pf non- Dv NULL , 221.Pf * Fa rawlen
152then the new 222bytes of raw private key data to the buffer starting at
153.Vt EVP_PKEY 223.Fa rawpriv
154structure is associated with the engine 224and stores the number of bytes written in
155.Fa e . 225.Pf * Fa rawlen .
156The 226The calling application is responsible for ensuring that the buffer
157.Fa type 227is large enough to receive the private key data.
158argument indicates what kind of key this is. 228If the
159The value should be a NID for a public key algorithm that supports 229.Fa rawpriv
160raw private keys, for example 230argument is
161.Dv EVP_PKEY_HMAC . 231.Dv NULL ,
162.Fa key 232the number of bytes required to hold the key is stored in
163points to the raw private key data for this 233.Pf * Fa rawlen .
164.Vt EVP_PKEY 234This function only works for algorithms that support raw private keys.
165which should be of length 235Currently these are
166.Fa keylen . 236.Dv EVP_PKEY_HMAC ,
167The length should be appropriate for the type of the key. 237.Dv EVP_PKEY_X25519 ,
168The public key data will be automatically derived from the given 238and
169private key data (if appropriate for the algorithm type). 239.Dv EVP_PKEY_ED25519 .
240.Pp
241.Fn EVP_PKEY_get_raw_public_key
242is similar to
243.Fn EVP_PKEY_get_raw_private_key
244except that it writes raw public key data.
245This function only works for algorithms that support raw public keys.
246Currently these are
247.Dv EVP_PKEY_X25519
248and
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 ,
173and 255and
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
179if an error occurred. 261if an error occurred.
180.Pp 262.Pp
181.Fn EVP_PKEY_up_ref 263.Fn EVP_PKEY_up_ref ,
182returns 1 for success or 0 for failure. 264.Fn EVP_PKEY_get_raw_private_key ,
265and
266.Fn EVP_PKEY_get_raw_public_key
267return 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
215first appeared in OpenSSL 1.1.0 and has been available since 300first 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 ,
306and
307.Fn EVP_PKEY_get_raw_public_key
308first appeared in OpenSSL 1.1.1 and have been available since
309.Ox 7.3 .