14 #ifndef MCUXCLEXAMPLE_RFC3394_HELPER_H_ 15 #define MCUXCLEXAMPLE_RFC3394_HELPER_H_ 17 #include <mcuxClConfig.h> 18 #include <mcuxClCore_Platform.h> 28 static inline bool mcuxClExample_rfc3394_wrap(
29 const uint8_t * pInput,
31 const uint8_t * pKek_in,
62 concat[0] = 0xA6A6A6A6u;
63 concat[1] = 0xA6A6A6A6u;
65 concat[3] = 0x00000000u;
66 concat[2] = (concat[2] << 24u) | (concat[2] >> 24u) | ((concat[2] & 0x0000ff00u) << 8u) | ((concat[2] >> 8u) & 0x0000ff00u);
76 if (inputLength %
sizeof(uint64_t) != 0u)
81 uint32_t *pSource = (uint32_t*) pInput;
82 uint32_t *pDest = (uint32_t*) pOutput;
83 uint32_t std_n = inputLength/
sizeof(uint64_t) + 1;
84 for(
size_t jdx = 0u; jdx < 6u; jdx++)
86 for(
size_t idx = 0u; idx < std_n; idx++)
117 pDest[2u*idx + 2u] = concat[2u];
118 pDest[2u*idx + 3u] = concat[3u];
120 if( idx == std_n - 1u)
123 concat[2u] = pDest[2u];
124 concat[3u] = pDest[3u];
130 concat[2u] = pSource[2u*idx + 0u];
131 concat[3u] = pSource[2u*idx + 1u];
135 uint32_t gdx = std_n * jdx + (idx+1);
136 gdx = (gdx << 24u) | (gdx >> 24u) | ((gdx & 0x0000ff00u) << 8u) | ((gdx >> 8u) & 0x0000ff00u);
141 pDest[0u] = concat[0u];
142 pDest[1u] = concat[1u];
151 static inline bool mcuxClExample_rfc3394_unwrap(
152 const uint8_t * pInput,
154 const uint8_t * pKek_in,
182 concat[0] = ((uint32_t*) pInput)[0];
183 concat[1] = ((uint32_t*) pInput)[1];
193 if (inputLength %
sizeof(uint64_t) != 0u)
199 uint32_t std_n = inputLength/
sizeof(uint64_t) - 1;
200 uint32_t *pSource = ((uint32_t*) pInput ) + 2u;
201 uint32_t *pDest = ((uint32_t*) pOutput) + 0u;
202 for(
size_t jdx = 6u; jdx > 0u; jdx--)
204 for(
size_t idx = std_n; idx > 0u; idx--)
207 concat[2u] = pSource[2u*(idx-1) + 0u];
208 concat[3u] = pSource[2u*(idx-1) + 1u];
211 uint32_t gdx = std_n * (jdx-1u) + idx;
212 gdx = (gdx << 24u) | (gdx >> 24u) | ((gdx & 0x0000ff00u) << 8u) | ((gdx >> 8u) & 0x0000ff00u);
244 pDest[2u*(idx-1) + 0u] = concat[2u];
245 pDest[2u*(idx-1) + 1u] = concat[3u];
249 pDest[0] = (pDest[0] << 24u) | (pDest[0] >> 24u) | ((pDest[0] & 0x0000ff00u) << 8u) | ((pDest[0] >> 8u) & 0x0000ff00u);
251 if((concat[0u] != 0xA6A6A6A6u) || (concat[1u] != 0xA6A6A6A6u))
#define MCUXCLELS_STATUS_OK
No error occurred.
Definition: mcuxClEls_Types.h:170
struct mcuxClEls_CipherOption_t::@2 word
Access mcuxClEls_CipherOption_t word-wise.
Definition of function identifiers for the flow protection mechanism.
#define MCUXCLELS_CIPHER_DECRYPT
Set this option at mcuxClEls_CipherOption_t.dcrpt to perform a decryption.
Definition: mcuxClEls_Cipher.h:63
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition: mcuxCsslFlowProtection.h:730
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
struct mcuxClEls_CipherOption_t::@3 bits
Access mcuxClEls_CipherOption_t bit-wise.
#define MCUXCLELS_CIPHERPARAM_ALGORITHM_AES_ECB
Set this option at mcuxClEls_CipherOption_t.cphmde to use AES engine in Electornic Code Book (ECB) mo...
Definition: mcuxClEls_Cipher.h:76
#define MCUXCLELS_CIPHER_ENCRYPT
Set this option at mcuxClEls_CipherOption_t.dcrpt to perform an encryption.
Definition: mcuxClEls_Cipher.h:62
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_WaitForOperation(mcuxClEls_ErrorHandling_t errorHandling)
Wait for an ELS operation and optionally clear the error status.
uint32_t dcrpt
Define operation mode.
Definition: mcuxClEls_Cipher.h:129
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition: mcuxCsslFlowProtection.h:611
Type for ELS key store key properties.
Definition: mcuxClEls_Types.h:224
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 mcuxClEls_KeyIndex_t
Type for ELS keystore indices.
Definition: mcuxClEls_Types.h:221
uint32_t value
Accesses the bit field as a full word; initialize with a combination of constants from MCUXCLELS_KEYP...
Definition: mcuxClEls_Types.h:228
#define MCUX_CSSL_FP_FUNCTION_CALL_VOID_BEGIN(...)
Call a flow protected void function and check the protection token.
Definition: mcuxCsslFlowProtection.h:647
#define MCUXCLELS_ERROR_FLAGS_CLEAR
Set this option at mcuxClEls_ErrorHandling_t to clear all ELS error flags.
Definition: mcuxClEls_Common.h:137
uint32_t extkey
Define whether an external key from memory or ELS internal key should be used.
Definition: mcuxClEls_Cipher.h:138
struct mcuxClEls_KeyProp_t::@38 word
Access mcuxClEls_KeyProp_t word-wise.
Memory header for copy functions.
#define MCUXCLELS_CIPHER_KEY_SIZE_AES_256
Size of an AES192 key: 256 bit (32 bytes)
Definition: mcuxClEls_Cipher.h:98
Provides the API for the CSSL flow protection mechanism.
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition: mcuxCsslFlowProtection.h:576
void mcuxClMemory_copy(uint8_t *pDst, uint8_t const *pSrc, size_t length, size_t bufLength)
Copies a memory buffer to another location.
Top-level include file for the ELS driver.
#define MCUXCLELS_CIPHER_EXTERNAL_KEY
Set this option at mcuxClEls_CipherOption_t.extkey to use a key located in CPU memory provided by pKe...
Definition: mcuxClEls_Cipher.h:73
#define MCUXCLELS_CIPHER_BLOCK_SIZE_AES
Definition: mcuxClEls_Cipher.h:87
#define MCUX_CSSL_FP_FUNCTION_CALL_VOID_END(...)
End a void function call section started by MCUX_CSSL_FP_FUNCTION_CALL_VOID_BEGIN.
Definition: mcuxCsslFlowProtection.h:678
#define MCUXCLELS_STATUS_OK_WAIT
An _Async function successfully started an ELS command. Call mcuxClEls_WaitForOperation to complete i...
Definition: mcuxClEls_Types.h:171