I'm parsing an RSA private key from a buffer with mbedtls_pk_parse_key()
, which returns 0. I then call mbedtls_ecdsa_from_keypair()
and it returns -20096 (which I believe corresponds to MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE)
.
I'm building something similar to the following code using the XDK Workbench:
mbedtls_mpi r, s;
mbedtls_pk_context pk;
mbedtls_ecdsa_context ecdsa_sign;
mbedtls_mpi_init(&r);
mbedtls_mpi_init(&s);
mbedtls_pk_init(&pk);
mbedtls_ecdsa_init(&ecdsa_sign);
int ret = mbedtls_pk_parse_key(&pk, priv_key, strlen(priv_key) + 1, NULL, 0);
/* Returns 0 */
ret = mbedtls_ecdsa_from_keypair(&ecdsa_sign, pk.pk_ctx);
/* Returns -20096 */
When I look at the implementation of mbedtls_ecdsa_from_keypair()
, I see that pk.pk_ctx
is treated as an mbedtls_ecp_keypair
. The grp
member of the mbedtls_ecp_keypair
has an id
member of zero, which corresponds to MBEDTLS_ECP_DP_NONE
. Am I passing the wrong thing to mbedtls_ecdsa_from_keypair
?