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