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

NOTES

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

RETURN VALUES

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

SEE ALSO

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

HISTORY

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