MCUX CLNS
MCUX Crypto Library Normal Secure
 
Loading...
Searching...
No Matches
mcuxClExample_Key_Helper.h
1/*--------------------------------------------------------------------------*/
2/* Copyright 2022-2023 NXP */
3/* */
4/* NXP Confidential. This software is owned or controlled by NXP and may */
5/* only be used strictly in accordance with the applicable license terms. */
6/* By expressly accepting such terms or by downloading, installing, */
7/* activating and/or otherwise using the software, you are agreeing that */
8/* you have read, and that you agree to comply with and are bound by, such */
9/* license terms. If you do not agree to be bound by the applicable license */
10/* terms, then you may not retain, install, activate or otherwise use the */
11/* software. */
12/*--------------------------------------------------------------------------*/
13
14#ifndef MCUXCLEXAMPLE_KEY_HELPER_H_
15#define MCUXCLEXAMPLE_KEY_HELPER_H_
16
17#include <mcuxClConfig.h> // Exported features flags header
18#include <mcuxClCore_Platform.h>
19#include <mcuxClKey.h>
20#include <mcuxClSession.h>
23
35#define MCUXCLEXAMPLE_CONST_EXTERNAL_KEY 0U
36#define MCUXCLEXAMPLE_CONST_INTERNAL_KEY 1U
37MCUX_CSSL_FP_FUNCTION_DEF(mcuxClExample_Key_Init_And_Load)
38static inline bool mcuxClExample_Key_Init_And_Load(mcuxClSession_Handle_t pSession,
41 uint8_t * pData,
42 uint32_t keyDataLength,
43 mcuxClEls_KeyProp_t * key_properties,
44 uint32_t * dst,
45 uint8_t key_loading_option)
46{
47 /* Init the key. */
49 /* mcuxClSession_Handle_t session */ pSession,
50 /* mcuxClKey_Handle_t key */ pKey,
51 /* mcuxClKey_Type_t type */ type,
52 /* uint8_t * pKeyData */ pData,
53 /* uint32_t keyDataLength */ keyDataLength)
54 );
55
57 {
58 return false;
59 }
61
62 /* Set the key properties. */
64 key_properties));
65
67 {
68 return false;
69 }
71
72 if(MCUXCLEXAMPLE_CONST_EXTERNAL_KEY == key_loading_option)
73 {
74 /* load key into destination memory buffer */
76 /* mcuxClSession_Handle_t pSession: */ pSession,
77 /* mcuxClKey_Handle_t key: */ pKey,
78 /* uint32_t * dstData: */ dst));
79
81 {
82 return false;
83 }
85 }
86 else
87 {
88 /* load key into destination key slot of coprocessor (key_slot = '*dst') */
90 /* mcuxClSession_Handle_t pSession: */ pSession,
91 /* mcuxClKey_Handle_t key: */ pKey,
92 /* uint32_t dstSlot: */ *dst));
93
95 {
96 return false;
97 }
99 }
100 return true;
101}
102
103#endif /* MCUXCLEXAMPLE_KEY_HELPER_H_ */
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 MCUXCLKEY_STATUS_OK
Key operation successful.
Definition mcuxClKey_Constants.h:39
mcuxClKey_Status_t mcuxClKey_loadCopro(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, uint32_t dstSlot)
Load key into destination key slot of a coprocessor.
mcuxClKey_Status_t mcuxClKey_setKeyproperties(mcuxClKey_Handle_t key, mcuxClEls_KeyProp_t *key_properties)
Set the requested key properties of the destination key.
mcuxClKey_Status_t mcuxClKey_init(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, mcuxClKey_Type_t type, const uint8_t *pKeyData, uint32_t keyDataLength)
Initializes a key handle.
mcuxClKey_Status_t mcuxClKey_loadMemory(mcuxClSession_Handle_t pSession, mcuxClKey_Handle_t key, uint32_t *dstData)
Load key into destination memory buffer.
const mcuxClKey_TypeDescriptor_t * mcuxClKey_Type_t
Key type handle type.
Definition mcuxClKey_Types.h:111
mcuxClKey_Descriptor_t *const mcuxClKey_Handle_t
Key handle type.
Definition mcuxClKey_Types.h:88
mcuxClSession_Descriptor_t *const mcuxClSession_Handle_t
Type for mcuxClSession Handle.
Definition mcuxClSession_Types.h:113
#define MCUX_CSSL_FP_FUNCTION_DEF(...)
Definition of a flow protected function.
Definition mcuxCsslFlowProtection.h:159
#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
Type for ELS key store key properties.
Definition mcuxClEls_Types.h:226