mirror of
https://github.com/polhenarejos/pico-hsm.git
synced 2026-01-26 13:38:06 +00:00
Add support for Edwards key generation.
Signed-off-by: Pol Henarejos <pol.henarejos@cttc.es>
This commit is contained in:
parent
5e801fbae7
commit
e67a7091ff
1 changed files with 14 additions and 1 deletions
|
|
@ -86,10 +86,23 @@ int cmd_keypair_gen() {
|
|||
return SW_WRONG_DATA();
|
||||
}
|
||||
mbedtls_ecp_group_id ec_id = ec_get_curve_from_prime(prime, prime_len);
|
||||
printf("KEYPAIR ECC %d\r\n", ec_id);
|
||||
if (ec_id == MBEDTLS_ECP_DP_NONE) {
|
||||
return SW_FUNC_NOT_SUPPORTED();
|
||||
}
|
||||
if (ec_id == MBEDTLS_ECP_DP_CURVE25519 || ec_id == MBEDTLS_ECP_DP_CURVE448) {
|
||||
size_t g_len = 0;
|
||||
uint8_t *g = NULL;
|
||||
if (asn1_find_tag(p, tout, 0x83, &g_len, &g) != true) {
|
||||
return SW_WRONG_DATA();
|
||||
}
|
||||
if (ec_id == MBEDTLS_ECP_DP_CURVE25519 && (g[0] != 9)) {
|
||||
ec_id = MBEDTLS_ECP_DP_ED25519;
|
||||
}
|
||||
else if (ec_id == MBEDTLS_ECP_DP_CURVE448 && (g_len != 56 || g[0] != 5)) {
|
||||
ec_id = MBEDTLS_ECP_DP_ED448;
|
||||
}
|
||||
}
|
||||
printf("KEYPAIR ECC %d\r\n", ec_id);
|
||||
mbedtls_ecdsa_context ecdsa;
|
||||
mbedtls_ecdsa_init(&ecdsa);
|
||||
uint8_t index = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue