MCUX CLNS
MCUX Crypto Library Normal Secure
 
Loading...
Searching...
No Matches
mcuxClEls_Common_Get_Info_example.c

Example of version and configuration load functions.

Example of version and configuration load functions.

/*--------------------------------------------------------------------------*/
/* Copyright 2020, 2022-2023 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 <mcuxCl_clns.h> // Test the CLNS component-independent functionality
#include <mcuxClEls.h> // Interface to the entire mcuxClEls component
#include <mcuxClCore_FunctionIdentifiers.h> // Code flow protection
#include <mcuxClCore_Examples.h>
#include <mcuxClExample_ELS_Helper.h>
MCUXCLEXAMPLE_FUNCTION(mcuxClEls_Common_Get_Info_example)
{
if(!mcuxClExample_Els_Init(MCUXCLELS_RESET_DO_NOT_CANCEL))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
// Read the ELS hardware version.
// mcuxClEls_GetHwVersion is a flow-protected function: Check the protection token and the return value
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
// Access and store hw_version struct elements
uint32_t revision = hw_version.bits.revision; // Extended revision version
uint32_t minor = hw_version.bits.minor; // Minor version
uint32_t major = hw_version.bits.major; // Major version
(void) revision;
(void) minor;
(void) major;
#if MCUXCL_FEATURE_ELS_GET_FW_VERSION == 0
uint32_t level = hw_version.bits.level; // Release level version
(void) level;
#else /* MCUXCL_FEATURE_ELS_GET_FW_VERSION == 0 */
uint32_t fw_revision = hw_version.bits.fw_revision; // Firmware Extended revision version
uint32_t fw_minor = hw_version.bits.fw_minor; // Firmware Minor version
uint32_t fw_major = hw_version.bits.fw_major; // Firmware Major version
(void) fw_revision;
(void) fw_minor;
(void) fw_major;
#endif /* MCUXCL_FEATURE_ELS_GET_FW_VERSION == 0 */
#ifdef MCUXCL_FEATURE_ELS_HWCONFIG
// Read the ELS hardware configuration bitmap.
MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(result, token, mcuxClEls_GetHwConfig(&config));
// mcuxClEls_GetHwConfig is a flow-protected function: Check the protection token and the return value
if((MCUX_CSSL_FP_FUNCTION_CALLED(mcuxClEls_GetHwConfig) != token) || (MCUXCLELS_STATUS_OK != result))
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
// Access and store config struct elements
uint32_t ciphersup = config.bits.ciphersup; // cipher command not supported
(void)ciphersup;
uint32_t authciphersup = config.bits.authciphersup; // auth_cipher command not supported
(void)authciphersup;
uint32_t ecsignsup = config.bits.ecsignsup; // ecsign command not supported
(void)ecsignsup;
uint32_t ecvfysup = config.bits.ecvfysup; // ecvfy command not supported
(void)ecvfysup;
uint32_t eckxchsup = config.bits.eckxchsup; // dhkey_xch command is supported
(void)eckxchsup;
uint32_t keygensup = config.bits.keygensup; // keygen command not supported
(void)keygensup;
uint32_t keyinsup = config.bits.keyinsup; // keyin command not supported
(void)keyinsup;
uint32_t keyoutsup = config.bits.keyoutsup; // keyout command not supported
(void)keyoutsup;
uint32_t kdeletesup = config.bits.kdeletesup; // kdelete command not supported
(void)kdeletesup;
uint32_t ckdfsup = config.bits.ckdfsup; // ckdf command not supported
(void)ckdfsup;
uint32_t hkdfsup = config.bits.hkdfsup; // hkdf command not supported
(void)hkdfsup;
uint32_t tlsinitsup = config.bits.tlsinitsup; // tls_init command not supported
(void)tlsinitsup;
uint32_t hashsup = config.bits.hashsup; // hash command not supported
(void)hashsup;
uint32_t hmacsup = config.bits.hmacsup; // hmac command not supported
(void)hmacsup;
uint32_t drbgreqsub = config.bits.drbgreqsub; // drbg_req command not supported
(void)drbgreqsub;
uint32_t dtrgncfgloadsup = config.bits.dtrgncfgloadsup; // dtrng_cfg_load command is not supported
(void)dtrgncfgloadsup;
uint32_t dtrngevalsup = config.bits.dtrngevalsup; // dtrng_eval command not supported
(void)dtrngevalsup;
char const* sw_version = mcuxCl_GetVersion(); // Read the CLNS version string that uniquely identifies this release of the CLNS.
// MCUXCL_VERSION_MAX_SIZE is the maximum size in bytes of the version string.
(void)sw_version;
if(!mcuxClExample_Els_Disable())
{
return MCUXCLEXAMPLE_STATUS_ERROR;
}
#endif
return MCUXCLEXAMPLE_STATUS_OK;
}
Definition of function identifiers for the flow protection mechanism.
Top-level include file for the ELS driver.
CLNS header for component-independent functionality.
static char const * mcuxCl_GetVersion(void)
Gets the CLNS version string that uniquely identifies this release of the CLNS.
Definition mcuxCl_clns.h:40
Provides the API for the CSSL flow protection mechanism.
#define MCUXCLELS_RESET_DO_NOT_CANCEL
Set this option at mcuxClEls_ResetOption_t to abort the requested command if another ELS operation is...
Definition mcuxClEls_Common.h:119
#define drbgreqsub
Deprecated name for mcuxClEls_HwConfig_t.drbgreqsup.
Definition mcuxClEls_Common.h:372
MCUXCLELS_API mcuxClEls_Status_t mcuxClEls_GetHwVersion(mcuxClEls_HwVersion_t *result)
Determines the version of the underlying ELS hardware IP.
#define MCUXCLELS_STATUS_OK
No error occurred.
Definition mcuxClEls_Types.h:171
#define MCUX_CSSL_FP_FUNCTION_CALL_BEGIN(...)
Call a flow protected function and check the protection token.
Definition mcuxCsslFlowProtection.h:581
#define MCUX_CSSL_FP_FUNCTION_CALLED(...)
Expectation of a called function.
Definition mcuxCsslFlowProtection.h:735
#define MCUX_CSSL_FP_FUNCTION_CALL_END(...)
End a function call section started by MCUX_CSSL_FP_FUNCTION_CALL_BEGIN.
Definition mcuxCsslFlowProtection.h:616
Result type of mcuxClEls_GetHwVersion.
Definition mcuxClEls_Common.h:195
uint32_t major
Major version.
Definition mcuxClEls_Common.h:204
uint32_t revision
Revision number.
Definition mcuxClEls_Common.h:202
uint32_t level
Release level version.
Definition mcuxClEls_Common.h:206
uint32_t minor
Minor version.
Definition mcuxClEls_Common.h:203
struct mcuxClEls_HwVersion_t::@7 bits
Access mcuxClEls_HwVersion_t bit-wise.
Result type of #mcuxClEls_GetHwConfig.
Definition mcuxClEls_Common.h:339
uint32_t ckdfsup
Indicates whether the ckdf command is supported.
Definition mcuxClEls_Common.h:356
uint32_t ecvfysup
Indicates whether the ecvfy command is supported.
Definition mcuxClEls_Common.h:349
uint32_t keyinsup
Indicates whether the keyin command is supported.
Definition mcuxClEls_Common.h:352
uint32_t dtrgncfgloadsup
Indicates whether the dtrng_cfg_load command is is supported.
Definition mcuxClEls_Common.h:364
uint32_t hmacsup
Indicates whether the hmac command is supported.
Definition mcuxClEls_Common.h:360
uint32_t keyoutsup
Indicates whether the keyout command is supported.
Definition mcuxClEls_Common.h:353
uint32_t dtrngevalsup
Indicates whether the dtrng_eval command is supported.
Definition mcuxClEls_Common.h:365
uint32_t tlsinitsup
Indicates whether the tls_init command is supported.
Definition mcuxClEls_Common.h:358
uint32_t ecsignsup
Indicates whether the ecsign command is supported.
Definition mcuxClEls_Common.h:348
uint32_t ciphersup
Indicates whether the cipher command is supported.
Definition mcuxClEls_Common.h:346
struct mcuxClEls_HwConfig_t::@17 bits
Access mcuxClEls_InterruptOptionSet_t bit-wise.
uint32_t hashsup
Indicates whether the hash command is supported.
Definition mcuxClEls_Common.h:359
uint32_t eckxchsup
Indicates whether the dhkey_xch command is supported.
Definition mcuxClEls_Common.h:350
uint32_t authciphersup
Indicates whether the auth_cipher command is supported.
Definition mcuxClEls_Common.h:347
uint32_t keygensup
Indicates whether the keygen command is supported.
Definition mcuxClEls_Common.h:351
uint32_t hkdfsup
Indicates whether the hkdf command is supported.
Definition mcuxClEls_Common.h:357
uint32_t kdeletesup
Indicates whether the kdelete command is supported.
Definition mcuxClEls_Common.h:354