summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschwarze <>2020-06-24 16:06:27 +0000
committerschwarze <>2020-06-24 16:06:27 +0000
commit0957e35e584e81a70ad31e3756c631131ed5bba9 (patch)
treef63d9d8a23d818ff1055d16836d58ad95cce4489
parent971de0313dae5e09ce7bb6d784903540cad611cf (diff)
downloadopenbsd-0957e35e584e81a70ad31e3756c631131ed5bba9.tar.gz
openbsd-0957e35e584e81a70ad31e3756c631131ed5bba9.tar.bz2
openbsd-0957e35e584e81a70ad31e3756c631131ed5bba9.zip
new manual page CMAC_Init(3);
OK tb@
-rw-r--r--src/lib/libcrypto/man/CMAC_Init.3287
-rw-r--r--src/lib/libcrypto/man/EVP_DigestInit.35
-rw-r--r--src/lib/libcrypto/man/HMAC.35
-rw-r--r--src/lib/libcrypto/man/Makefile3
-rw-r--r--src/lib/libcrypto/man/crypto.35
5 files changed, 298 insertions, 7 deletions
diff --git a/src/lib/libcrypto/man/CMAC_Init.3 b/src/lib/libcrypto/man/CMAC_Init.3
new file mode 100644
index 0000000000..55196b3213
--- /dev/null
+++ b/src/lib/libcrypto/man/CMAC_Init.3
@@ -0,0 +1,287 @@
1.\" $OpenBSD: CMAC_Init.3,v 1.1 2020/06/24 16:06:27 schwarze Exp $
2.\"
3.\" Copyright (c) 2020 Ingo Schwarze <schwarze@openbsd.org>
4.\"
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
8.\"
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
16.\"
17.Dd $Mdocdate: June 24 2020 $
18.Dt CMAC_INIT 3
19.Os
20.Sh NAME
21.Nm CMAC_CTX_new ,
22.Nm CMAC_Init ,
23.Nm CMAC_Update ,
24.Nm CMAC_Final ,
25.Nm CMAC_resume ,
26.Nm CMAC_CTX_copy ,
27.Nm CMAC_CTX_get0_cipher_ctx ,
28.Nm CMAC_CTX_cleanup ,
29.Nm CMAC_CTX_free
30.Nd Cipher-based message authentication code
31.Sh SYNOPSIS
32.In openssl/cmac.h
33.Ft CMAC_CTX *
34.Fn CMAC_CTX_new void
35.Ft int
36.Fo CMAC_Init
37.Fa "CMAC_CTX *ctx"
38.Fa "const void *key"
39.Fa "size_t key_len"
40.Fa "const EVP_CIPHER *cipher"
41.Fa "ENGINE *impl"
42.Fc
43.Ft int
44.Fo CMAC_Update
45.Fa "CMAC_CTX *ctx"
46.Fa "const void *in_data"
47.Fa "size_t in_len"
48.Fc
49.Ft int
50.Fo CMAC_Final
51.Fa "CMAC_CTX *ctx"
52.Fa "unsigned char *out_mac"
53.Fa "size_t *out_len"
54.Fc
55.Ft int
56.Fn CMAC_resume "CMAC_CTX *ctx"
57.Ft int
58.Fo CMAC_CTX_copy
59.Fa "CMAC_CTX *out_ctx"
60.Fa "CMAC_CTX *in_ctx"
61.Fc
62.Ft EVP_CIPHER_CTX *
63.Fn CMAC_CTX_get0_cipher_ctx "CMAC_CTX *ctx"
64.Ft void
65.Fn CMAC_CTX_cleanup "CMAC_CTX *ctx"
66.Ft void
67.Fn CMAC_CTX_free "CMAC_CTX *ctx"
68.Sh DESCRIPTION
69CMAC is a message authentication code algorithm that can employ an
70arbitrary block cipher using a symmetric key.
71.Pp
72The present manual page describes low-level functions implementing CMAC.
73Instead of using these functions directly,
74application programs normally call
75.Xr EVP_PKEY_CTX_new_id 3
76with an argument of
77.Dv EVP_PKEY_CMAC
78and then pass the resulting
79.Vt EVP_MD_CTX
80object to
81.Xr EVP_DigestInit_ex 3 .
82.Pp
83The CMAC API is object-oriented.
84Calculating a message authentication code requires a
85.Vt CMAC_CTX
86object.
87Usually, the functions
88.Fn CMAC_CTX_new ,
89.Fn CMAC_Init ,
90.Fn CMAC_Update ,
91.Fn CMAC_Final ,
92and
93.Fn CMAC_CTX_free
94need to be called in this order.
95.Pp
96.Fn CMAC_CTX_new
97allocates a new
98.Vt CMAC_CTX
99object, initializes the embedded
100.Vt EVP_CIPHER_CTX
101object, and marks the object itself as uninitialized.
102.Pp
103.Fn CMAC_Init
104selects the given block
105.Fa cipher
106for use by
107.Fa ctx .
108Funtions to obtain suitable
109.Vt EVP_CIPHER
110objects are listed in the CIPHER LISTING section of the
111.Xr EVP_Cipher 3
112manual page.
113Unless
114.Fa key
115is
116.Dv NULL ,
117.Fn CMAC_Init
118also initializes
119.Fa ctx
120for use with the given symmetric
121.Fa key
122that is
123.Fa key_len
124bytes long.
125In particular, it calculates and internally stores the two subkeys
126and initializes
127.Fa ctx
128for subsequently feeding in data with
129.Fn CMAC_Update .
130To use the default cipher implementations provided by the library, pass
131.Dv NULL
132as the
133.Fa impl
134argument.
135.Pp
136If
137.Fa ctx
138is already initialized,
139.Fn CMAC_Init
140can be called again with
141.Fa key ,
142.Fa cipher ,
143and
144.Fa impl
145all set to
146.Dv NULL
147and
148.Fa key_len
149set to 0.
150In that case, any data already processed is discarded and
151.Fa ctx
152is re-initialized to start reading data anew.
153.Pp
154.Fn CMAC_Update
155processes
156.Fa in_len
157bytes of input data pointed to by
158.Fa in_data .
159Depending on the number of input bytes already cached in
160.Fa ctx ,
161on
162.Fa in_len ,
163and on the block size, this may encrypt zero or more blocks.
164Unless
165.Fa in_len
166is zero, this function leaves at least one byte and at most one
167block of input cached but unprocessed inside the
168.Fa ctx
169object.
170.Fn CMAC_Update
171can be called multiple times
172to concatenate several chunks of input data of varying sizes.
173.Pp
174.Fn CMAC_Final
175stores the length of the message authentication code in bytes,
176which equals the cipher block size, into
177.Pf * Fa out_len .
178Unless
179.Fa out_mac
180is
181.Dv NULL ,
182it encrypts the last block, padding it if required, and copies the
183resulting message authentication code to
184.Fa out_mac .
185The caller is responsible for providing a buffer of sufficient size.
186.Pp
187Calling
188.Fn CMAC_resume
189after
190.Fn CMAC_Final
191allows to subsequently append additional data with
192.Fn CMAC_Update .
193.Pp
194.Fn CMAC_CTX_copy
195performs a deep copy of the already initialized
196.Fa in_ctx
197into
198.Fa out_ctx .
199.Pp
200.Fn CMAC_CTX_cleanup
201zeros out both subkeys and all temporary data in
202.Fa ctx
203and in the embedded
204.Vt EVP_CIPHER_CTX
205object, frees all allocated memory associated with it,
206except for
207.Fa ctx
208itself, and marks it as uninitialized,
209such that it can be reused for subsequent
210.Fn CMAC_Init .
211.Pp
212.Fn CMAC_CTX_free
213calls
214.Fn CMAC_CTX_cleanup ,
215then frees
216.Fa ctx
217itself.
218If
219.Fa ctx
220is
221.Dv NULL ,
222no action occurs.
223.Sh RETURN VALUES
224.Fn CMAC_CTX_new
225returns the new context object or
226.Dv NULL
227in case of failure.
228It succeeds unless memory is exhausted.
229.Pp
230.Fn CMAC_Init ,
231.Fn CMAC_Update ,
232.Fn CMAC_Final ,
233.Fn CMAC_resume ,
234and
235.Fn CMAC_CTX_copy
236return 1 on success or 0 on failure.
237.Fn CMAC_Init
238fails if initializing the embedded
239.Vt EVP_CIPHER_CTX
240object fails.
241The others fail if
242.Fa in_ctx
243is uninitialized.
244.Fn CMAC_Update
245and
246.Fn CMAC_Final
247also fail if encrypting a block fails, and
248.Fn CMAC_CTX_copy
249if copying the embedded
250.Vt EVP_CIPHER_CTX
251object fails, which can for example happen when memory is exhausted.
252.Pp
253.Fn CMAC_CTX_get0_cipher_ctx
254returns an internal pointer to the
255.Vt EVP_CIPHER_CTX
256object that is embedded in
257.Fa ctx .
258.Sh ERRORS
259The CMAC code itself does not use the
260.In openssl/err.h
261framework, so in general, the reasons for failure cannot be found out with
262.Xr ERR_get_error 3 .
263However, since the
264.Xr EVP_Cipher 3
265functions are used internally, entries may still get pushed onto
266the error stack in some cases of failure.
267.Sh SEE ALSO
268.Xr EVP_aes_128_cbc 3 ,
269.Xr EVP_Cipher 3 ,
270.Xr EVP_DigestInit 3 ,
271.Xr EVP_PKEY_CTX_new_id 3 ,
272.Xr HMAC 3
273.Sh STANDARDS
274.Rs
275.%A Morris Dworkin
276.%T "Recommendation for Block Cipher Modes of Operation:\
277 The CMAC Mode for Authentication"
278.%I National Institute of Standards and Technology
279.%R NIST Special Publication 800-38B
280.%U https://doi.org/10.6028/NIST.SP.800-38B
281.%C Gaithersburg, Maryland
282.%D May 2005, updated October 6, 2016
283.Re
284.Sh HISTORY
285These functions first appeared in OpenSSL 1.0.1
286and have been available since
287.Ox 5.3 .
diff --git a/src/lib/libcrypto/man/EVP_DigestInit.3 b/src/lib/libcrypto/man/EVP_DigestInit.3
index cefd546af3..d8f452fe4c 100644
--- a/src/lib/libcrypto/man/EVP_DigestInit.3
+++ b/src/lib/libcrypto/man/EVP_DigestInit.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: EVP_DigestInit.3,v 1.18 2019/08/25 17:08:20 schwarze Exp $ 1.\" $OpenBSD: EVP_DigestInit.3,v 1.19 2020/06/24 16:06:27 schwarze Exp $
2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000 2.\" full merge up to: OpenSSL 7f572e95 Dec 2 13:57:04 2015 +0000
3.\" selective merge up to: OpenSSL a95d7574 Jul 2 12:16:38 2017 -0400 3.\" selective merge up to: OpenSSL a95d7574 Jul 2 12:16:38 2017 -0400
4.\" 4.\"
@@ -68,7 +68,7 @@
68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 68.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
69.\" OF THE POSSIBILITY OF SUCH DAMAGE. 69.\" OF THE POSSIBILITY OF SUCH DAMAGE.
70.\" 70.\"
71.Dd $Mdocdate: August 25 2019 $ 71.Dd $Mdocdate: June 24 2020 $
72.Dt EVP_DIGESTINIT 3 72.Dt EVP_DIGESTINIT 3
73.Os 73.Os
74.Sh NAME 74.Sh NAME
@@ -671,6 +671,7 @@ main(int argc, char *argv[])
671.Ed 671.Ed
672.Sh SEE ALSO 672.Sh SEE ALSO
673.Xr BIO_f_md 3 , 673.Xr BIO_f_md 3 ,
674.Xr CMAC_Init 3 ,
674.Xr evp 3 , 675.Xr evp 3 ,
675.Xr EVP_BytesToKey 3 , 676.Xr EVP_BytesToKey 3 ,
676.Xr EVP_DigestSignInit 3 , 677.Xr EVP_DigestSignInit 3 ,
diff --git a/src/lib/libcrypto/man/HMAC.3 b/src/lib/libcrypto/man/HMAC.3
index b2a0e2836e..b76d8b2869 100644
--- a/src/lib/libcrypto/man/HMAC.3
+++ b/src/lib/libcrypto/man/HMAC.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: HMAC.3,v 1.16 2019/12/14 09:04:51 tb Exp $ 1.\" $OpenBSD: HMAC.3,v 1.17 2020/06/24 16:06:27 schwarze Exp $
2.\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400 2.\" full merge up to: OpenSSL crypto/hmac a528d4f0 Oct 27 13:40:11 2015 -0400
3.\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400 3.\" selective merge up to: OpenSSL man3/HMAC b3696a55 Sep 2 09:35:50 2017 -0400
4.\" 4.\"
@@ -52,7 +52,7 @@
52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 52.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
53.\" OF THE POSSIBILITY OF SUCH DAMAGE. 53.\" OF THE POSSIBILITY OF SUCH DAMAGE.
54.\" 54.\"
55.Dd $Mdocdate: December 14 2019 $ 55.Dd $Mdocdate: June 24 2020 $
56.Dt HMAC 3 56.Dt HMAC 3
57.Os 57.Os
58.Sh NAME 58.Sh NAME
@@ -365,6 +365,7 @@ if none was set.
365returns the length in bytes of the underlying hash function output 365returns the length in bytes of the underlying hash function output
366or 0 on error. 366or 0 on error.
367.Sh SEE ALSO 367.Sh SEE ALSO
368.Xr CMAC_Init 3 ,
368.Xr EVP_DigestInit 3 369.Xr EVP_DigestInit 3
369.Sh STANDARDS 370.Sh STANDARDS
370RFC 2104 371RFC 2104
diff --git a/src/lib/libcrypto/man/Makefile b/src/lib/libcrypto/man/Makefile
index c613fdc293..de6e446f2f 100644
--- a/src/lib/libcrypto/man/Makefile
+++ b/src/lib/libcrypto/man/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.168 2020/06/12 11:37:42 schwarze Exp $ 1# $OpenBSD: Makefile,v 1.169 2020/06/24 16:06:26 schwarze Exp $
2 2
3.include <bsd.own.mk> 3.include <bsd.own.mk>
4 4
@@ -68,6 +68,7 @@ MAN= \
68 BN_swap.3 \ 68 BN_swap.3 \
69 BN_zero.3 \ 69 BN_zero.3 \
70 BUF_MEM_new.3 \ 70 BUF_MEM_new.3 \
71 CMAC_Init.3 \
71 CMS_ContentInfo_new.3 \ 72 CMS_ContentInfo_new.3 \
72 CMS_add0_cert.3 \ 73 CMS_add0_cert.3 \
73 CMS_add1_recipient_cert.3 \ 74 CMS_add1_recipient_cert.3 \
diff --git a/src/lib/libcrypto/man/crypto.3 b/src/lib/libcrypto/man/crypto.3
index cbc03543ae..9f29698e80 100644
--- a/src/lib/libcrypto/man/crypto.3
+++ b/src/lib/libcrypto/man/crypto.3
@@ -1,4 +1,4 @@
1.\" $OpenBSD: crypto.3,v 1.23 2019/11/02 15:28:04 schwarze Exp $ 1.\" $OpenBSD: crypto.3,v 1.24 2020/06/24 16:06:27 schwarze Exp $
2.\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100 2.\" OpenSSL a9c85cea Nov 11 09:33:55 2016 +0100
3.\" 3.\"
4.\" This file was written by Ulf Moeller <ulf@openssl.org> and 4.\" This file was written by Ulf Moeller <ulf@openssl.org> and
@@ -49,7 +49,7 @@
49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 49.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50.\" OF THE POSSIBILITY OF SUCH DAMAGE. 50.\" OF THE POSSIBILITY OF SUCH DAMAGE.
51.\" 51.\"
52.Dd $Mdocdate: November 2 2019 $ 52.Dd $Mdocdate: June 24 2020 $
53.Dt CRYPTO 3 53.Dt CRYPTO 3
54.Os 54.Os
55.Sh NAME 55.Sh NAME
@@ -93,6 +93,7 @@ and
93.Sy Authentication codes and hash functions 93.Sy Authentication codes and hash functions
94offered include 94offered include
95.Xr EVP_DigestInit 3 , 95.Xr EVP_DigestInit 3 ,
96.Xr CMAC_Init 3 ,
96.Xr HMAC 3 , 97.Xr HMAC 3 ,
97.Xr MD4 3 , 98.Xr MD4 3 ,
98.Xr MD5 3 , 99.Xr MD5 3 ,