Example for the mcuxClKey component for RFC3394 key rewrap using the SGI coprocessor.
Example for the mcuxClKey component for RFC3394 key rewrap using the SGI coprocessor.
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_Session_Helper.h>
#include <mcuxClExample_RNG_Helper.h>
0x33221100U, 0x77665544U, 0xBBAA9988U, 0xFFEEDDCCU
};
0x03020100U, 0x07060504U, 0x0B0A0908U, 0x0F0E0D0CU,
0x13121110U, 0x17161514U, 0x1B1A1918U, 0x1F1E1D1CU
};
0xF9C3E864U, 0xA25B0FCEU, 0x7977E963U, 0x2A8A8105U,
0x1E19C893U, 0xE78A6E7DU
};
MCUXCLEXAMPLE_FUNCTION(mcuxClKey_Wrap_Rfc3394_Sgi_kwkAlreadyLoaded_example)
{
mcuxClSession_Descriptor_t sessionDesc;
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(session, MCUXCLEXAMPLE_MAX_WA(MCUXCLKEY_ENCODE_CPU_WA_SIZE, MCUXCLRANDOM_NCINIT_WACPU_SIZE), 0U);
MCUXCLEXAMPLE_INITIALIZE_PRNG(session);
uint32_t dummyKwkDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
dummyKwk,
(const uint8_t*)kwk256Data,
sizeof(kwk256Data))
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
dummyKwk,
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t keyWrappingKeyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
session,
keyWrappingKey,
(uint8_t *) NULL,
0u )
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
keyWrappingKey,
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t keyDesc[MCUXCLKEY_DESCRIPTOR_SIZE_IN_WORDS];
MCUX_CSSL_ANALYSIS_START_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
MCUX_CSSL_ANALYSIS_STOP_PATTERN_REINTERPRET_MEMORY_OF_OPAQUE_TYPES()
uint32_t wrappedKeyLen = 0u;
session,
key,
(const uint8_t*)keyData,
sizeof(keyData),
(uint8_t*) keyWrappingKeyDesc,
sizeof(keyWrappingKeyDesc),
wrappedKeyData,
&wrappedKeyLen)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by mcuxClKey_encode")
if(!mcuxClCore_assertEqual(wrappedKeyData, (const uint8_t*)expectedwrappedKeyData, sizeof(expectedwrappedKeyData)))
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
dummyKwk)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
keyWrappingKey)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
if(!mcuxClExample_Session_Clean(session))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
return MCUXCLEXAMPLE_STATUS_OK;
}
Top-level include file for the mcuxClAes component.
Top-level include file for the mcuxClBuffer component.
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the mcuxClKey component.
Top-level include file for the mcuxClSession component.
Provides the API for the CSSL flow protection mechanism.
#define MCUXCLAES_ENCODING_RFC3394_AES128_KEY_SIZE
RFC3394 encoding of AES-128 key material, encoded key size in bytes.
Definition mcuxClAes_Constants.h:49
#define MCUXCLAES_AES128_KEY_SIZE
AES-128 key size in bytes.
Definition mcuxClAes_Constants.h:40
#define MCUXCLAES_AES256_KEY_SIZE
AES-256 key size in bytes.
Definition mcuxClAes_Constants.h:44
static const mcuxClKey_Encoding_t mcuxClAes_Encoding_Rfc3394
Key encoding for RFC3394 key wrap/unwrap.
Definition mcuxClAes_KeyEncodingMechanisms.h:47
static const mcuxClKey_Type_t mcuxClKey_Type_Aes256
Key type pointer for AES-256 based keys.
Definition mcuxClAes_KeyTypes.h:63
static const mcuxClKey_Type_t mcuxClKey_Type_Aes128
Key type pointer for AES-128 based keys.
Definition mcuxClAes_KeyTypes.h:51
#define MCUXCLKEY_STATUS_OK
Key operation successful.
Definition mcuxClKey_Constants.h:40
#define MCUXCLKEY_LOADOPTION_SLOT_SGI_KEY_6
SGI key slot 6.
Definition mcuxClKey_Constants.h:178
#define MCUXCLKEY_LOADOPTION_ALREADYLOADED
Option: the key is already loaded; only set the fields in the key object.
Definition mcuxClKey_Constants.h:187
mcuxClKey_Status_t mcuxClKey_init(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key, mcuxClKey_Type_t type, const uint8_t *pKeyData, uint32_t keyDataLength)
Initializes a key handle.
mcuxClKey_Status_t mcuxClKey_flush(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key)
Flush key from destination which can be a key slot of coprocessor or memory buffer.
mcuxClKey_Status_t mcuxClKey_loadCopro(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key, uint32_t loadOptions)
Load key into destination key slot of a coprocessor.
mcuxClKey_Status_t mcuxClKey_encode(mcuxClSession_Handle_t session, mcuxClKey_Encoding_t encoding, mcuxClKey_Handle_t encodedKey, mcuxClKey_Type_t type, const uint8_t *pPlainKeyData, uint32_t plainKeyDataLength, const uint8_t *pAuxData, uint32_t auxDataLength, uint8_t *pEncodedKeyData, uint32_t *const pEncodedKeyDataLength)
Key descriptor initialization function including applying a encoding mechanism.
mcuxClKey_Descriptor_t *const mcuxClKey_Handle_t
Key handle type.
Definition mcuxClKey_Types.h:91
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:98
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:623
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:777
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:658