mbedtls_rsa_context to pem format

Hi, I have a mbedtls_rsa_context object that contains the private and public keys.
is there a way to obtain a string that the public key in pem (base64) format or in the standard base64 format, and not the subcomponents (N, P, Q, D, E, DP, DQ, QP)?

Hi @mrdebug
Thank you for your question!

I believe the API mbedtls_pk_write_key_pem() answers your needs. However, this API receives mbedtls_pk_context as a parameter, and not mbedtls_rsa_context.
You will need to generate an mbedtls_pk_context from your object; You can look in other posts showing how to do this.
For example, this post also addresses your question.

Mbed TLS support