1PROVIDER-MAC(7ossl)                 OpenSSL                PROVIDER-MAC(7ossl)
2
3
4

NAME

6       provider-mac - The mac library <-> provider functions
7

SYNOPSIS

9        #include <openssl/core_dispatch.h>
10        #include <openssl/core_names.h>
11
12        /*
13         * None of these are actual functions, but are displayed like this for
14         * the function signatures for functions that are offered as function
15         * pointers in OSSL_DISPATCH arrays.
16         */
17
18        /* Context management */
19        void *OSSL_FUNC_mac_newctx(void *provctx);
20        void OSSL_FUNC_mac_freectx(void *mctx);
21        void *OSSL_FUNC_mac_dupctx(void *src);
22
23        /* Encryption/decryption */
24        int OSSL_FUNC_mac_init(void *mctx, unsigned char *key, size_t keylen,
25                               const OSSL_PARAM params[]);
26        int OSSL_FUNC_mac_update(void *mctx, const unsigned char *in, size_t inl);
27        int OSSL_FUNC_mac_final(void *mctx, unsigned char *out, size_t *outl, size_t outsize);
28
29        /* MAC parameter descriptors */
30        const OSSL_PARAM *OSSL_FUNC_mac_gettable_params(void *provctx);
31        const OSSL_PARAM *OSSL_FUNC_mac_gettable_ctx_params(void *mctx, void *provctx);
32        const OSSL_PARAM *OSSL_FUNC_mac_settable_ctx_params(void *mctx, void *provctx);
33
34        /* MAC parameters */
35        int OSSL_FUNC_mac_get_params(OSSL_PARAM params[]);
36        int OSSL_FUNC_mac_get_ctx_params(void *mctx, OSSL_PARAM params[]);
37        int OSSL_FUNC_mac_set_ctx_params(void *mctx, const OSSL_PARAM params[]);
38

DESCRIPTION

40       This documentation is primarily aimed at provider authors. See
41       provider(7) for further information.
42
43       The MAC operation enables providers to implement mac algorithms and
44       make them available to applications via the API functions
45       EVP_MAC_init(3), EVP_MAC_update(3) and EVP_MAC_final(3).
46
47       All "functions" mentioned here are passed as function pointers between
48       libcrypto and the provider in OSSL_DISPATCH arrays via OSSL_ALGORITHM
49       arrays that are returned by the provider's provider_query_operation()
50       function (see "Provider Functions" in provider-base(7)).
51
52       All these "functions" have a corresponding function type definition
53       named OSSL_FUNC_{name}_fn, and a helper function to retrieve the
54       function pointer from an OSSL_DISPATCH element named OSSL_FUNC_{name}.
55       For example, the "function" OSSL_FUNC_mac_newctx() has these:
56
57        typedef void *(OSSL_FUNC_mac_newctx_fn)(void *provctx);
58        static ossl_inline OSSL_FUNC_mac_newctx_fn
59            OSSL_FUNC_mac_newctx(const OSSL_DISPATCH *opf);
60
61       OSSL_DISPATCH arrays are indexed by numbers that are provided as macros
62       in openssl-core_dispatch.h(7), as follows:
63
64        OSSL_FUNC_mac_newctx               OSSL_FUNC_MAC_NEWCTX
65        OSSL_FUNC_mac_freectx              OSSL_FUNC_MAC_FREECTX
66        OSSL_FUNC_mac_dupctx               OSSL_FUNC_MAC_DUPCTX
67
68        OSSL_FUNC_mac_init                 OSSL_FUNC_MAC_INIT
69        OSSL_FUNC_mac_update               OSSL_FUNC_MAC_UPDATE
70        OSSL_FUNC_mac_final                OSSL_FUNC_MAC_FINAL
71
72        OSSL_FUNC_mac_get_params           OSSL_FUNC_MAC_GET_PARAMS
73        OSSL_FUNC_mac_get_ctx_params       OSSL_FUNC_MAC_GET_CTX_PARAMS
74        OSSL_FUNC_mac_set_ctx_params       OSSL_FUNC_MAC_SET_CTX_PARAMS
75
76        OSSL_FUNC_mac_gettable_params      OSSL_FUNC_MAC_GETTABLE_PARAMS
77        OSSL_FUNC_mac_gettable_ctx_params  OSSL_FUNC_MAC_GETTABLE_CTX_PARAMS
78        OSSL_FUNC_mac_settable_ctx_params  OSSL_FUNC_MAC_SETTABLE_CTX_PARAMS
79
80       A mac algorithm implementation may not implement all of these
81       functions.  In order to be a consistent set of functions, at least the
82       following functions must be implemented: OSSL_FUNC_mac_newctx(),
83       OSSL_FUNC_mac_freectx(), OSSL_FUNC_mac_init(), OSSL_FUNC_mac_update(),
84       OSSL_FUNC_mac_final().  All other functions are optional.
85
86   Context Management Functions
87       OSSL_FUNC_mac_newctx() should create and return a pointer to a provider
88       side structure for holding context information during a mac operation.
89       A pointer to this context will be passed back in a number of the other
90       mac operation function calls.  The parameter provctx is the provider
91       context generated during provider initialisation (see provider(7)).
92
93       OSSL_FUNC_mac_freectx() is passed a pointer to the provider side mac
94       context in the mctx parameter.  If it receives NULL as mctx value, it
95       should not do anything other than return.  This function should free
96       any resources associated with that context.
97
98       OSSL_FUNC_mac_dupctx() should duplicate the provider side mac context
99       in the mctx parameter and return the duplicate copy.
100
101   Encryption/Decryption Functions
102       OSSL_FUNC_mac_init() initialises a mac operation given a newly created
103       provider side mac context in the mctx parameter.  The params are set
104       before setting the MAC key of keylen bytes.
105
106       OSSL_FUNC_mac_update() is called to supply data for MAC computation of
107       a previously initialised mac operation.  The mctx parameter contains a
108       pointer to a previously initialised provider side context.
109       OSSL_FUNC_mac_update() may be called multiple times for a single mac
110       operation.
111
112       OSSL_FUNC_mac_final() completes the MAC computation started through
113       previous OSSL_FUNC_mac_init() and OSSL_FUNC_mac_update() calls.  The
114       mctx parameter contains a pointer to the provider side context.  The
115       resulting MAC should be written to out and the amount of data written
116       to *outl, which should not exceed outsize bytes.  The same expectations
117       apply to outsize as documented for EVP_MAC_final(3).
118
119   Mac Parameters
120       See OSSL_PARAM(3) for further details on the parameters structure used
121       by these functions.
122
123       OSSL_FUNC_mac_get_params() gets details of parameter values associated
124       with the provider algorithm and stores them in params.
125
126       OSSL_FUNC_mac_set_ctx_params() sets mac parameters associated with the
127       given provider side mac context mctx to params.  Any parameter settings
128       are additional to any that were previously set.  Passing NULL for
129       params should return true.
130
131       OSSL_FUNC_mac_get_ctx_params() gets details of currently set parameter
132       values associated with the given provider side mac context mctx and
133       stores them in params.  Passing NULL for params should return true.
134
135       OSSL_FUNC_mac_gettable_params(), OSSL_FUNC_mac_gettable_ctx_params(),
136       and OSSL_FUNC_mac_settable_ctx_params() all return constant OSSL_PARAM
137       arrays as descriptors of the parameters that
138       OSSL_FUNC_mac_get_params(), OSSL_FUNC_mac_get_ctx_params(), and
139       OSSL_FUNC_mac_set_ctx_params() can handle, respectively.
140       OSSL_FUNC_mac_gettable_ctx_params() and
141       OSSL_FUNC_mac_settable_ctx_params() will return the parameters
142       associated with the provider side context mctx in its current state if
143       it is not NULL.  Otherwise, they return the parameters associated with
144       the provider side algorithm provctx.
145
146       All MAC implementations are expected to handle the following
147       parameters:
148
149       with OSSL_FUNC_set_ctx_params():
150           "key" (OSSL_MAC_PARAM_KEY) <octet string>
151               Sets the key in the associated MAC ctx.  This is identical to
152               passing a key argument to the OSSL_FUNC_mac_init() function.
153
154       with OSSL_FUNC_get_params():
155           "size" (OSSL_MAC_PARAM_SIZE) <integer>
156               Can be used to get the default MAC size (which might be the
157               only allowable MAC size for the implementation).
158
159               Note that some implementations allow setting the size that the
160               resulting MAC should have as well, see the documentation of the
161               implementation.
162
163           "size" (OSSL_MAC_PARAM_BLOCK_SIZE) <integer>
164               Can be used to get the MAC block size (if supported by the
165               algorithm).
166

