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>
0x1FU, 0xA6U, 0x8BU, 0x0AU, 0x81U, 0x12U, 0xB4U, 0x47U,
0xAEU, 0xF3U, 0x4BU, 0xD8U, 0xFBU, 0x5AU, 0x7BU, 0x82U,
0x9DU, 0x3EU, 0x86U, 0x23U, 0x71U, 0xD2U, 0xCFU, 0xE5U
};
0x00U, 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U,
0x08U, 0x09U, 0x0AU, 0x0BU, 0x0CU, 0x0DU, 0x0EU, 0x0FU
};
0x00U, 0x01U, 0x02U, 0x03U, 0x04U, 0x05U, 0x06U, 0x07U,
0x08U, 0x09U, 0x0AU, 0x0BU, 0x0CU, 0x0DU, 0x0EU, 0x0FU,
0x10U, 0x11U, 0x12U, 0x13U, 0x14U, 0x15U, 0x16U, 0x17U,
0x18U, 0x19U, 0x1AU, 0x1BU, 0x1CU, 0x1DU, 0x1EU, 0x1FU
};
0x64U, 0xE8U, 0xC3U, 0xF9U, 0xCEU, 0x0FU, 0x5BU, 0xA2U,
0x63U, 0xE9U, 0x77U, 0x79U, 0x05U, 0x81U, 0x8AU, 0x2AU,
0x93U, 0xC8U, 0x19U, 0x1EU, 0x7DU, 0x6EU, 0x8AU, 0xE7U
};
MCUXCLEXAMPLE_FUNCTION(mcuxClKey_Rewrap_Rfc3394_Sgi_example)
{
mcuxClSession_Descriptor_t sessionDesc;
MCUXCLEXAMPLE_ALLOCATE_AND_INITIALIZE_SESSION(session, MCUXCLEXAMPLE_MAX_WA(MCUXCLKEY_RECODE_CPU_WA_SIZE, MCUXCLRANDOM_NCINIT_WACPU_SIZE), 0U);
MCUXCLEXAMPLE_INITIALIZE_PRNG(session);
uint32_t transportKeyDesc[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,
transportKey,
transportKeyData,
sizeof(transportKeyData))
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
transportKey,
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t wrappedKeyDesc[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,
wrappedKey,
wrappedKeyData,
sizeof(wrappedKeyData))
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
wrappedKey,
(const uint8_t*) transportKeyDesc,
sizeof(transportKeyDesc))
);
{
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,
kwk256Data,
sizeof(kwk256Data))
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
keyWrappingKey,
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
uint32_t reWrappedKeyDesc[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 reWrappedKeyLen = 0u;
session,
wrappedKey,
reWrappedKey,
(uint8_t*) keyWrappingKeyDesc,
sizeof(keyWrappingKeyDesc),
reWrappedKeyData,
&reWrappedKeyLen)
);
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
MCUX_CSSL_ANALYSIS_START_SUPPRESS_ALREADY_INITIALIZED("Initialized by MCUXCLBUFFER_INIT")
if(!mcuxClCore_assertEqual(reWrappedKeyData, expectedRewrappedKeyData, sizeof(expectedRewrappedKeyData)))
MCUX_CSSL_ANALYSIS_STOP_SUPPRESS_ALREADY_INITIALIZED()
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
session,
transportKey)
);
{
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_2
SGI key slot 2.
Definition mcuxClKey_Constants.h:174
#define MCUXCLKEY_LOADOPTION_SLOT_SGI_KEY_6
SGI key slot 6.
Definition mcuxClKey_Constants.h:178
mcuxClKey_Status_t mcuxClKey_recode(mcuxClSession_Handle_t session, mcuxClKey_Handle_t encodedKey, mcuxClKey_Encoding_t encoding, mcuxClKey_Handle_t recodedKey, const uint8_t *pAuxData, uint32_t auxDataLength, uint8_t *pEncodedKeyData, uint32_t *const pEncodedKeyDataLength)
Key recoding (re-encoding) function to apply a new encoding to key material.
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_setEncoding(mcuxClSession_Handle_t session, mcuxClKey_Handle_t key, mcuxClKey_Encoding_t encoding, const uint8_t *pAuxData, uint32_t auxDataLength)
Configures the encoding mechanism for the given key handle.
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