MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClKey_example.c

Example for the mcuxClKey component

/*--------------------------------------------------------------------------*/
/* Copyright 2021 NXP */
/* */
/* NXP Confidential. This software is owned or controlled by NXP and may */
/* only be used strictly in accordance with the applicable license terms. */
/* By expressly accepting such terms or by downloading, installing, */
/* activating and/or otherwise using the software, you are agreeing that */
/* you have read, and that you agree to comply with and are bound by, such */
/* license terms. If you do not agree to be bound by the applicable license */
/* terms, then you may not retain, install, activate or otherwise use the */
/* software. */
/*--------------------------------------------------------------------------*/
#include <mcuxClKey.h>
#include <mcuxClSession.h>
#include <mcuxCsslFlowProtection.h> // Code flow protection
#include <stdbool.h> // bool type for the example's return code
/* Example AES-128 key. */
static uint8_t aes128_key[MCUXCLKEY_SIZE_128] = {
0x7c, 0x0b, 0x7d, 0xb9,
0x81, 0x1f, 0x10, 0xd0,
0x0e, 0x47, 0x6c, 0x7a,
0x0d, 0x92, 0xf6, 0xe0
};
{
/**************************************************************************/
/* Preparation */
/**************************************************************************/
/* Key buffer for the key in memory. */
uint32_t key_buffer[MCUXCLKEY_SIZE_128 / sizeof(uint32_t)];
NULL,
NULL,
NULL,
NULL));
return false;
/**************************************************************************/
/* Key setup */
/**************************************************************************/
/* Create and initialize mcuxClKey_Descriptor_t structure. */
aes128_key,
NULL, /* no srcAuxData */
0u));
return false;
/* Set key properties. */
mcuxClCss_KeyProp_t key_properties;
key_properties.word.value = 0u;
key_properties));
return false;
/* Load key to memory. */
key_buffer));
return false;
/**************************************************************************/
/* The key could now be used for a cryptographic operation. */
/**************************************************************************/
/**************************************************************************/
/* Cleanup */
/**************************************************************************/
/* Flush the key. */
return false;
/* mcuxClSession_Handle_t pSession: */ &session));
{
return false;
}
/* mcuxClSession_Handle_t pSession: */ &session));
{
return false;
}
return true;
}