MCUX CLNS
MCUX Crypto Library Normal Secure
Loading...
Searching...
No Matches
mcuxClEls_Cipher.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*/
2/* Copyright 2020-2023 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
45
52
53#ifndef MCUXCLELS_CIPHER_H_
54#define MCUXCLELS_CIPHER_H_
55
56#include <mcuxClConfig.h> // Exported features flags header
57#include <mcuxClEls_Common.h> // Common functionality
58
59#ifdef __cplusplus
60extern "C" {
61#endif
62
63/**********************************************
64 * CONSTANTS
65 **********************************************/
72
81
82#define MCUXCLELS_CIPHER_ENCRYPT 0U
83#define MCUXCLELS_CIPHER_DECRYPT 1U
84
85#define MCUXCLELS_CIPHER_STATE_OUT_ENABLE 1U
86#define MCUXCLELS_CIPHER_STATE_OUT_DISABLE 0U
87
88#ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
89#define MCUXCLELS_CIPHER_STATE_IN_ENABLE 1U
90#define MCUXCLELS_CIPHER_STATE_IN_DISABLE 0U
91#endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
92
93#define MCUXCLELS_CIPHER_EXTERNAL_KEY 1U
94#define MCUXCLELS_CIPHER_INTERNAL_KEY 0U
95
96#define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_ECB 0x00U
97#define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_CBC 0x01U
98#define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_CTR 0x02U
102
103
107#define MCUXCLELS_CIPHER_BLOCK_SIZE_AES ((size_t) 16U)
108
115
116#define MCUXCLELS_CIPHER_KEY_SIZE_AES_128 ((size_t) 16U)
117#define MCUXCLELS_CIPHER_KEY_SIZE_AES_192 ((size_t) 24U)
118#define MCUXCLELS_CIPHER_KEY_SIZE_AES_256 ((size_t) 32U)
124
125/**********************************************
126 * TYPEDEFS
127 **********************************************/
134
140typedef union
141{
142 struct
143 {
144 uint32_t value;
145 } word;
146 struct
147 {
148 uint32_t :1;
149 uint32_t dcrpt :1;
150 uint32_t cphmde :2;
151 uint32_t cphsoe :1;
152#ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
153 uint32_t cphsie :1;
154 uint32_t :7;
155#else
156 uint32_t :8;
157#endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
158 uint32_t extkey :1;
159 uint32_t :18;
160 } bits;
162
165
166/**********************************************
167 * FUNCTIONS
168 **********************************************/
175
239 uint8_t const * pKey,
240 size_t keyLength,
241 uint8_t const * pInput,
242 size_t inputLength,
243 uint8_t * pIV,
244 uint8_t * pOutput
245 );
246
250
251#ifdef __cplusplus
252} /* extern "C" */
253#endif
254
255#endif /* MCUXCLELS_CIPHER_H_ */
256
ELS header for common functionality.
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_Cipher_Async(mcuxClEls_CipherOption_t options, mcuxClEls_KeyIndex_t keyIdx, uint8_t const *pKey, size_t keyLength, uint8_t const *pInput, size_t inputLength, uint8_t *pIV, uint8_t *pOutput)
Performs AES 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_Cipher_Async.
Definition mcuxClEls_Cipher.h:141
uint32_t value
Accesses the bit field as a full word.
Definition mcuxClEls_Cipher.h:144
uint32_t cphmde
Define cipher mode.
Definition mcuxClEls_Cipher.h:150
uint32_t extkey
Define whether an external key from memory or ELS internal key should be used.
Definition mcuxClEls_Cipher.h:158
uint32_t cphsoe
Define whether the ELS internal cipher state should be extracted to external memory or kept internall...
Definition mcuxClEls_Cipher.h:151
uint32_t dcrpt
Define operation mode.
Definition mcuxClEls_Cipher.h:149
uint32_t cphsie
Define whether an external provided cipher state should be imported from external memory.
Definition mcuxClEls_Cipher.h:153