cancel
Showing results for 
Search instead for 
Did you mean: 

RSA Signature generated by X-Cube Crypto Library and Python script are not matching even though we used same key for both methods.

CChee.2
Associate

Hello All,

I Integrated X-Cube-CRYPTOLIB V4.1.0 into my project. My application to generate SHA256 for the "xx_xx.hex " file and generate RSA signature . SHA256 value generated by X-Cube-CRYPTOLIB and python script both are same. But RSA signature is not same.

created 1024 key pair by using "openssl" command . I installed "cryptography" python library and used" serialization.load_pem_private_key" method to read the private key from the pem file. private_key.sign method is used to generate Signature.

Please find the attachments for python script and X -Cube code.

Hash value is generated by X-Cube-CRYPTOLIB is in decimal format , But it is equivalent to generated hash value (hex format) by python script .

But the signature which is generated X-Cube-CRYPTOLIB decimal values are not equivalent to the generated signature (hex format ) by python script.

Below is the result of python script;

Hexadecimal signature: 72869266541a76bc2a73437e53c1c917e4b2dd323f8b9735e44f6d600e7fe414c0899e41e0a89c557bcd3673dac2084409fabb0ef52574108363fdd3bdc44d2239371fe3e0617966f93964db42d12ad91b254b70af7add8cd1043d7f6a5857ea834c885480d5ac2d792c514233fcc62eea3149fc8fa50e0e2579f780ff6e1c37

Please find the below image to check signature generated by X-Cube-CRYPTOLIB, it is not complete.But just for reference we can see few bytes.


_legacyfs_online_stmicro_images_0693W00000dDItgQAG.png 

in script I used PKCS1v15 padding scheme for RSA signature, Which is similar to ST code. But still the signatures are not same.

Please suggest what is the wrong here.

1 REPLY 1
CChee.2
Associate

@Jocelyn RICARD : Could you please check my question and provide your suggestion.