1
0
mirror of https://github.com/Mbed-TLS/mbedtls.git synced 2025-07-30 22:43:08 +03:00

Add implemetation of ECP keypair export function

Signed-off-by: Przemek Stekiel <przemyslaw.stekiel@mobica.com>
This commit is contained in:
Przemek Stekiel
2022-03-18 13:52:26 +01:00
parent 8d4bc5eeb9
commit 711d0f5e29
2 changed files with 44 additions and 0 deletions

View File

@ -3356,6 +3356,30 @@ cleanup:
return( ret );
}
/*
* Export generic key-pair parameters.
*/
int mbedtls_ecp_export(const mbedtls_ecp_keypair *key, mbedtls_ecp_group *grp,
mbedtls_mpi *d, mbedtls_ecp_point *Q)
{
int ret = MBEDTLS_ERR_ERROR_CORRUPTION_DETECTED;
ECP_VALIDATE_RET( key != NULL );
ECP_VALIDATE_RET( grp != NULL );
ECP_VALIDATE_RET( d != NULL );
ECP_VALIDATE_RET( Q != NULL );
if( ( ret = mbedtls_ecp_group_copy( grp, &key->grp ) ) != 0 )
return ret;
if( ( ret = mbedtls_mpi_copy( d, &key->d ) ) != 0 )
return ret;
if( ( ret = mbedtls_ecp_copy( Q, &key->Q ) ) != 0 )
return ret;
return 0;
}
#if defined(MBEDTLS_SELF_TEST)
/*