cancel
Showing results for 
Search instead for 
Did you mean: 

STM32U585 PKA -- ECC Scalar Multiplication - undocumented errors?

Doug Barnes
Associate II

[EDIT: Question below is about STM32U5 PKA, but I see the STM32L5 Cube S/W has an example "PKA_ECCscalarMultiplication" that is probably similar to what I'm trying to do. Not sure how similar PKAs are on these MCUs but I bet they are either identical or very similar. I will look at the example and post back...]

[EDIT 2: OK, it's clear that the L5 and U5 PKA share DNA, but that they are not at all identical or even "very similar". 32 bit vs. 64 bit, no error codes on output from many L5 operations (including scalar point multiplication), PKA RAM addresses, operation parameter lists, etc.]

I'm using the STM32U585's PKA to do an ECC scalar multiplication. For sure I might be configuring it wrong, although I've got a lot of stuff working with the PKA (not the best documented peripheral).

I want to multiply the base point for curve P256 by 19 (this is for a test vector). I may or may not have the PKA RAM configured properly. Regardless, upon completion, PKA RAM @ 0x680 holds the dreaded "0xCBC9" value -- the reference manual just says "Errors". None of OPERRF, ADDRERRF, or RAMERRF in PKA_SR are set.

I'd like to know specifically what went wrong so I can debug/fix the code. It's not clear to me what errors cause 0xCBC9 @ 0x680, and it's not clear which of those is causing the problem I'm seeing. I can't find any documentation on this.

(Also as far as I can tell, nothing in the current STM32CubeU5 distribution has an example that uses this mode on the PKA. I always try to start with something working and then change it, but here I can't do that.)

Thanks.

4 REPLIES 4
Jocelyn RICARD
ST Employee

Hello @Community membermith​ 

I have ported the L5 example to U5 on STM32CubeIDE

I attached the example.

You need to extract it in

STM32Cube_FW_U5_V1.0.2\Projects\B-U585I-IOT02A\Examples\PKA\

This was not really straight forward

Needed to add the RNG startup (necessary when using PKA)

and add following fields in the initialization

in.coefB =      prime256v1_B;

in.primeOrder =   prime256v1_Order;

Best regards

Jocelyn

Thank you Jocelyn, I truly appreciate you responding and taking the time to make a working example.

I'll get your code running on my board and then try to see what I am doing wrong.

I really appreciate the help, thanks!

(P.S. I'm glad to hear you say that it wasn't straightforward -- even though both the L5 & U5 have PKAs, they are definitely different "animals"!)

can we have for RSA key generation also

Jocelyn RICARD
ST Employee

Hello Rajan,

RSA key generation is not involving a simple PKA operation. So, we don't provide anything for that.

For such operation you can use mbedTLS code for instance.

Best regards

Jocelyn