2024-05-17 02:17 AM
I am working with the NUCLEO-H563ZI, and I'm trying to write an application that verifies an ECDSA Certificate. I have already successfully done the verification using the HAL_PKA_ECDSAVerif() function provided with all the parameters. My problem is that the public key that I get is in the compact form (I only have the X part and a bit to indicate which Y part to choose) so I have to calculate the Y part separately before running the verification. To get the Y part I must use the ECC curve function y = modular square root of (x^3 + a.x + b). The parameters are 192 bits long so I can't just directly calculate everything so I tried using the PKA Arithmetic function but I cannot get them to work. The function just gets stuck until timeout. With the HAL_MAX_DELAY it just stays stuck forever. Here is the code below:
//Just a mockup of the actual code
uint32_t number1[6] = {0x12345678, 0x9ABCDEF0, 0x13579BDF, 0x2468ACE0, 0x02468ACE, 0x13579BDF};
uint32_t number2[6] = {0x98765432, 0xABCDEF09, 0x2468ACE0, 0x13579BDF, 0x02468ACE, 0x2468ACE0};
uint32_t result [7];
PKA_AddInTypeDef Addition_Struct;
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_RNG_Init();
MX_PKA_Init();
Addition_Struct.size = 6;
Addition_Struct.pOp1 = number1;
Addition_Struct.pOp2 = number2;
HAL_StatusTypeDef status = HAL_PKA_Add (&hpka, &Addition_Struct, 1000);
//It doesn't work even with HAL_MAX_DELAY
// Check if addition was successful
if (HAL_PKA_GetState (&hpka) == HAL_OK){
printf("Operation Successful\n");
HAL_PKA_Arithmetic_GetResult(&hpka, result);
} else{
// Addition failed
printf("Error occurred during addition\n");
uint32_t error = HAL_PKA_GetError (&hpka); //Error has value 12
}
while (1)
{
}
}
What could the problem be? And do you have any idea how can I calculate the y part of the public key in an efficient way ?
Solved! Go to Solution.
2024-05-20 11:29 PM
Hello @A_A_Phil ,
the NUCLEO-H563ZI does not support HW accelerated crypto.
You should use the STM32H573I-DK
Best regards
Jocelyn
2024-05-20 09:59 AM
This post has been escalated to the ST Online Support Team for additional assistance. We'll contact you directly.
2024-05-20 11:29 PM
Hello @A_A_Phil ,
the NUCLEO-H563ZI does not support HW accelerated crypto.
You should use the STM32H573I-DK
Best regards
Jocelyn