HAL PKA How to Use ¶
- group PKA_How_To_Use
-
Use the steps below to configure and run a PKA operation.
This file provides firmware functions to manage the following features of the PKA peripheral:
Initialization and deinitialization functions
Configuration functions
Process management functions
Callback functions
State and error functions
How to use the PKA HAL module driver ¶
Initialization and deinitialization functions: ¶
Declare a hal_pka_handle_t handle structure, for example, hal_pka_handle_t hpka.
Use the HAL_PKA_Init() function to initialize the PKA handle and associate the physical instance.
Use the HAL_PKA_DeInit() function to abort any ongoing operation and reset the state.
Configuration functions ¶
Use HAL_PKA_SetConfigModExp() function to configure the Modular exponentiation operating mode.
Use HAL_PKA_SetConfigModExpFast() function to configure the Modular exponentiation (fast) operating mode.
Use HAL_PKA_SetConfigModExpProtect() function to configure the modular exponentiation (protected) operating mode when the mode is supported.
Use HAL_PKA_SetConfigAdd() function to configure the Arithmetic addition operating mode.
Use HAL_PKA_SetConfigSub() function to configure the Arithmetic subtraction operating mode.
Use HAL_PKA_SetConfigCmp() function to configure the Arithmetic comparison operating mode.
Use HAL_PKA_SetConfigMul() function to configure the Arithmetic multiplication operating mode.
Use HAL_PKA_SetConfigModAdd() function to configure the Modular addition operating mode.
Use HAL_PKA_SetConfigModSub() function to configure the Modular subtraction operating mode.
Use HAL_PKA_SetConfigModInv() function to configure the Modular inversion operating mode.
Use HAL_PKA_SetConfigModRed() function to configure the Modular reduction operating mode.
Use HAL_PKA_SetConfigMontgomeryMul() function to configure the Montgomery multiplication operating mode.
Use HAL_PKA_SetConfigMontgomery() function to configure the Montgomery parameter operating mode.
Use HAL_PKA_ECDSA_SetConfigSignatureProtect() function to configure the elliptic curves over prime fields signature (protected) operating mode when the mode is supported.
Use HAL_PKA_ECDSA_SetConfigVerifSignature() function to configure the elliptic curves over prime fields verification operating mode.
Use HAL_PKA_RSA_SetConfigCRTExp() function to configure the RSA CRT exponentiation operating mode.
Use HAL_PKA_RSA_SetConfigSignature() function to configure the RSA signature operating mode.
Use HAL_PKA_RSA_SetConfigSignatureFast() function to configure the RSA signature (fast) operating mode.
Use HAL_PKA_RSA_SetConfigSignatureProtect() function to configure the RSA signature (protected) operating mode when the mode is supported.
Use HAL_PKA_RSA_SetConfigVerifSignature() function to configure the RSA verification operating mode.
Use HAL_PKA_ECC_SetConfigPointCheck() function to configure the Point on elliptic curve check operating mode.
Use HAL_PKA_ECC_SetConfigMulProtect() function to configure the ECC scalar multiplication (protected) operating mode when the mode is supported.
Use HAL_PKA_ECC_SetConfigDoubleBaseLadder() function to configure the ECC double base ladder operating mode.
Use HAL_PKA_ECC_SetConfigProjectiveToAffine() function to configure the ECC projective to affine operating mode.
Use HAL_PKA_ECC_SetConfigCompleteAdd() function to configure the ECC complete addition operating mode.
Process management functions ¶
Use HAL_PKA_Compute() function to execute the operation in blocking mode.
Use HAL_PKA_Compute_IT() function to execute the operation in interrupt mode.
Call HAL_PKA_IRQHandler() in the PKA NVIC vector interrupt handler to handle PKA interrupts.
Use HAL_PKA_Abort() function to abort any ongoing operation. Do not call this API from an interrupt service routine.
Use HAL_PKA_GetResultModExp() function to retrieve the result of the Modular exponentiation operation.
Use HAL_PKA_GetResultModExpFast() function to retrieve the result of the Modular exponentiation (Fast) operation.
Use HAL_PKA_GetResultModExpProtect() function to retrieve the result of the Modular exponentiation (Protected) operation when the mode is supported.
Use HAL_PKA_GetResultAdd() function to retrieve the result of the addition operation.
Use HAL_PKA_GetResultSub() function to retrieve the result of the subtraction operation.
Use HAL_PKA_GetResultMul() function to retrieve the result of the multiplication operation.
Use HAL_PKA_GetResultCmp() function to retrieve the result of the comparison operation.
Use HAL_PKA_GetResultModAdd() function to retrieve the result of the Modular addition operation.
Use HAL_PKA_GetResultModSub() function to retrieve the result of the Modular subtraction operation.
Use HAL_PKA_GetResultModInv() function to retrieve the result of the Modular inversion operation.
Use HAL_PKA_GetResultModRed() function to retrieve the result of the Modular reduction operation.
Use HAL_PKA_GetResultMontgomeryMul() function to retrieve the result of the Montgomery parameter operation.
Use HAL_PKA_GetResultMontgomery() function to retrieve the result of the Montgomery parameter operation.
Use HAL_PKA_ECDSA_GetResultSignatureProtect() function to retrieve the result of the elliptic curves over prime fields signature (protected) operation when the mode is supported.
Use HAL_PKA_ECDSA_IsValidVerifSignature() function to check if the signature is verified.
Use HAL_PKA_RSA_GetResultCRTExp() function to retrieve the result of the RSA CRT exponentiation operation.
Use HAL_PKA_RSA_GetResultSignature() function to retrieve the result of the RSA signature operation.
Use HAL_PKA_RSA_GetResultSignatureFast() function to retrieve the result of the RSA signature (fast) operation.
Use HAL_PKA_RSA_GetResultSignatureProtect() function to retrieve the result of the RSA signature (protected) operation when the mode is supported.
Use HAL_PKA_RSA_IsValidVerifSignature() function to check if the signature is verified.
Use HAL_PKA_ECC_IsPointCheckOnCurve() function to check if the point is on the curve.
Use HAL_PKA_ECC_GetResultMulProtect() function to retrieve the result of the ECC scalar multiplication (protected) operation when the mode is supported.
Use HAL_PKA_ECC_GetResultDoubleBaseLadder() function to retrieve the result of the ECC double base ladder operation.
Use HAL_PKA_ECC_GetResultProjectiveToAffine() function to retrieve the result of the ECC projective to affine operation.
Use HAL_PKA_ECC_GetResultCompleteAdd() function to retrieve the result of the ECC complete addition operation.
Callback functions ¶
The HAL_PKA_OperationCpltCallback() function is called when the process is complete.
The HAL_PKA_ErrorCallback() function is called in case of an error.
Use the function HAL_PKA_RegisterOperationCpltCallback() to register the PKA Operation Complete Callback to be used instead of the weak HAL_PKA_OperationCpltCallback() predefined callback.
Use the function HAL_PKA_RegisterErrorCallback() to register the PKA Error Callback to be used instead of the weak HAL_PKA_ErrorCallback() predefined callback.
Peripheral state and error functions ¶
Use the HAL_PKA_GetState() function to get the current state of the HAL PKA driver.
Use the HAL_PKA_GetLastErrorCodes() function to get the last error codes.
Use the HAL_PKA_SetUserData() function to set the PKA user data.
Use the HAL_PKA_GetUserData() function to get the PKA user data.
PKA RAM erase function ¶
Use the HAL_PKA_RAMMassErase() function to fully erase the content of the PKA RAM.