cancel
Showing results for 
Search instead for 
Did you mean: 

Crypto library rsa signature not matching with openssl

lukin
Associate III

Hi,

I would use the STM32 Crypto Library. I have the 4.0.1 version.

I just compiled and run the RSA\PKCS1v1.5_SignVerify example on my L4 micro and it is successful. 

Then, I generated with openssl a new 1024 key pair and signed a custom message. Then I copied private exponent, modulus and messagge arrays on firmware but signature is different. I checked also if SHA-1 hashes are equals, and they are. So, different behaviour in signature function. Where am I wrong?

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Jocelyn RICARD
ST Employee

Hello @lukin ,

did you remove the heading 00 of the modulus and private exponent ?

Best regards

Jocelyn

View solution in original post

5 REPLIES 5
Pavel A.
Evangelist III

Check error returns from any lib function that can return error result. Some lib functions require a memory buffer, but IIRC there's no way to know the required size beforehand, and it changes from version to version. If you use such functions, try to double the buffer size.

Hi, I checked and no errors from any lib function call. I even tryed to double the size of working buffer, but signature results is the same. Thanks for suggestion.

Pavel A.
Evangelist III
Jocelyn RICARD
ST Employee

Hello @lukin ,

did you remove the heading 00 of the modulus and private exponent ?

Best regards

Jocelyn

Hi Jocely,

it worked! I had a 0x00 on the heading of modulus. I did not realized it could affect results. It seems this extra byte comes from ASN.1 coding. Thank you and thanks to @Pavel A.