OP-TEE / optee_os

Trusted side of the TEE
Other
1.52k stars 1.03k forks source link

Right way to use ecp #6864

Open arunlalkm-intel opened 1 month ago

arunlalkm-intel commented 1 month ago

I have a very basic use case, to use a buffer and perform ECDSA encryption in a TA application. I also want to read back the private key which is generated.

I see functions like mbedtls_ecp_gen_key but I have failed to find enough details on what steps to follow to use this function. It will be really helpful if I can be pointed to a example. Or let me know If there is some other way to achieve the end goal.

jenswi-linaro commented 1 month ago

Have you tried doing the same with the GP API https://globalplatform.org/specs-library/tee-internal-core-api-specification/ ?

arunlalkm-intel commented 1 month ago

I have not used.

I have tried the following code from few examples I can find. And still no luck.

static void testEcdsa2() { mbedtls_ecdsa_context ecdsa; const mbedtls_ecp_curve_info* curve_info; size_t sig_len; unsigned char tmp[200]; unsigned char buf[32];

memset(buf, 0x2A, sizeof(buf));

mbedtls_ecdsa_init(&ecdsa);

if (mbedtls_ecdsa_genkey(&ecdsa, MBEDTLS_ECP_DP_BP256R1, myrand, NULL) != 0)
{
    return;
}

if (mbedtls_ecdsa_write_signature(&ecdsa, MBEDTLS_MD_SHA256, buf,
    256,
    tmp, sizeof(tmp), &sig_len, myrand,
    NULL) != 0)
{
    return;
}

mbedtls_ecdsa_free(&ecdsa);

}

github-actions[bot] commented 4 days ago

This issue has been marked as a stale issue because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this issue will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time.