Debian Codegraph @

upstream/debian-unstable/man7/provider-mac.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 "PROVIDER-MAC 7SSL"
58 .TH PROVIDER-MAC 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 provider\-mac \- The mac library <\-> provider functions
65 .SH SYNOPSIS
66 .IX Header "SYNOPSIS"
67 .Vb 2
68 \& #include <openssl/core_dispatch.h>
69 \& #include <openssl/core_names.h>
70 \&
71 \& /*
72 \& * None of these are actual functions, but are displayed like this for
73 \& * the function signatures for functions that are offered as function
74 \& * pointers in OSSL_DISPATCH arrays.
75 \& */
76 \&
77 \& /* Context management */
78 \& void *OSSL_FUNC_mac_newctx(void *provctx);
79 \& void OSSL_FUNC_mac_freectx(void *mctx);
80 \& void *OSSL_FUNC_mac_dupctx(void *src);
81 \&
82 \& /* Encryption/decryption */
83 \& int OSSL_FUNC_mac_init(void *mctx, unsigned char *key, size_t keylen,
84 \& const OSSL_PARAM params[]);
85 \& int OSSL_FUNC_mac_init_skey(void *mctx, const void *key, const OSSL_PARAM params[]);
86 \& int OSSL_FUNC_mac_update(void *mctx, const unsigned char *in, size_t inl);
87 \& int OSSL_FUNC_mac_final(void *mctx, unsigned char *out, size_t *outl, size_t outsize);
88 \&
89 \& /* MAC parameter descriptors */
90 \& const OSSL_PARAM *OSSL_FUNC_mac_gettable_params(void *provctx);
91 \& const OSSL_PARAM *OSSL_FUNC_mac_gettable_ctx_params(void *mctx, void *provctx);
92 \& const OSSL_PARAM *OSSL_FUNC_mac_settable_ctx_params(void *mctx, void *provctx);
93 \&
94 \& /* MAC parameters */
95 \& int OSSL_FUNC_mac_get_params(OSSL_PARAM params[]);
96 \& int OSSL_FUNC_mac_get_ctx_params(void *mctx, OSSL_PARAM params[]);
97 \& int OSSL_FUNC_mac_set_ctx_params(void *mctx, const OSSL_PARAM params[]);
98 .Ve
99 .SH DESCRIPTION
100 .IX Header "DESCRIPTION"
101 This documentation is primarily aimed at provider authors. See \fBprovider\fR\|(7)
102 for further information.
103 .PP
104 The MAC operation enables providers to implement mac algorithms and make
105 them available to applications via the API functions \fBEVP_MAC_init\fR\|(3),
106 \&\fBEVP_MAC_update\fR\|(3) and \fBEVP_MAC_final\fR\|(3).
107 .PP
108 All "functions" mentioned here are passed as function pointers between
109 \&\fIlibcrypto\fR and the provider in \fBOSSL_DISPATCH\fR\|(3) arrays via
110 \&\fBOSSL_ALGORITHM\fR\|(3) arrays that are returned by the provider's
111 \&\fBprovider_query_operation()\fR function
112 (see "Provider Functions" in \fBprovider\-base\fR\|(7)).
113 .PP
114 All these "functions" have a corresponding function type definition
115 named \fBOSSL_FUNC_{name}_fn\fR, and a helper function to retrieve the
116 function pointer from an \fBOSSL_DISPATCH\fR\|(3) element named
117 \&\fBOSSL_FUNC_{name}\fR.
118 For example, the "function" \fBOSSL_FUNC_mac_newctx()\fR has these:
119 .PP
120 .Vb 3
121 \& typedef void *(OSSL_FUNC_mac_newctx_fn)(void *provctx);
122 \& static ossl_inline OSSL_FUNC_mac_newctx_fn
123 \& OSSL_FUNC_mac_newctx(const OSSL_DISPATCH *opf);
124 .Ve
125 .PP
126 \&\fBOSSL_DISPATCH\fR\|(3) arrays are indexed by numbers that are provided as
127 macros in \fBopenssl\-core_dispatch.h\fR\|(7), as follows:
128 .PP
129 .Vb 3
130 \& OSSL_FUNC_mac_newctx OSSL_FUNC_MAC_NEWCTX
131 \& OSSL_FUNC_mac_freectx OSSL_FUNC_MAC_FREECTX
132 \& OSSL_FUNC_mac_dupctx OSSL_FUNC_MAC_DUPCTX
133 \&
134 \& OSSL_FUNC_mac_init OSSL_FUNC_MAC_INIT
135 \& OSSL_FUNC_mac_init_skey OSSL_FUNC_MAC_INIT_SKEY
136 \& OSSL_FUNC_mac_update OSSL_FUNC_MAC_UPDATE
137 \& OSSL_FUNC_mac_final OSSL_FUNC_MAC_FINAL
138 \&
139 \& OSSL_FUNC_mac_get_params OSSL_FUNC_MAC_GET_PARAMS
140 \& OSSL_FUNC_mac_get_ctx_params OSSL_FUNC_MAC_GET_CTX_PARAMS
141 \& OSSL_FUNC_mac_set_ctx_params OSSL_FUNC_MAC_SET_CTX_PARAMS
142 \&
143 \& OSSL_FUNC_mac_gettable_params OSSL_FUNC_MAC_GETTABLE_PARAMS
144 \& OSSL_FUNC_mac_gettable_ctx_params OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS
145 \& OSSL_FUNC_mac_settable_ctx_params OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS
146 .Ve
147 .PP
148 A mac algorithm implementation may not implement all of these functions.
149 In order to be a consistent set of functions, at least the following functions
150 must be implemented: \fBOSSL_FUNC_mac_newctx()\fR, \fBOSSL_FUNC_mac_freectx()\fR,
151 at least one of \fBOSSL_FUNC_mac_init()\fR or \fBOSSL_FUNC_mac_init_skey()\fR,
152 \&\fBOSSL_FUNC_mac_update()\fR, \fBOSSL_FUNC_mac_final()\fR.
153 All other functions are optional.
154 .SS "Context Management Functions"
155 .IX Subsection "Context Management Functions"
156 \&\fBOSSL_FUNC_mac_newctx()\fR should create and return a pointer to a provider side
157 structure for holding context information during a mac operation.
158 A pointer to this context will be passed back in a number of the other mac
159 operation function calls.
160 The parameter \fIprovctx\fR is the provider context generated during provider
161 initialisation (see \fBprovider\fR\|(7)).
162 .PP
163 \&\fBOSSL_FUNC_mac_freectx()\fR is passed a pointer to the provider side mac context in
164 the \fImctx\fR parameter.
165 If it receives NULL as \fImctx\fR value, it should not do anything other than
166 return.
167 This function should free any resources associated with that context.
168 .PP
169 \&\fBOSSL_FUNC_mac_dupctx()\fR should duplicate the provider side mac context in the
170 \&\fImctx\fR parameter and return the duplicate copy.
171 .SS "Encryption/Decryption Functions"
172 .IX Subsection "Encryption/Decryption Functions"
173 \&\fBOSSL_FUNC_mac_init()\fR initialises a mac operation given a newly created provider
174 side mac context in the \fImctx\fR parameter. The \fIparams\fR are set before setting
175 the MAC \fIkey\fR of \fIkeylen\fR bytes.
176 .PP
177 \&\fBOSSL_FUNC_mac_init_skey()\fR is similar but uses an opaque provider-specific object
178 to initialize the MAC context.
179 .PP
180 \&\fBOSSL_FUNC_mac_update()\fR is called to supply data for MAC computation of a previously
181 initialised mac operation.
182 The \fImctx\fR parameter contains a pointer to a previously initialised provider
183 side context.
184 \&\fBOSSL_FUNC_mac_update()\fR may be called multiple times for a single mac operation.
185 .PP
186 \&\fBOSSL_FUNC_mac_final()\fR completes the MAC computation started through previous
187 \&\fBOSSL_FUNC_mac_init()\fR and \fBOSSL_FUNC_mac_update()\fR calls.
188 The \fImctx\fR parameter contains a pointer to the provider side context.
189 The resulting MAC should be written to \fIout\fR and the amount of data written
190 to \fI*outl\fR, which should not exceed \fIoutsize\fR bytes.
191 The same expectations apply to \fIoutsize\fR as documented for
192 \&\fBEVP_MAC_final\fR\|(3).
193 .SS "Mac Parameters"
194 .IX Subsection "Mac Parameters"
195 See \fBOSSL_PARAM\fR\|(3) for further details on the parameters structure used by
196 these functions.
197 .PP
198 \&\fBOSSL_FUNC_mac_get_params()\fR gets details of parameter values associated with the
199 provider algorithm and stores them in \fIparams\fR.
200 .PP
201 \&\fBOSSL_FUNC_mac_set_ctx_params()\fR sets mac parameters associated with the given
202 provider side mac context \fImctx\fR to \fIparams\fR.
203 Any parameter settings are additional to any that were previously set.
204 Passing NULL for \fIparams\fR should return true.
205 .PP
206 \&\fBOSSL_FUNC_mac_get_ctx_params()\fR gets details of currently set parameter values
207 associated with the given provider side mac context \fImctx\fR and stores them
208 in \fIparams\fR.
209 Passing NULL for \fIparams\fR should return true.
210 .PP
211 \&\fBOSSL_FUNC_mac_gettable_params()\fR, \fBOSSL_FUNC_mac_gettable_ctx_params()\fR,
212 and \fBOSSL_FUNC_mac_settable_ctx_params()\fR all return constant \fBOSSL_PARAM\fR\|(3)
213 arrays as descriptors of the parameters that \fBOSSL_FUNC_mac_get_params()\fR,
214 \&\fBOSSL_FUNC_mac_get_ctx_params()\fR, and \fBOSSL_FUNC_mac_set_ctx_params()\fR
215 can handle, respectively. \fBOSSL_FUNC_mac_gettable_ctx_params()\fR and
216 \&\fBOSSL_FUNC_mac_settable_ctx_params()\fR will return the parameters associated
217 with the provider side context \fImctx\fR in its current state if it is
218 not NULL. Otherwise, they return the parameters associated with the
219 provider side algorithm \fIprovctx\fR.
220 .PP
221 All MAC implementations are expected to handle the following parameters:
222 .IP "with \fBOSSL_FUNC_set_ctx_params()\fR:" 4
223 .IX Item "with OSSL_FUNC_set_ctx_params():"
224 .RS 4
225 .PD 0
226 .IP """key"" (\fBOSSL_MAC_PARAM_KEY\fR) <octet string>" 4
227 .IX Item """key"" (OSSL_MAC_PARAM_KEY) <octet string>"
228 .PD
229 Sets the key in the associated MAC ctx. This is identical to passing a \fIkey\fR
230 argument to the \fBOSSL_FUNC_mac_init()\fR function.
231 .RE
232 .RS 4
233 .RE
234 .IP "with \fBOSSL_FUNC_get_params()\fR:" 4
235 .IX Item "with OSSL_FUNC_get_params():"
236 .RS 4
237 .PD 0
238 .IP """size"" (\fBOSSL_MAC_PARAM_SIZE\fR) <integer>" 4
239 .IX Item """size"" (OSSL_MAC_PARAM_SIZE) <integer>"
240 .PD
241 Can be used to get the default MAC size (which might be the only allowable
242 MAC size for the implementation).
243 .Sp
244 Note that some implementations allow setting the size that the resulting MAC
245 should have as well, see the documentation of the implementation.
246 .RE
247 .RS 4
248 .IP """size"" (\fBOSSL_MAC_PARAM_BLOCK_SIZE\fR) <integer>" 4
249 .IX Item """size"" (OSSL_MAC_PARAM_BLOCK_SIZE) <integer>"
250 Can be used to get the MAC block size (if supported by the algorithm).
251 .RE
252 .RS 4
253 .RE
254 .PP
255 The OpenSSL FIPS provider may support the following parameters:
256 .IP """fips-indicator"" (\fBOSSL_MAC_PARAM_FIPS_APPROVED_INDICATOR\fR) <int>" 4
257 .IX Item """fips-indicator"" (OSSL_MAC_PARAM_FIPS_APPROVED_INDICATOR) <int>"
258 A getter that returns 1 if the operation is FIPS approved, or 0 otherwise.
259 This may be used after calling the final function. It may return 0 if
260 either "no-short-mac" or "key-check" are set to 0.
261 .IP """no-short-mac"" (\fBOSSL_MAC_PARAM_FIPS_NO_SHORT_MAC\fR) <integer>" 4
262 .IX Item """no-short-mac"" (OSSL_MAC_PARAM_FIPS_NO_SHORT_MAC) <integer>"
263 If required this parameter should be set early via an init function.
264 The default value of 1 causes an error when too short MAC output is
265 asked for. Setting this to 0 will ignore the error and set the approved
266 "fips-indicator" to 0.
267 This option breaks FIPS compliance if it causes the approved "fips-indicator"
268 to return 0.
269 .IP """key-check"" (\fBOSSL_MAC_PARAM_FIPS_KEY_CHECK\fR) <integer>" 4
270 .IX Item """key-check"" (OSSL_MAC_PARAM_FIPS_KEY_CHECK) <integer>"
271 If required this parameter should be set before OSSL_FUNC_mac_init.
272 The default value of 1 causes an error when small key sizes are
273 asked for. Setting this to 0 will ignore the error and set the approved
274 "fips-indicator" to 0.
275 This option breaks FIPS compliance if it causes the approved "fips-indicator"
276 to return 0.
277 .SH NOTES
278 .IX Header "NOTES"
279 The MAC life-cycle is described in \fBlife_cycle\-rand\fR\|(7). Providers should
280 ensure that the various transitions listed there are supported. At some point
281 the EVP layer will begin enforcing the listed transitions.
282 .SH "RETURN VALUES"
283 .IX Header "RETURN VALUES"
284 \&\fBOSSL_FUNC_mac_newctx()\fR and \fBOSSL_FUNC_mac_dupctx()\fR should return the newly created
285 provider side mac context, or NULL on failure.
286 .PP
287 \&\fBOSSL_FUNC_mac_init()\fR, \fBOSSL_FUNC_mac_init_skey()\fR,
288 \&\fBOSSL_FUNC_mac_update()\fR, \fBOSSL_FUNC_mac_final()\fR, \fBOSSL_FUNC_mac_get_params()\fR,
289 \&\fBOSSL_FUNC_mac_get_ctx_params()\fR and \fBOSSL_FUNC_mac_set_ctx_params()\fR should return 1 for
290 success or 0 on error.
291 .PP
292 \&\fBOSSL_FUNC_mac_gettable_params()\fR, \fBOSSL_FUNC_mac_gettable_ctx_params()\fR and
293 \&\fBOSSL_FUNC_mac_settable_ctx_params()\fR should return a constant \fBOSSL_PARAM\fR\|(3)
294 array, or NULL if none is offered.
295 .SH "SEE ALSO"
296 .IX Header "SEE ALSO"
297 \&\fBprovider\fR\|(7),
298 \&\fBEVP_MAC\-BLAKE2\fR\|(7), \fBEVP_MAC\-CMAC\fR\|(7), \fBEVP_MAC\-GMAC\fR\|(7),
299 \&\fBEVP_MAC\-HMAC\fR\|(7), \fBEVP_MAC\-KMAC\fR\|(7), \fBEVP_MAC\-Poly1305\fR\|(7),
300 \&\fBEVP_MAC\-Siphash\fR\|(7),
301 \&\fBlife_cycle\-mac\fR\|(7), \fBEVP_MAC\fR\|(3)
302 .SH HISTORY
303 .IX Header "HISTORY"
304 The provider MAC interface was introduced in OpenSSL 3.0.
305 The parameters "no-short-mac" and "fips-indicator" were added in OpenSSL 3.4.
306 .PP
307 The function \fBOSSL_FUNC_mac_init_skey()\fR was introduced in OpenSSL 3.5.
308 .SH COPYRIGHT
309 .IX Header "COPYRIGHT"
310 Copyright 2019\-2025 The OpenSSL Project Authors. All Rights Reserved.
311 .PP
312 Licensed under the Apache License 2.0 (the "License"). You may not use
313 this file except in compliance with the License. You can obtain a copy
314 in the file LICENSE in the source distribution or at
315 <https://www.openssl.org/source/license.html>.