Skip to content

Skip public key computation in mbedtls_psa_ecp_generate_key() #9732

@jan-bruckner

Description

@jan-bruckner

Suggested enhancement

mbedtls_psa_ecp_generate_key() calls mbedtls_ecp_gen_key() to generate an ECC key. This ends up calling mbedtls_ecp_gen_keypair_base(), which first generates the private key (which mainly consists of random number generation), but also computes the corresponding public key with mbedtls_ecp_mul() (which is computationally much more expensive).

int mbedtls_ecp_gen_keypair_base(mbedtls_ecp_group *grp,
const mbedtls_ecp_point *G,
mbedtls_mpi *d, mbedtls_ecp_point *Q,
int (*f_rng)(void *, unsigned char *, size_t),
void *p_rng)
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
MBEDTLS_MPI_CHK(mbedtls_ecp_gen_privkey(grp, d, f_rng, p_rng));
MBEDTLS_MPI_CHK(mbedtls_ecp_mul(grp, Q, d, G, f_rng, p_rng));
cleanup:
return ret;
}

In PSA, only the private key is used in the API. Thus, computing the public key could be skipped, especially considering the cost of this step.

Metadata

Metadata

Labels

component-cryptoCrypto primitives and low-level interfacesenhancementsize-xsEstimated task size: extra small (a few hours at most)

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions