Debian Codegraph @

upstream/debian-unstable/man7/EVP_MAC-KMAC.7ssl

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_MAC-KMAC 7SSL"
58 .TH EVP_MAC-KMAC 7SSL 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_MAC\-KMAC, EVP_MAC\-KMAC128, EVP_MAC\-KMAC256
65 \&\- The KMAC EVP_MAC implementations
66 .SH DESCRIPTION
67 .IX Header "DESCRIPTION"
68 Support for computing KMAC MACs through the \fBEVP_MAC\fR API.
69 .SS Identity
70 .IX Subsection "Identity"
71 These implementations are identified with one of these names and
72 properties, to be used with \fBEVP_MAC_fetch()\fR:
73 .IP """KMAC\-128"", ""provider=default"" or ""provider=fips""" 4
74 .IX Item """KMAC-128"", ""provider=default"" or ""provider=fips"""
75 .PD 0
76 .IP """KMAC\-256"", ""provider=default"" or ""provider=fips""" 4
77 .IX Item """KMAC-256"", ""provider=default"" or ""provider=fips"""
78 .PD
79 .SS "Supported parameters"
80 .IX Subsection "Supported parameters"
81 The general description of these parameters can be found in
82 "PARAMETERS" in \fBEVP_MAC\fR\|(3).
83 .PP
84 All these parameters (except for "block-size") can be set with
85 \&\fBEVP_MAC_CTX_set_params()\fR.
86 Furthermore, the "size" parameter can be retrieved with
87 \&\fBEVP_MAC_CTX_get_params()\fR, or with \fBEVP_MAC_CTX_get_mac_size()\fR.
88 The length of the "size" parameter should not exceed that of a \fBsize_t\fR.
89 Likewise, the "block-size" parameter can be retrieved with
90 \&\fBEVP_MAC_CTX_get_params()\fR, or with \fBEVP_MAC_CTX_get_block_size()\fR.
91 .IP """key"" (\fBOSSL_MAC_PARAM_KEY\fR) <octet string>" 4
92 .IX Item """key"" (OSSL_MAC_PARAM_KEY) <octet string>"
93 Sets the MAC key.
94 Setting this parameter is identical to passing a \fIkey\fR to \fBEVP_MAC_init\fR\|(3).
95 The length of the key (in bytes) must be in the range 4...512.
96 .IP """custom"" (\fBOSSL_MAC_PARAM_CUSTOM\fR) <octet string>" 4
97 .IX Item """custom"" (OSSL_MAC_PARAM_CUSTOM) <octet string>"
98 Sets the customization string.
99 It is an optional value with a length of at most 512 bytes, and is
100 empty by default.
101 .IP """size"" (\fBOSSL_MAC_PARAM_SIZE\fR) <unsigned integer>" 4
102 .IX Item """size"" (OSSL_MAC_PARAM_SIZE) <unsigned integer>"
103 Sets the MAC size.
104 By default, it is 32 for \f(CW\*(C`KMAC\-128\*(C'\fR and 64 for \f(CW\*(C`KMAC\-256\*(C'\fR.
105 .IP """block-size"" (\fBOSSL_MAC_PARAM_BLOCK_SIZE\fR) <unsigned integer>" 4
106 .IX Item """block-size"" (OSSL_MAC_PARAM_BLOCK_SIZE) <unsigned integer>"
107 Gets the MAC block size.
108 It is 168 for \f(CW\*(C`KMAC\-128\*(C'\fR and 136 for \f(CW\*(C`KMAC\-256\*(C'\fR.
109 .IP """xof"" (\fBOSSL_MAC_PARAM_XOF\fR) <integer>" 4
110 .IX Item """xof"" (OSSL_MAC_PARAM_XOF) <integer>"
111 The "xof" parameter value is expected to be 1 or 0. Use 1 to enable XOF mode.
112 The default value is 0.
113 .IP """fips-indicator"" (\fBOSSL_MAC_PARAM_FIPS_APPROVED_INDICATOR\fR) <int>" 4
114 .IX Item """fips-indicator"" (OSSL_MAC_PARAM_FIPS_APPROVED_INDICATOR) <int>"
115 This settable parameter is described in \fBprovider\-mac\fR\|(7).
116 .IP """no-short-mac"" (\fBOSSL_MAC_PARAM_FIPS_NO_SHORT_MAC\fR) <integer>" 4
117 .IX Item """no-short-mac"" (OSSL_MAC_PARAM_FIPS_NO_SHORT_MAC) <integer>"
118 This settable parameter is described in \fBprovider\-mac\fR\|(7). It is used by
119 the OpenSSL FIPS provider and the minimum length output for KMAC
120 is defined by NIST's SP 800\-185 8.4.2.
121 .IP """key-check"" (\fBOSSL_MAC_PARAM_FIPS_KEY_CHECK\fR) <integer>" 4
122 .IX Item """key-check"" (OSSL_MAC_PARAM_FIPS_KEY_CHECK) <integer>"
123 This settable parameter is described in \fBprovider\-mac\fR\|(7).
124 .PP
125 The "custom" and "no-short-mac" parameters must be set as part of or before
126 the \fBEVP_MAC_init()\fR call.
127 The "xof" and "size" parameters can be set at any time before \fBEVP_MAC_final()\fR.
128 The "key" parameter is set as part of the \fBEVP_MAC_init()\fR call, but can be
129 set before it instead.
130 .SH EXAMPLES
131 .IX Header "EXAMPLES"
132 .Vb 2
133 \& #include <openssl/evp.h>
134 \& #include <openssl/params.h>
135 \&
136 \& static int do_kmac(const unsigned char *in, size_t in_len,
137 \& const unsigned char *key, size_t key_len,
138 \& const unsigned char *custom, size_t custom_len,
139 \& int xof_enabled, unsigned char *out, int out_len)
140 \& {
141 \& EVP_MAC_CTX *ctx = NULL;
142 \& EVP_MAC *mac = NULL;
143 \& OSSL_PARAM params[4], *p;
144 \& int ret = 0;
145 \& size_t l = 0;
146 \&
147 \& mac = EVP_MAC_fetch(NULL, "KMAC\-128", NULL);
148 \& if (mac == NULL)
149 \& goto err;
150 \& ctx = EVP_MAC_CTX_new(mac);
151 \& /* The mac can be freed after it is used by EVP_MAC_CTX_new */
152 \& EVP_MAC_free(mac);
153 \& if (ctx == NULL)
154 \& goto err;
155 \&
156 \& /*
157 \& * Setup parameters required before calling EVP_MAC_init()
158 \& * The parameters OSSL_MAC_PARAM_XOF and OSSL_MAC_PARAM_SIZE may also be
159 \& * used at this point.
160 \& */
161 \& p = params;
162 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_KEY,
163 \& (void *)key, key_len);
164 \& if (custom != NULL && custom_len != 0)
165 \& *p++ = OSSL_PARAM_construct_octet_string(OSSL_MAC_PARAM_CUSTOM,
166 \& (void *)custom, custom_len);
167 \& *p = OSSL_PARAM_construct_end();
168 \& if (!EVP_MAC_CTX_set_params(ctx, params))
169 \& goto err;
170 \&
171 \& if (!EVP_MAC_init(ctx))
172 \& goto err;
173 \&
174 \& /*
175 \& * Note: the following optional parameters can be set any time
176 \& * before EVP_MAC_final().
177 \& */
178 \& p = params;
179 \& *p++ = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_XOF, &xof_enabled);
180 \& *p++ = OSSL_PARAM_construct_int(OSSL_MAC_PARAM_SIZE, &out_len);
181 \& *p = OSSL_PARAM_construct_end();
182 \& if (!EVP_MAC_CTX_set_params(ctx, params))
183 \& goto err;
184 \&
185 \& /* The update may be called multiple times here for streamed input */
186 \& if (!EVP_MAC_update(ctx, in, in_len))
187 \& goto err;
188 \& if (!EVP_MAC_final(ctx, out, &l, out_len))
189 \& goto err;
190 \& ret = 1;
191 \& err:
192 \& EVP_MAC_CTX_free(ctx);
193 \& return ret;
194 \& }
195 .Ve
196 .SH "SEE ALSO"
197 .IX Header "SEE ALSO"
198 \&\fBEVP_MAC_CTX_get_params\fR\|(3), \fBEVP_MAC_CTX_set_params\fR\|(3),
199 "PARAMETERS" in \fBEVP_MAC\fR\|(3), \fBOSSL_PARAM\fR\|(3),
200 SP 800\-185 8.4.2 <https://nvlpubs.nist.gov/nistpubs/SpecialPublications/NIST.SP.800-185.pdf>
201 .SH COPYRIGHT
202 .IX Header "COPYRIGHT"
203 Copyright 2018\-2024 The OpenSSL Project Authors. All Rights Reserved.
204 .PP
205 Licensed under the Apache License 2.0 (the "License"). You may not use
206 this file except in compliance with the License. You can obtain a copy
207 in the file LICENSE in the source distribution or at
208 <https://www.openssl.org/source/license.html>.