mbedtls_pk_parse_public_key() function
Parse a public key in PEM or DER format
Arguments
ctx
The PK context to fill. It must have been initialized but not set up.
key
Input buffer to parse. The buffer must contain the input exactly, with no extra trailing material. For PEM, the buffer must contain a null-terminated string.
keylen
Size of \b key in bytes. For PEM data, this includes the terminating null byte, so \p keylen must be equal to `strlen(key) + 1`.
Return value
0 if successful, or a specific PK or PEM error code
Notes
On entry, ctx must be empty, either freshly initialised with mbedtls_pk_init() or reset with mbedtls_pk_free(). If you need a specific key type, check the result with mbedtls_pk_can_do(). The key is also checked for correctness.