MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClEls_Cipher.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2023 NXP */
3 /* */
4 /* NXP Confidential. This software is owned or controlled by NXP and may */
5 /* only be used strictly in accordance with the applicable license terms. */
6 /* By expressly accepting such terms or by downloading, installing, */
7 /* activating and/or otherwise using the software, you are agreeing that */
8 /* you have read, and that you agree to comply with and are bound by, such */
9 /* license terms. If you do not agree to be bound by the applicable license */
10 /* terms, then you may not retain, install, activate or otherwise use the */
11 /* software. */
12 /*--------------------------------------------------------------------------*/
13 
33 #ifndef MCUXCLELS_CIPHER_H_
34 #define MCUXCLELS_CIPHER_H_
35 
36 #include <mcuxClConfig.h> // Exported features flags header
37 #include <mcuxClEls_Common.h> // Common functionality
38 
39 #ifdef __cplusplus
40 extern "C" {
41 #endif
42 
43 /**********************************************
44  * CONSTANTS
45  **********************************************/
62 #define MCUXCLELS_CIPHER_ENCRYPT 0U
63 #define MCUXCLELS_CIPHER_DECRYPT 1U
64 
65 #define MCUXCLELS_CIPHER_STATE_OUT_ENABLE 1U
66 #define MCUXCLELS_CIPHER_STATE_OUT_DISABLE 0U
67 
68 #ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
69 #define MCUXCLELS_CIPHER_STATE_IN_ENABLE 1U
70 #define MCUXCLELS_CIPHER_STATE_IN_DISABLE 0U
71 #endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
72 
73 #define MCUXCLELS_CIPHER_EXTERNAL_KEY 1U
74 #define MCUXCLELS_CIPHER_INTERNAL_KEY 0U
75 
76 #define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_ECB 0x00U
77 #define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_CBC 0x01U
78 #define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_CTR 0x02U
79 
87 #define MCUXCLELS_CIPHER_BLOCK_SIZE_AES ((size_t) 16U)
88 
89 
96 #define MCUXCLELS_CIPHER_KEY_SIZE_AES_128 ((size_t) 16U)
97 #define MCUXCLELS_CIPHER_KEY_SIZE_AES_192 ((size_t) 24U)
98 #define MCUXCLELS_CIPHER_KEY_SIZE_AES_256 ((size_t) 32U)
99 
105 /**********************************************
106  * TYPEDEFS
107  **********************************************/
108 
120 typedef union
121 {
122  struct
123  {
124  uint32_t value;
125  } word;
126  struct
127  {
128  uint32_t :1;
129  uint32_t dcrpt :1;
130  uint32_t cphmde :2;
131  uint32_t cphsoe :1;
132 #ifndef MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS
133  uint32_t cphsie :1;
134  uint32_t :7;
135 #else
136  uint32_t :8;
137 #endif /* MCUXCL_FEATURE_ELS_NO_INTERNAL_STATE_FLAGS */
138  uint32_t extkey :1;
139  uint32_t :18;
140  } bits;
146 /**********************************************
147  * FUNCTIONS
148  **********************************************/
217  mcuxClEls_CipherOption_t options,
218  mcuxClEls_KeyIndex_t keyIdx,
219  uint8_t const * pKey,
220  size_t keyLength,
221  uint8_t const * pInput,
222  size_t inputLength,
223  uint8_t * pIV,
224  uint8_t * pOutput
225  );
226 
231 #ifdef __cplusplus
232 } /* extern "C" */
233 #endif
234 
235 #endif /* MCUXCLELS_CIPHER_H_ */
236 
uint32_t mcuxClEls_Status_t
Type for ELS driver status codes.
Definition: mcuxClEls_Types.h:211
ELS header for common functionality.
uint32_t value
Accesses the bit field as a full word.
Definition: mcuxClEls_Cipher.h:124
uint32_t cphmde
Define cipher mode.
Definition: mcuxClEls_Cipher.h:130
uint32_t dcrpt
Define operation mode.
Definition: mcuxClEls_Cipher.h:129
uint32_t cphsoe
Define whether the ELS internal cipher state should be extracted to external memory or kept internall...
Definition: mcuxClEls_Cipher.h:131
#define MCUX_CSSL_FP_FUNCTION_DECL(...)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:125
Command option bit field for mcuxClEls_Cipher_Async.
Definition: mcuxClEls_Cipher.h:120
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.
uint32_t cphsie
Define whether an external provided cipher state should be imported from external memory.
Definition: mcuxClEls_Cipher.h:133
#define MCUXCLELS_API
Marks a function as a public API function of the mcuxClEls component.
Definition: mcuxClEls_Common.h:47
uint32_t mcuxClEls_KeyIndex_t
Type for ELS keystore indices.
Definition: mcuxClEls_Types.h:221
uint32_t extkey
Define whether an external key from memory or ELS internal key should be used.
Definition: mcuxClEls_Cipher.h:138
#define MCUX_CSSL_FP_PROTECTED_TYPE(resultType)
Based on a given base type, builds a return type with flow protection.
Definition: mcuxCsslFlowProtection.h:81