1 /**
2   ******************************************************************************
3   * @file    stm32l5xx_hal_pka.h
4   * @author  MCD Application Team
5   * @brief   Header file of PKA HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2019 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32L5xx_HAL_PKA_H
21 #define STM32L5xx_HAL_PKA_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32l5xx_hal_def.h"
29 
30 /** @addtogroup STM32L5xx_HAL_Driver
31   * @{
32   */
33 
34 #if defined(PKA) && defined(HAL_PKA_MODULE_ENABLED)
35 
36 /** @addtogroup PKA
37   * @{
38   */
39 
40 /* Exported types ------------------------------------------------------------*/
41 /** @defgroup PKA_Exported_Types PKA Exported Types
42   * @{
43   */
44 
45 /** @defgroup HAL_state_structure_definition HAL state structure definition
46   * @brief  HAL State structures definition
47   * @{
48   */
49 typedef enum
50 {
51   HAL_PKA_STATE_RESET   = 0x00U,  /*!< PKA not yet initialized or disabled  */
52   HAL_PKA_STATE_READY   = 0x01U,  /*!< PKA initialized and ready for use    */
53   HAL_PKA_STATE_BUSY    = 0x02U,  /*!< PKA internal processing is ongoing   */
54   HAL_PKA_STATE_ERROR   = 0x03U,  /*!< PKA error state                      */
55 }
56 HAL_PKA_StateTypeDef;
57 
58 /**
59   * @}
60   */
61 
62 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
63 /** @defgroup HAL_callback_id HAL callback ID enumeration
64   * @{
65   */
66 typedef enum
67 {
68   HAL_PKA_OPERATION_COMPLETE_CB_ID      = 0x00U,    /*!< PKA End of operation callback ID  */
69   HAL_PKA_ERROR_CB_ID                   = 0x01U,    /*!< PKA Error callback ID             */
70   HAL_PKA_MSPINIT_CB_ID                 = 0x02U,    /*!< PKA Msp Init callback ID          */
71   HAL_PKA_MSPDEINIT_CB_ID               = 0x03U     /*!< PKA Msp DeInit callback ID        */
72 } HAL_PKA_CallbackIDTypeDef;
73 
74 /**
75   * @}
76   */
77 
78 #endif /* USE_HAL_PKA_REGISTER_CALLBACKS */
79 
80 /** @defgroup PKA_Error_Code_definition PKA Error Code definition
81   * @brief  PKA Error Code definition
82   * @{
83   */
84 #define HAL_PKA_ERROR_NONE      (0x00000000U)
85 #define HAL_PKA_ERROR_ADDRERR   (0x00000001U)
86 #define HAL_PKA_ERROR_RAMERR    (0x00000002U)
87 #define HAL_PKA_ERROR_TIMEOUT   (0x00000004U)
88 #define HAL_PKA_ERROR_OPERATION (0x00000008U)
89 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
90 #define HAL_PKA_ERROR_INVALID_CALLBACK  (0x00000010U)    /*!< Invalid Callback error */
91 #endif /* USE_HAL_PKA_REGISTER_CALLBACKS */
92 
93 /**
94   * @}
95   */
96 
97 /** @defgroup PKA_handle_Structure_definition PKA handle Structure definition
98   * @brief  PKA handle Structure definition
99   * @{
100   */
101 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
102 typedef struct __PKA_HandleTypeDef
103 #else
104 typedef struct
105 #endif  /* USE_HAL_PKA_REGISTER_CALLBACKS */
106 {
107   PKA_TypeDef                   *Instance;              /*!< Register base address */
108   __IO HAL_PKA_StateTypeDef     State;                  /*!< PKA state */
109   __IO uint32_t                 ErrorCode;              /*!< PKA Error code */
110 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
111   void (* OperationCpltCallback)(struct __PKA_HandleTypeDef *hpka); /*!< PKA End of operation callback */
112   void (* ErrorCallback)(struct __PKA_HandleTypeDef *hpka);         /*!< PKA Error callback            */
113   void (* MspInitCallback)(struct __PKA_HandleTypeDef *hpka);       /*!< PKA Msp Init callback         */
114   void (* MspDeInitCallback)(struct __PKA_HandleTypeDef *hpka);     /*!< PKA Msp DeInit callback       */
115 #endif  /* USE_HAL_PKA_REGISTER_CALLBACKS */
116 } PKA_HandleTypeDef;
117 /**
118   * @}
119   */
120 
121 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
122 /** @defgroup PKA_Callback_definition PKA Callback pointer definition
123   * @brief  PKA Callback pointer definition
124   * @{
125   */
126 typedef  void (*pPKA_CallbackTypeDef)(PKA_HandleTypeDef *hpka); /*!< Pointer to a PKA callback function */
127 /**
128   * @}
129   */
130 #endif /* USE_HAL_PKA_REGISTER_CALLBACKS */
131 /** @defgroup PKA_Operation PKA operation structure definition
132   * @brief  Input and output data definition
133   * @{
134   */
135 typedef struct
136 {
137   uint32_t scalarMulSize;              /*!< Number of element in scalarMul array */
138   uint32_t modulusSize;                /*!< Number of element in modulus, coefA, pointX and pointY arrays */
139   uint32_t coefSign;                   /*!< Curve coefficient a sign */
140   const uint8_t *coefA;                /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */
141   const uint8_t *modulus;              /*!< Pointer to curve modulus value p (Array of modulusSize elements) */
142   const uint8_t *pointX;               /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */
143   const uint8_t *pointY;               /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */
144   const uint8_t *scalarMul;            /*!< Pointer to scalar multiplier k   (Array of scalarMulSize elements) */
145   const uint32_t *pMontgomeryParam;    /*!< Pointer to Montgomery parameter  (Array of modulusSize/4 elements) */
146 } PKA_ECCMulFastModeInTypeDef;
147 
148 typedef struct
149 {
150   uint32_t scalarMulSize;              /*!< Number of element in scalarMul array */
151   uint32_t modulusSize;                /*!< Number of element in modulus, coefA, pointX and pointY arrays */
152   uint32_t coefSign;                   /*!< Curve coefficient a sign */
153   const uint8_t *coefA;                /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */
154   const uint8_t *modulus;              /*!< Pointer to curve modulus value p (Array of modulusSize elements) */
155   const uint8_t *pointX;               /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */
156   const uint8_t *pointY;               /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */
157   const uint8_t *scalarMul;            /*!< Pointer to scalar multiplier k   (Array of scalarMulSize elements) */
158 } PKA_ECCMulInTypeDef;
159 
160 typedef struct
161 {
162   uint32_t modulusSize;                /*!< Number of element in coefA, coefB, modulus, pointX and pointY arrays */
163   uint32_t coefSign;                   /*!< Curve coefficient a sign */
164   const uint8_t *coefA;                /*!< Pointer to curve coefficient |a| (Array of modulusSize elements) */
165   const uint8_t *coefB;                /*!< Pointer to curve coefficient b   (Array of modulusSize elements) */
166   const uint8_t *modulus;              /*!< Pointer to curve modulus value p (Array of modulusSize elements) */
167   const uint8_t *pointX;               /*!< Pointer to point P coordinate xP (Array of modulusSize elements) */
168   const uint8_t *pointY;               /*!< Pointer to point P coordinate yP (Array of modulusSize elements) */
169 } PKA_PointCheckInTypeDef;
170 
171 typedef struct
172 {
173   uint32_t size;                       /*!< Number of element in popA array */
174   const uint8_t *pOpDp;                /*!< Pointer to operand dP   (Array of size/2 elements) */
175   const uint8_t *pOpDq;                /*!< Pointer to operand dQ   (Array of size/2 elements) */
176   const uint8_t *pOpQinv;              /*!< Pointer to operand qinv (Array of size/2 elements) */
177   const uint8_t *pPrimeP;              /*!< Pointer to prime p      (Array of size/2 elements) */
178   const uint8_t *pPrimeQ;              /*!< Pointer to prime Q      (Array of size/2 elements) */
179   const uint8_t *popA;                 /*!< Pointer to operand A    (Array of size elements) */
180 } PKA_RSACRTExpInTypeDef;
181 
182 typedef struct
183 {
184   uint32_t primeOrderSize;             /*!< Number of element in primeOrder array */
185   uint32_t modulusSize;                /*!< Number of element in modulus array */
186   uint32_t coefSign;                   /*!< Curve coefficient a sign */
187   const uint8_t *coef;                 /*!< Pointer to curve coefficient |a|     (Array of modulusSize elements) */
188   const uint8_t *modulus;              /*!< Pointer to curve modulus value p     (Array of modulusSize elements) */
189   const uint8_t *basePointX;           /*!< Pointer to curve base point xG       (Array of modulusSize elements) */
190   const uint8_t *basePointY;           /*!< Pointer to curve base point yG       (Array of modulusSize elements) */
191   const uint8_t *pPubKeyCurvePtX;      /*!< Pointer to public-key curve point xQ (Array of modulusSize elements) */
192   const uint8_t *pPubKeyCurvePtY;      /*!< Pointer to public-key curve point yQ (Array of modulusSize elements) */
193   const uint8_t *RSign;                /*!< Pointer to signature part r          (Array of primeOrderSize elements) */
194   const uint8_t *SSign;                /*!< Pointer to signature part s          (Array of primeOrderSize elements) */
195   const uint8_t *hash;                 /*!< Pointer to hash of the message e     (Array of primeOrderSize elements) */
196   const uint8_t *primeOrder;           /*!< Pointer to order of the curve n      (Array of primeOrderSize elements) */
197 } PKA_ECDSAVerifInTypeDef;
198 
199 typedef struct
200 {
201   uint32_t primeOrderSize;             /*!< Number of element in primeOrder array */
202   uint32_t modulusSize;                /*!< Number of element in modulus array */
203   uint32_t coefSign;                   /*!< Curve coefficient a sign */
204   const uint8_t *coef;                 /*!< Pointer to curve coefficient |a|     (Array of modulusSize elements) */
205   const uint8_t *modulus;              /*!< Pointer to curve modulus value p     (Array of modulusSize elements) */
206   const uint8_t *integer;              /*!< Pointer to random integer k          (Array of primeOrderSize elements) */
207   const uint8_t *basePointX;           /*!< Pointer to curve base point xG       (Array of modulusSize elements) */
208   const uint8_t *basePointY;           /*!< Pointer to curve base point yG       (Array of modulusSize elements) */
209   const uint8_t *hash;                 /*!< Pointer to hash of the message       (Array of primeOrderSize elements) */
210   const uint8_t *privateKey;           /*!< Pointer to private key d             (Array of primeOrderSize elements) */
211   const uint8_t *primeOrder;           /*!< Pointer to order of the curve n      (Array of primeOrderSize elements) */
212 } PKA_ECDSASignInTypeDef;
213 
214 typedef struct
215 {
216   uint8_t *RSign;                      /*!< Pointer to signature part r          (Array of modulusSize elements) */
217   uint8_t *SSign;                      /*!< Pointer to signature part s          (Array of modulusSize elements) */
218 } PKA_ECDSASignOutTypeDef;
219 
220 typedef struct
221 {
222   uint8_t *ptX;                        /*!< Pointer to point P coordinate xP     (Array of modulusSize elements) */
223   uint8_t *ptY;                        /*!< Pointer to point P coordinate yP     (Array of modulusSize elements) */
224 } PKA_ECDSASignOutExtParamTypeDef, PKA_ECCMulOutTypeDef;
225 
226 
227 typedef struct
228 {
229   uint32_t expSize;                    /*!< Number of element in pExp array */
230   uint32_t OpSize;                     /*!< Number of element in pOp1 and pMod arrays */
231   const uint8_t *pExp;                 /*!< Pointer to Exponent             (Array of expSize elements) */
232   const uint8_t *pOp1;                 /*!< Pointer to Operand              (Array of OpSize elements) */
233   const uint8_t *pMod;                 /*!< Pointer to modulus              (Array of OpSize elements) */
234 } PKA_ModExpInTypeDef;
235 
236 
237 typedef struct
238 {
239   uint32_t expSize;                    /*!< Number of element in pExp and pMontgomeryParam arrays */
240   uint32_t OpSize;                     /*!< Number of element in pOp1 and pMod arrays */
241   const uint8_t *pExp;                 /*!< Pointer to Exponent             (Array of expSize elements) */
242   const uint8_t *pOp1;                 /*!< Pointer to Operand              (Array of OpSize elements) */
243   const uint8_t *pMod;                 /*!< Pointer to modulus              (Array of OpSize elements) */
244   const uint32_t *pMontgomeryParam;    /*!< Pointer to Montgomery parameter (Array of expSize/4 elements) */
245 } PKA_ModExpFastModeInTypeDef;
246 
247 typedef struct
248 {
249   uint32_t size;                       /*!< Number of element in pOp1 array */
250   const uint8_t *pOp1;                 /*!< Pointer to Operand (Array of size elements) */
251 } PKA_MontgomeryParamInTypeDef;
252 
253 typedef struct
254 {
255   uint32_t size;                       /*!< Number of element in pOp1 and pOp2 arrays */
256   const uint32_t *pOp1;                /*!< Pointer to Operand 1 (Array of size elements) */
257   const uint32_t *pOp2;                /*!< Pointer to Operand 2 (Array of size elements) */
258 } PKA_AddInTypeDef, PKA_SubInTypeDef, PKA_MulInTypeDef, PKA_CmpInTypeDef;
259 
260 typedef struct
261 {
262   uint32_t size;                       /*!< Number of element in pOp1 array */
263   const uint32_t *pOp1;                /*!< Pointer to Operand 1       (Array of size elements) */
264   const uint8_t *pMod;                 /*!< Pointer to modulus value n (Array of size*4 elements) */
265 } PKA_ModInvInTypeDef;
266 
267 typedef struct
268 {
269   uint32_t OpSize;                     /*!< Number of element in pOp1 array */
270   uint32_t modSize;                    /*!< Number of element in pMod array */
271   const uint32_t *pOp1;                /*!< Pointer to Operand 1       (Array of OpSize elements) */
272   const uint8_t *pMod;                 /*!< Pointer to modulus value n (Array of modSize elements) */
273 } PKA_ModRedInTypeDef;
274 
275 typedef struct
276 {
277   uint32_t size;                       /*!< Number of element in pOp1 and pOp2 arrays */
278   const uint32_t *pOp1;                /*!< Pointer to Operand 1 (Array of size elements) */
279   const uint32_t *pOp2;                /*!< Pointer to Operand 2 (Array of size elements) */
280   const uint8_t  *pOp3;                /*!< Pointer to Operand 3 (Array of size*4 elements) */
281 } PKA_ModAddInTypeDef, PKA_ModSubInTypeDef, PKA_MontgomeryMulInTypeDef;
282 
283 /**
284   * @}
285   */
286 
287 /**
288   * @}
289   */
290 
291 /* Exported constants --------------------------------------------------------*/
292 /** @defgroup PKA_Exported_Constants PKA Exported Constants
293   * @{
294   */
295 
296 /** @defgroup PKA_Mode PKA mode
297   * @{
298   */
299 #define PKA_MODE_MONTGOMERY_PARAM                 (0x00000001U)
300 #define PKA_MODE_MODULAR_EXP                      (0x00000000U)
301 #define PKA_MODE_MODULAR_EXP_FAST_MODE            (0x00000002U)
302 #define PKA_MODE_ECC_MUL                          (0x00000020U)
303 #define PKA_MODE_ECC_MUL_FAST_MODE                (0x00000022U)
304 #define PKA_MODE_ECDSA_SIGNATURE                  (0x00000024U)
305 #define PKA_MODE_ECDSA_VERIFICATION               (0x00000026U)
306 #define PKA_MODE_POINT_CHECK                      (0x00000028U)
307 #define PKA_MODE_RSA_CRT_EXP                      (0x00000007U)
308 #define PKA_MODE_MODULAR_INV                      (0x00000008U)
309 #define PKA_MODE_ARITHMETIC_ADD                   (0x00000009U)
310 #define PKA_MODE_ARITHMETIC_SUB                   (0x0000000AU)
311 #define PKA_MODE_ARITHMETIC_MUL                   (0x0000000BU)
312 #define PKA_MODE_COMPARISON                       (0x0000000CU)
313 #define PKA_MODE_MODULAR_RED                      (0x0000000DU)
314 #define PKA_MODE_MODULAR_ADD                      (0x0000000EU)
315 #define PKA_MODE_MODULAR_SUB                      (0x0000000FU)
316 #define PKA_MODE_MONTGOMERY_MUL                   (0x00000010U)
317 /**
318   * @}
319   */
320 
321 /** @defgroup PKA_Interrupt_configuration_definition PKA Interrupt configuration definition
322   * @brief PKA Interrupt definition
323   * @{
324   */
325 #define PKA_IT_PROCEND                            PKA_CR_PROCENDIE
326 #define PKA_IT_ADDRERR                            PKA_CR_ADDRERRIE
327 #define PKA_IT_RAMERR                             PKA_CR_RAMERRIE
328 
329 /**
330   * @}
331   */
332 
333 /** @defgroup PKA_Flag_definition PKA Flag definition
334   * @{
335   */
336 #define PKA_FLAG_PROCEND                          PKA_SR_PROCENDF
337 #define PKA_FLAG_ADDRERR                          PKA_SR_ADDRERRF
338 #define PKA_FLAG_RAMERR                           PKA_SR_RAMERRF
339 
340 /**
341   * @}
342   */
343 
344 /**
345   * @}
346   */
347 
348 /* Exported macros -----------------------------------------------------------*/
349 
350 /** @defgroup PKA_Exported_Macros PKA Exported Macros
351   * @{
352   */
353 
354 /** @brief  Reset PKA handle state.
355   * @param  __HANDLE__ specifies the PKA Handle
356   * @retval None
357   */
358 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
359 #define __HAL_PKA_RESET_HANDLE_STATE(__HANDLE__)                do{                                                   \
360                                                                     (__HANDLE__)->State = HAL_PKA_STATE_RESET;       \
361                                                                     (__HANDLE__)->MspInitCallback = NULL;            \
362                                                                     (__HANDLE__)->MspDeInitCallback = NULL;          \
363                                                                   } while(0)
364 #else
365 #define __HAL_PKA_RESET_HANDLE_STATE(__HANDLE__)                ((__HANDLE__)->State = HAL_PKA_STATE_RESET)
366 #endif /* USE_HAL_PKA_REGISTER_CALLBACKS */
367 
368 /** @brief  Enable the specified PKA interrupt.
369   * @param  __HANDLE__ specifies the PKA Handle
370   * @param  __INTERRUPT__ specifies the interrupt source to enable.
371   *        This parameter can be one of the following values:
372   *            @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable
373   *            @arg @ref PKA_IT_ADDRERR Address error interrupt enable
374   *            @arg @ref PKA_IT_RAMERR RAM error interrupt enable
375   * @retval None
376   */
377 #define __HAL_PKA_ENABLE_IT(__HANDLE__, __INTERRUPT__)          ((__HANDLE__)->Instance->CR |= (__INTERRUPT__))
378 
379 /** @brief  Disable the specified PKA interrupt.
380   * @param  __HANDLE__ specifies the PKA Handle
381   * @param  __INTERRUPT__ specifies the interrupt source to disable.
382   *        This parameter can be one of the following values:
383   *            @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable
384   *            @arg @ref PKA_IT_ADDRERR Address error interrupt enable
385   *            @arg @ref PKA_IT_RAMERR RAM error interrupt enable
386   * @retval None
387   */
388 #define __HAL_PKA_DISABLE_IT(__HANDLE__, __INTERRUPT__)         ((__HANDLE__)->Instance->CR &= (~(__INTERRUPT__)))
389 
390 /** @brief  Check whether the specified PKA interrupt source is enabled or not.
391   * @param  __HANDLE__ specifies the PKA Handle
392   * @param  __INTERRUPT__ specifies the PKA interrupt source to check.
393   *        This parameter can be one of the following values:
394   *            @arg @ref PKA_IT_PROCEND End Of Operation interrupt enable
395   *            @arg @ref PKA_IT_ADDRERR Address error interrupt enable
396   *            @arg @ref PKA_IT_RAMERR RAM error interrupt enable
397   * @retval The new state of __INTERRUPT__ (SET or RESET)
398   */
399 #define __HAL_PKA_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__)      ((((__HANDLE__)->Instance->CR\
400                                                                    & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
401 
402 /** @brief  Check whether the specified PKA flag is set or not.
403   * @param  __HANDLE__ specifies the PKA Handle
404   * @param  __FLAG__ specifies the flag to check.
405   *        This parameter can be one of the following values:
406   *            @arg @ref PKA_FLAG_PROCEND End Of Operation
407   *            @arg @ref PKA_FLAG_ADDRERR Address error
408   *            @arg @ref PKA_FLAG_RAMERR RAM error
409   * @retval The new state of __FLAG__ (SET or RESET)
410   */
411 #define __HAL_PKA_GET_FLAG(__HANDLE__, __FLAG__)                (((((__HANDLE__)->Instance->SR)\
412                                                                    & (__FLAG__)) == (__FLAG__)) ? SET : RESET)
413 
414 /** @brief  Clear the PKA pending flags which are cleared by writing 1 in a specific bit.
415   * @param  __HANDLE__ specifies the PKA Handle
416   * @param  __FLAG__ specifies the flag to clear.
417   *          This parameter can be any combination of the following values:
418   *            @arg @ref PKA_FLAG_PROCEND End Of Operation
419   *            @arg @ref PKA_FLAG_ADDRERR Address error
420   *            @arg @ref PKA_FLAG_RAMERR RAM error
421   * @retval None
422   */
423 #define __HAL_PKA_CLEAR_FLAG(__HANDLE__, __FLAG__)              ((__HANDLE__)->Instance->CLRFR = (__FLAG__))
424 
425 /** @brief  Enable the specified PKA peripheral.
426   * @param  __HANDLE__ specifies the PKA Handle
427   * @retval None
428   */
429 #define __HAL_PKA_ENABLE(__HANDLE__)                            (SET_BIT((__HANDLE__)->Instance->CR,  PKA_CR_EN))
430 
431 /** @brief  Disable the specified PKA peripheral.
432   * @param  __HANDLE__ specifies the PKA Handle
433   * @retval None
434   */
435 #define __HAL_PKA_DISABLE(__HANDLE__)                           (CLEAR_BIT((__HANDLE__)->Instance->CR, PKA_CR_EN))
436 
437 /** @brief  Start a PKA operation.
438   * @param  __HANDLE__ specifies the PKA Handle
439   * @retval None
440   */
441 #define __HAL_PKA_START(__HANDLE__)                             (SET_BIT((__HANDLE__)->Instance->CR,  PKA_CR_START))
442 /**
443   * @}
444   */
445 
446 /* Private macros --------------------------------------------------------*/
447 /* Exported functions --------------------------------------------------------*/
448 /** @addtogroup PKA_Exported_Functions
449   * @{
450   */
451 
452 /** @addtogroup PKA_Exported_Functions_Group1
453   * @{
454   */
455 /* Initialization and de-initialization functions *****************************/
456 HAL_StatusTypeDef HAL_PKA_Init(PKA_HandleTypeDef *hpka);
457 HAL_StatusTypeDef HAL_PKA_DeInit(PKA_HandleTypeDef *hpka);
458 void              HAL_PKA_MspInit(PKA_HandleTypeDef *hpka);
459 void              HAL_PKA_MspDeInit(PKA_HandleTypeDef *hpka);
460 
461 #if (USE_HAL_PKA_REGISTER_CALLBACKS == 1)
462 /* Callbacks Register/UnRegister functions  ***********************************/
463 HAL_StatusTypeDef HAL_PKA_RegisterCallback(PKA_HandleTypeDef *hpka, HAL_PKA_CallbackIDTypeDef CallbackID,
464                                            pPKA_CallbackTypeDef pCallback);
465 HAL_StatusTypeDef HAL_PKA_UnRegisterCallback(PKA_HandleTypeDef *hpka, HAL_PKA_CallbackIDTypeDef CallbackID);
466 #endif /* USE_HAL_PKA_REGISTER_CALLBACKS */
467 
468 /**
469   * @}
470   */
471 
472 /** @addtogroup PKA_Exported_Functions_Group2
473   * @{
474   */
475 /* IO operation functions *****************************************************/
476 /* High Level Functions *******************************************************/
477 HAL_StatusTypeDef HAL_PKA_ModExp(PKA_HandleTypeDef *hpka, PKA_ModExpInTypeDef *in, uint32_t Timeout);
478 HAL_StatusTypeDef HAL_PKA_ModExp_IT(PKA_HandleTypeDef *hpka, PKA_ModExpInTypeDef *in);
479 HAL_StatusTypeDef HAL_PKA_ModExpFastMode(PKA_HandleTypeDef *hpka, PKA_ModExpFastModeInTypeDef *in, uint32_t Timeout);
480 HAL_StatusTypeDef HAL_PKA_ModExpFastMode_IT(PKA_HandleTypeDef *hpka, PKA_ModExpFastModeInTypeDef *in);
481 void HAL_PKA_ModExp_GetResult(PKA_HandleTypeDef *hpka, uint8_t *pRes);
482 
483 HAL_StatusTypeDef HAL_PKA_ECDSASign(PKA_HandleTypeDef *hpka, PKA_ECDSASignInTypeDef *in, uint32_t Timeout);
484 HAL_StatusTypeDef HAL_PKA_ECDSASign_IT(PKA_HandleTypeDef *hpka, PKA_ECDSASignInTypeDef *in);
485 void HAL_PKA_ECDSASign_GetResult(PKA_HandleTypeDef *hpka, PKA_ECDSASignOutTypeDef *out,
486                                  PKA_ECDSASignOutExtParamTypeDef *outExt);
487 
488 HAL_StatusTypeDef HAL_PKA_ECDSAVerif(PKA_HandleTypeDef *hpka, PKA_ECDSAVerifInTypeDef *in, uint32_t Timeout);
489 HAL_StatusTypeDef HAL_PKA_ECDSAVerif_IT(PKA_HandleTypeDef *hpka, PKA_ECDSAVerifInTypeDef *in);
490 uint32_t HAL_PKA_ECDSAVerif_IsValidSignature(PKA_HandleTypeDef const *const hpka);
491 
492 HAL_StatusTypeDef HAL_PKA_RSACRTExp(PKA_HandleTypeDef *hpka, PKA_RSACRTExpInTypeDef *in, uint32_t Timeout);
493 HAL_StatusTypeDef HAL_PKA_RSACRTExp_IT(PKA_HandleTypeDef *hpka, PKA_RSACRTExpInTypeDef *in);
494 void HAL_PKA_RSACRTExp_GetResult(PKA_HandleTypeDef *hpka, uint8_t *pRes);
495 
496 HAL_StatusTypeDef HAL_PKA_PointCheck(PKA_HandleTypeDef *hpka, PKA_PointCheckInTypeDef *in, uint32_t Timeout);
497 HAL_StatusTypeDef HAL_PKA_PointCheck_IT(PKA_HandleTypeDef *hpka, PKA_PointCheckInTypeDef *in);
498 uint32_t HAL_PKA_PointCheck_IsOnCurve(PKA_HandleTypeDef const *const hpka);
499 
500 HAL_StatusTypeDef HAL_PKA_ECCMul(PKA_HandleTypeDef *hpka, PKA_ECCMulInTypeDef *in, uint32_t Timeout);
501 HAL_StatusTypeDef HAL_PKA_ECCMul_IT(PKA_HandleTypeDef *hpka, PKA_ECCMulInTypeDef *in);
502 HAL_StatusTypeDef HAL_PKA_ECCMulFastMode(PKA_HandleTypeDef *hpka, PKA_ECCMulFastModeInTypeDef *in, uint32_t Timeout);
503 HAL_StatusTypeDef HAL_PKA_ECCMulFastMode_IT(PKA_HandleTypeDef *hpka, PKA_ECCMulFastModeInTypeDef *in);
504 void HAL_PKA_ECCMul_GetResult(PKA_HandleTypeDef *hpka, PKA_ECCMulOutTypeDef *out);
505 
506 HAL_StatusTypeDef HAL_PKA_Add(PKA_HandleTypeDef *hpka, PKA_AddInTypeDef *in, uint32_t Timeout);
507 HAL_StatusTypeDef HAL_PKA_Add_IT(PKA_HandleTypeDef *hpka, PKA_AddInTypeDef *in);
508 HAL_StatusTypeDef HAL_PKA_Sub(PKA_HandleTypeDef *hpka, PKA_SubInTypeDef *in, uint32_t Timeout);
509 HAL_StatusTypeDef HAL_PKA_Sub_IT(PKA_HandleTypeDef *hpka, PKA_SubInTypeDef *in);
510 HAL_StatusTypeDef HAL_PKA_Cmp(PKA_HandleTypeDef *hpka, PKA_CmpInTypeDef *in, uint32_t Timeout);
511 HAL_StatusTypeDef HAL_PKA_Cmp_IT(PKA_HandleTypeDef *hpka, PKA_CmpInTypeDef *in);
512 HAL_StatusTypeDef HAL_PKA_Mul(PKA_HandleTypeDef *hpka, PKA_MulInTypeDef *in, uint32_t Timeout);
513 HAL_StatusTypeDef HAL_PKA_Mul_IT(PKA_HandleTypeDef *hpka, PKA_MulInTypeDef *in);
514 HAL_StatusTypeDef HAL_PKA_ModAdd(PKA_HandleTypeDef *hpka, PKA_ModAddInTypeDef *in, uint32_t Timeout);
515 HAL_StatusTypeDef HAL_PKA_ModAdd_IT(PKA_HandleTypeDef *hpka, PKA_ModAddInTypeDef *in);
516 HAL_StatusTypeDef HAL_PKA_ModSub(PKA_HandleTypeDef *hpka, PKA_ModSubInTypeDef *in, uint32_t Timeout);
517 HAL_StatusTypeDef HAL_PKA_ModSub_IT(PKA_HandleTypeDef *hpka, PKA_ModSubInTypeDef *in);
518 HAL_StatusTypeDef HAL_PKA_ModInv(PKA_HandleTypeDef *hpka, PKA_ModInvInTypeDef *in, uint32_t Timeout);
519 HAL_StatusTypeDef HAL_PKA_ModInv_IT(PKA_HandleTypeDef *hpka, PKA_ModInvInTypeDef *in);
520 HAL_StatusTypeDef HAL_PKA_ModRed(PKA_HandleTypeDef *hpka, PKA_ModRedInTypeDef *in, uint32_t Timeout);
521 HAL_StatusTypeDef HAL_PKA_ModRed_IT(PKA_HandleTypeDef *hpka, PKA_ModRedInTypeDef *in);
522 HAL_StatusTypeDef HAL_PKA_MontgomeryMul(PKA_HandleTypeDef *hpka, PKA_MontgomeryMulInTypeDef *in, uint32_t Timeout);
523 HAL_StatusTypeDef HAL_PKA_MontgomeryMul_IT(PKA_HandleTypeDef *hpka, PKA_MontgomeryMulInTypeDef *in);
524 void HAL_PKA_Arithmetic_GetResult(PKA_HandleTypeDef *hpka, uint32_t *pRes);
525 
526 HAL_StatusTypeDef HAL_PKA_MontgomeryParam(PKA_HandleTypeDef *hpka, PKA_MontgomeryParamInTypeDef *in, uint32_t Timeout);
527 HAL_StatusTypeDef HAL_PKA_MontgomeryParam_IT(PKA_HandleTypeDef *hpka, PKA_MontgomeryParamInTypeDef *in);
528 void HAL_PKA_MontgomeryParam_GetResult(PKA_HandleTypeDef *hpka, uint32_t *pRes);
529 
530 
531 HAL_StatusTypeDef HAL_PKA_Abort(PKA_HandleTypeDef *hpka);
532 void HAL_PKA_RAMReset(PKA_HandleTypeDef *hpka);
533 void HAL_PKA_OperationCpltCallback(PKA_HandleTypeDef *hpka);
534 void HAL_PKA_ErrorCallback(PKA_HandleTypeDef *hpka);
535 void HAL_PKA_IRQHandler(PKA_HandleTypeDef *hpka);
536 /**
537   * @}
538   */
539 
540 /** @addtogroup PKA_Exported_Functions_Group3
541   * @{
542   */
543 /* Peripheral State and Error functions ***************************************/
544 HAL_PKA_StateTypeDef HAL_PKA_GetState(PKA_HandleTypeDef *hpka);
545 uint32_t             HAL_PKA_GetError(PKA_HandleTypeDef *hpka);
546 /**
547   * @}
548   */
549 
550 /**
551   * @}
552   */
553 
554 /**
555   * @}
556   */
557 
558 #endif /* defined(PKA) && defined(HAL_PKA_MODULE_ENABLED) */
559 
560 /**
561   * @}
562   */
563 
564 #ifdef __cplusplus
565 }
566 #endif
567 
568 #endif /* STM32L5xx_HAL_PKA_H */
569