MCUX CLNS
MCUX Crypto Library Normal Secure
mcuxClPkc_Functions.h
Go to the documentation of this file.
1 /*--------------------------------------------------------------------------*/
2 /* Copyright 2020-2021 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 
20 #ifndef MCUXCLPKC_FUNCTIONS_H_
21 #define MCUXCLPKC_FUNCTIONS_H_
22 
23 
24 #include <stdint.h>
25 #include <stdbool.h>
26 #include <mcuxCsslFlowProtection.h>
27 
28 #include <mcuxClPkc_Types.h>
29 
30 
39 /**********************************************************/
40 /* PKC initialization and deinitialization */
41 /**********************************************************/
51 typedef struct
52 {
53  uint16_t ctrl;
54  uint16_t cfg;
56 
69  mcuxClPkc_State_t *pState
70  );
72 #define MCUXCLPKC_FP_INITIALIZE(pState) \
73  do{ \
74  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_Initialize(pState)); \
75  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
76  } while (false)
77 
90  const mcuxClPkc_State_t *pState
91  );
93 #define MCUXCLPKC_FP_DEINITIALIZE(pState) \
94  do{ \
95  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_Deinitialize(pState)); \
96  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
97  } while (false)
98  /* mcuxClPkc_Functions_Init */
102 
103 
104 /**********************************************************/
105 /* UPTR table */
106 /**********************************************************/
130  uint16_t *pUPTRT,
131  const uint8_t *pBaseBuffer,
132  uint16_t bufferSize,
133  uint8_t noOfBuffer
134  );
136 #define MCUXCLPKC_FP_GENERATEUPTRT(pUPTRT, pBaseBuffer, bufferSize, noOfBuffer) \
137  do{ \
138  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_GenerateUPTRT(pUPTRT, pBaseBuffer, bufferSize, noOfBuffer)); \
139  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
140  } while (false)
141 
160  uint16_t *pUPTRT,
161  uint8_t noOfBuffer
162  );
163 
182  uint16_t *pUPTRT,
183  uint16_t bufferSize,
184  uint8_t noOfBuffer
185  );
186  /* mcuxClPkc_Functions_UPTRT */
190 
191 
192 /**********************************************************/
193 /* PKC calculation */
194 /**********************************************************/
217  uint16_t param_mode,
218  uint32_t iR_iX_iY_iZ
219  );
220 
238  uint16_t param_mode,
239  uint32_t iR_iX_iY_C
240  );
241 
243 typedef const struct mcuxClPkc_FUPEntry * mcuxClPkc_PtrFUPEntry_t;
244 
261  uint8_t ulen
262  );
264 #define MCUXCLPKC_FP_CALCFUP(pUPTR, ulen) \
265  do{ \
266  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_CalcFup(pUPTR, ulen)); \
267  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
268  } while (false)
269 
270 #define MCUXCLPKC_FP_CALCFUP_OFFSET(pUPTR, skipLen, ulen) \
271  do{ \
272  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_CalcFup(&((mcuxClPkc_PtrFUPEntry_t) (pUPTR))[(skipLen)], ulen)); \
273  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
274  } while (false)
275  /* mcuxClPkc_Functions_Calculation */
279 
280 
281 /**********************************************************/
282 /* PKC wait functions */
283 /**********************************************************/
302 #define MCUXCLPKC_FP_WAITFORFINISH() \
303  do{ \
304  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_WaitForFinish()); \
305  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
306  } while (false)
307 
319 #define MCUXCLPKC_FP_WAITFORREADY() \
320  do{ \
321  MCUX_CSSL_FP_FUNCTION_CALL(retValTemp, mcuxClPkc_WaitForReady()); \
322  (void) retValTemp; /* Checking is unnecessary, because it always returns OK. */ \
323  } while (false)
324  /* mcuxClPkc_Functions_Wait */
328  /* mcuxClPkc_Functions */
332 
333 
334 #endif /* MCUXCLPKC_FUNCTIONS_H_ */
uint16_t cfg
backup of PKC CFG bits
Definition: mcuxClPkc_Functions.h:54
mcuxClPkc_Status_Protected_t mcuxClPkc_WaitForReady(void)
Wait until PKC is ready to accept new calculation.
Type definitions of mcuxClPkc component.
mcuxClPkc_Status_Protected_t mcuxClPkc_GenerateUPTRT(uint16_t *pUPTRT, const uint8_t *pBaseBuffer, uint16_t bufferSize, uint8_t noOfBuffer)
Initialize UPTR table.
mcuxClPkc_Status_Protected_t mcuxClPkc_Deinitialize(const mcuxClPkc_State_t *pState)
deinitialize PKC hardware
uint64_t mcuxClPkc_Status_Protected_t
Type for error codes used by code-flow protected PKC component functions.
Definition: mcuxClPkc_Types.h:58
mcuxClPkc_Status_Protected_t mcuxClPkc_RandomizeUPTRT(uint16_t *pUPTRT, uint8_t noOfBuffer)
Randomize UPTR table.
uint16_t ctrl
backup of PKC CTRL bits
Definition: mcuxClPkc_Functions.h:53
mcuxClPkc_Status_Protected_t mcuxClPkc_ReRandomizeUPTRT(uint16_t *pUPTRT, uint16_t bufferSize, uint8_t noOfBuffer)
Randomize UPTR table and operands in PKC workarea.
Structure of PKC state backup.
Definition: mcuxClPkc_Functions.h:51
mcuxClPkc_Status_Protected_t mcuxClPkc_Calc(uint16_t param_mode, uint32_t iR_iX_iY_iZ)
Start a PKC calculation.
const struct mcuxClPkc_FUPEntry * mcuxClPkc_PtrFUPEntry_t
type of FUP program address.
Definition: mcuxClPkc_Functions.h:243
mcuxClPkc_Status_Protected_t mcuxClPkc_CalcFup(mcuxClPkc_PtrFUPEntry_t pUPTR, uint8_t ulen)
Start a PKC FUP program calculation.
mcuxClPkc_Status_Protected_t mcuxClPkc_CalcConst(uint16_t param_mode, uint32_t iR_iX_iY_C)
Start a PKC calculation with one constant parameter.
Provides the API for the CSSL flow protection mechanism.
mcuxClPkc_Status_Protected_t mcuxClPkc_Initialize(mcuxClPkc_State_t *pState)
initialize PKC hardware
#define MCUX_CSSL_FP_FUNCTION_DECL(id)
Declaration of a flow protected function.
Definition: mcuxCsslFlowProtection.h:119
mcuxClPkc_Status_Protected_t mcuxClPkc_WaitForFinish(void)
Wait until PKC finishes calculations.