2023-11-14 03:39 AM - last edited on 2023-11-14 04:41 AM by Sarra.S
Hello,
I am using the STM32 Cryptolib. I need to get the modulus and exponent of RSA public key from a .pub or .pem files. After decoded from base64 I need to decode the DER format (in ASN.1 format). Has anyone any suggestion of which libray may I use? Cryptolib only accept modulus and exponent has two parameters.
Solved! Go to Solution.
2023-11-22 01:03 AM
Hello everybody,
I solve by using wolfSSL library, which is available in STM32CubeIDE already. It allows to read pem public key and certificates. It allows to check certificate chain as well.
2023-11-14 09:22 AM
Hello @lukin ,
can you explain more what is the type of conversion you will need to do and how you generated the keys in the first place ?
meanwhile i suggest you do key formatting with a python script to give as an input for the cryptolib accepted format this is explained in this thread .
BR
2023-11-14 10:07 AM
Not sure but this thread may help you:
2023-11-14 01:25 PM
Hi, I need to read PEM file, generated externally, which contain a RSA public key. I should extract the modulus and exponent in order to pass them to crypto library so to verify a signed file. I see openssl is a typical lib but size of the library is big. Any other way to retrieve this information?
Thank you
2023-11-15 12:21 AM
Hello ,
do you need to do the extraction in the MCU or it can be done externally ? because if you can do this on your computer it can be done using python and then it can be feed to you code in C formatted table in hex representation .
BR
2023-11-15 01:11 AM
Hello,
since pem or csr certificate would loaded externally on an SD card, it would be the best to decode the files. When using csr, I should also verify trust chain.
2023-11-20 03:48 AM
Hello @lukin ,
in this case i recommend you use opensll library to decode the RSA key stored into you SD card .
This can be done by :
you will find in the attachment and example if this use-case hope this solves you problem.
BR
2023-11-22 01:03 AM
Hello everybody,
I solve by using wolfSSL library, which is available in STM32CubeIDE already. It allows to read pem public key and certificates. It allows to check certificate chain as well.
2023-11-22 01:49 AM
Hi, thank you. I then preferred to use wolfSSL. It should be lighter than openssl. Isn't it?
2023-11-22 02:02 AM
Hello @lukin
Indeed WolfSSL is lighter than OpenSSL and it's more suited for your application if you are concerned about memory usage . this is explained in the following link . OpenSSL has the edge when it comes to the robustness of the solution
because OpenSSL has a longer track record and a larger community of developers, which means it has been more extensively tested and audited.
The are basically the same in term of usage .
BR