NOTES

168       The MAC life-cycle is described in life_cycle-rand(7).  Providers
169       should ensure that the various transitions listed there are supported.
170       At some point the EVP layer will begin enforcing the listed
171       transitions.
172

RETURN VALUES

174       OSSL_FUNC_mac_newctx() and OSSL_FUNC_mac_dupctx() should return the
175       newly created provider side mac context, or NULL on failure.
176
177       OSSL_FUNC_mac_init(), OSSL_FUNC_mac_update(), OSSL_FUNC_mac_final(),
178       OSSL_FUNC_mac_get_params(), OSSL_FUNC_mac_get_ctx_params() and
179       OSSL_FUNC_mac_set_ctx_params() should return 1 for success or 0 on
180       error.
181
182       OSSL_FUNC_mac_gettable_params(), OSSL_FUNC_mac_gettable_ctx_params()
183       and OSSL_FUNC_mac_settable_ctx_params() should return a constant
184       OSSL_PARAM array, or NULL if none is offered.
185

SEE ALSO

187       provider(7), EVP_MAC-BLAKE2(7), EVP_MAC-CMAC(7), EVP_MAC-GMAC(7),
188       EVP_MAC-HMAC(7), EVP_MAC-KMAC(7), EVP_MAC-Poly1305(7),
189       EVP_MAC-Siphash(7), life_cycle-mac(7), EVP_MAC(3)
190

HISTORY

192       The provider MAC interface was introduced in OpenSSL 3.0.
193
195       Copyright 2019-2022 The OpenSSL Project Authors. All Rights Reserved.
196
197       Licensed under the Apache License 2.0 (the "License").  You may not use
198       this file except in compliance with the License.  You can obtain a copy
199       in the file LICENSE in the source distribution or at
200       <https://www.openssl.org/source/license.html>.
201
202
203
2043.0.5                             2022-07-05               PROVIDER-MAC(7ossl)
Impressum