Function esp_idf_svc::sys::mbedtls_pk_parse_key
source ยท pub unsafe extern "C" fn mbedtls_pk_parse_key(
ctx: *mut mbedtls_pk_context,
key: *const u8,
keylen: usize,
pwd: *const u8,
pwdlen: usize,
f_rng: Option<unsafe extern "C" fn(_: *mut c_void, _: *mut u8, _: usize) -> i32>,
p_rng: *mut c_void,
) -> i32
Expand description
\ingroup pk_module / /* \brief Parse a private key in PEM or DER format
\note If #MBEDTLS_USE_PSA_CRYPTO is enabled, the PSA crypto subsystem must have been initialized by calling psa_crypto_init() before calling this function.
\param ctx The PK context to fill. It must have been initialized
but not set up.
\param 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.
\param 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
.
\param pwd Optional password for decryption.
Pass \c NULL if expecting a non-encrypted key.
Pass a string of \p pwdlen bytes if expecting an encrypted
key; a non-encrypted key will also be accepted.
The empty password is not supported.
\param pwdlen Size of the password in bytes.
Ignored if \p pwd is \c NULL.
\param f_rng RNG function, must not be \c NULL. Used for blinding.
\param p_rng RNG parameter
\note 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().
\note The key is also checked for correctness.
\return 0 if successful, or a specific PK or PEM error code