1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-29 11:41:15 +03:00

Fix endianness and masking for Curve25519 keys handled by PSA

Changed PSA core (and PKWrite) from reaching into MPI to using the proper
ecp function to fetch a private key.
Added changelog.

Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
This commit is contained in:
Steven Cooreman
2020-06-11 16:50:36 +02:00
parent 6f5cc71ad1
commit e3fd39289e
3 changed files with 18 additions and 9 deletions

View File

@ -166,9 +166,10 @@ static int pk_write_ec_private( unsigned char **p, unsigned char *start,
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
size_t byte_length = ( ec->grp.pbits + 7 ) / 8;
size_t output_length;
unsigned char tmp[MBEDTLS_ECP_MAX_BYTES];
ret = mbedtls_mpi_write_binary( &ec->d, tmp, byte_length );
ret = mbedtls_ecp_write_key( ec->grp.id, ec, &output_length, tmp, byte_length );
if( ret != 0 )
goto exit;
ret = mbedtls_asn1_write_octet_string( p, start, tmp, byte_length );