mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-28 00:21:48 +03:00
Add RNG params to private key parsing
This is necessary for the case where the public part of an EC keypair needs to be computed from the private part - either because it was not included (it's an optional component) or because it was compressed (a format we can't parse). This changes the API of two public functions: mbedtls_pk_parse_key() and mbedtls_pk_parse_keyfile(). Tests and programs have been adapted. Some programs use a non-secure RNG (from the test library) just to get things to compile and run; in a future commit this should be improved in order to demonstrate best practice. Signed-off-by: Manuel Pégourié-Gonnard <manuel.pegourie-gonnard@arm.com>
This commit is contained in:
@ -1548,12 +1548,12 @@ int main( int argc, char *argv[] )
|
||||
else
|
||||
#if defined(MBEDTLS_FS_IO)
|
||||
if( strlen( opt.key_file ) )
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, opt.key_pwd );
|
||||
ret = mbedtls_pk_parse_keyfile( &pkey, opt.key_file, opt.key_pwd, rng_get, &rng );
|
||||
else
|
||||
#endif
|
||||
ret = mbedtls_pk_parse_key( &pkey,
|
||||
(const unsigned char *) mbedtls_test_cli_key,
|
||||
mbedtls_test_cli_key_len, NULL, 0 );
|
||||
mbedtls_test_cli_key_len, NULL, 0, rng_get, &rng );
|
||||
if( ret != 0 )
|
||||
{
|
||||
mbedtls_printf( " failed\n ! mbedtls_pk_parse_key returned -0x%x\n\n",
|
||||
|
Reference in New Issue
Block a user