Please forgive the fact that I am a little new to generating key pairs. I have done this using openssl in the past but now I’m working on an embedded device(ESP32) and have to do this at a much lower level so some things are going over my head.
Essentially I am provisioning a device to Google IoT but this requires a key pair to be generated on the device for customer ease of use. This is google’s documenation on generating the pair with openssl:
I am attempting to accomplish the same thing using mbedtls.
I found mbedtls_rsa_gen_key and did some slight porting of this code to get it running successfully on the ESP32.
This does appear to create a public key file and a private key file. However it is not in the format I’m use to seeing(PEM). How do I go about converting these two files(rsa_pub.txt/rsa_priv.txt) into PEM files? I tried creating a pk_context and copied the information over to the Public Key abstraction Layer as @ roneld01 explained on Write RSA public key top PEM but I’m a bit lost.
A light nudge in the right direction would be most appreciated.
Thank you so much for reading and have a great day.