MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Aead.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2024 NXP */
3/* */
4/* SPDX-License-Identifier: BSD-3-Clause */
5/* */
6/* Redistribution and use in source and binary forms, with or without */
7/* modification, are permitted provided that the following conditions are */
8/* met: */
9/* */
10/* 1. Redistributions of source code must retain the above copyright */
11/* notice, this list of conditions and the following disclaimer. */
12/* */
13/* 2. Redistributions in binary form must reproduce the above copyright */
14/* notice, this list of conditions and the following disclaimer in the */
15/* documentation and/or other materials provided with the distribution. */
16/* */
17/* 3. Neither the name of the copyright holder nor the names of its */
18/* contributors may be used to endorse or promote products derived from */
19/* this software without specific prior written permission. */
20/* */
21/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS */
22/* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED */
23/* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A */
24/* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
25/* HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
26/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
27/* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR */
28/* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
29/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
30/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
31/* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
32/*--------------------------------------------------------------------------*/
33
42
49#ifndef MCUXCLELS_AEAD_H_
50#define MCUXCLELS_AEAD_H_
51
52#include <mcuxClConfig.h> // Exported features flags header
53#include <mcuxClEls_Common.h> // Common functionality
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58
59/**********************************************
60 * CONSTANTS
61 **********************************************/
74#define MCUXCLELS_AEAD_ENCRYPT ((uint8_t)0x00U)
75#define MCUXCLELS_AEAD_DECRYPT ((uint8_t)0x01U)
76
77#define MCUXCLELS_AEAD_STATE_IN_DISABLE ((uint8_t)0x00U)
78#define MCUXCLELS_AEAD_STATE_IN_ENABLE ((uint8_t)0x01U)
79
80#define MCUXCLELS_AEAD_LASTINIT_TRUE (0x01U)
81#define MCUXCLELS_AEAD_LASTINIT_FALSE (0x00U)
82
83#define MCUXCLELS_AEAD_EXTERN_KEY ((uint8_t)0x01U)
84#define MCUXCLELS_AEAD_INTERN_KEY ((uint8_t)0x00U)
85
86#define MCUXCLELS_AEAD_ACPMOD_INIT ((uint8_t)0x00U)
87#define MCUXCLELS_AEAD_ACPMOD_AADPROC ((uint8_t)0x01U)
88#define MCUXCLELS_AEAD_ACPMOD_MSGPROC ((uint8_t)0x02U)
89#define MCUXCLELS_AEAD_ACPMOD_FINAL ((uint8_t)0x03U)
90
91#ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
92#define MCUXCLELS_AEAD_STATE_OUT_ENABLE ((uint8_t)0x01U)
93#endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
97
98#define MCUXCLELS_AEAD_IV_BLOCK_SIZE 16U
99#define MCUXCLELS_AEAD_AAD_BLOCK_SIZE 16U
100#define MCUXCLELS_AEAD_TAG_SIZE 16U
101#define MCUXCLELS_AEAD_CONTEXT_SIZE 80U
105
106/**********************************************
107 * TYPEDEFS
108 **********************************************/
118typedef union
119{
120 struct
121 {
122 uint32_t value;
123 } word;
124 struct
125 {
126 uint32_t :1;
127 uint32_t dcrpt :1;
128 uint32_t acpmod :2;
129#ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
130 uint32_t acpsoe :1;
131#else
132 uint32_t :1;
133#endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
134 uint32_t acpsie :1;
135 uint32_t msgendw :4;
136 uint32_t lastinit :1;
137 uint32_t :2;
138 uint32_t extkey :1;
139 uint32_t :18;
140 } bits;
142
145
146/**********************************************
147 * FUNCTIONS
148 **********************************************/
155
206 uint8_t const * pKey,
207 size_t keyLength,
208 uint8_t const * pIV,
209 size_t ivLength,
210 uint8_t * pAeadCtx
211 );
212
266 uint8_t const * pKey,
267 size_t keyLength,
268 uint8_t const * pIV,
269 size_t ivLength,
270 uint8_t * pAeadCtx
271 );
272
328 uint8_t const * pKey,
329 size_t keyLength,
330 uint8_t const * pAad,
331 size_t aadLength,
332 uint8_t * pAeadCtx
333 );
334
393 uint8_t const * pKey,
394 size_t keyLength,
395 uint8_t const * pInput,
396 size_t inputLength,
397 uint8_t * pOutput,
398 uint8_t * pAeadCtx
399 );
400
459 uint8_t const * pKey,
460 size_t keyLength,
461 size_t aadLength,
462 size_t dataLength,
463 uint8_t * pTag,
464 uint8_t * pAeadCtx
465 );
466
467#ifdef __cplusplus
468} /* extern "C" */
469#endif
470
471#endif /* MCUXCLELS_AEAD_H_ */
472
ELS header for common functionality.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Aead_UpdateData_Async(mcuxClEls_AeadOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pInput, size_t inputLength, uint8_t *pOutput, uint8_t *pAeadCtx)
AES-GCM update of the encrypted data.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Aead_PartialInit_Async(mcuxClEls_AeadOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pIV, size_t ivLength, uint8_t *pAeadCtx)
AES-GCM partial initialization.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Aead_Init_Async(mcuxClEls_AeadOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pIV, size_t ivLength, uint8_t *pAeadCtx)
AES-GCM initialization.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Aead_UpdateAad_Async(mcuxClEls_AeadOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pAad, size_t aadLength, uint8_t *pAeadCtx)
AES-GCM update of the Additional Authenticated Data (AAD).
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Aead_Finalize_Async(mcuxClEls_AeadOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, size_t aadLength, size_t dataLength, uint8_t *pTag, uint8_t *pAeadCtx)
AES-GCM final encryption/decryption.
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition mcuxClEls_Common.h:66
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition mcuxClEls_Types.h:232
uint32_t mcuxClEls_KeyIndex_t
Type for ELS keystore indices.
Definition mcuxClEls_Types.h:242
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition mcuxCsslFlowProtection.h:145
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition mcuxCsslFlowProtection.h:101
Command option bit field for mcuxClEls_Aead_Init_Async, mcuxClEls_Aead_UpdateAad_Async,...
Definition mcuxClEls_Aead.h:119
uint32_t acpmod
This field is managed internally.
Definition mcuxClEls_Aead.h:128
uint32_t acpsie
This field is managed internally.
Definition mcuxClEls_Aead.h:134
uint32_t msgendw
The size of the last data block (plain/cipher text) in bytes, without padding.
Definition mcuxClEls_Aead.h:135
uint32_t extkey
Defines whether an external key shall be used.
Definition mcuxClEls_Aead.h:138
uint32_t lastinit
Defines whether this is the last call to init.
Definition mcuxClEls_Aead.h:136
uint32_t acpsoe
This field is managed internally.
Definition mcuxClEls_Aead.h:130
uint32_t dcrpt
Defines if encryption or decryption shall be performed.
Definition mcuxClEls_Aead.h:127
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Aead.h:122