aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Cooreman <steven.cooreman@silabs.com>2020-07-13 10:59:40 +0200
committerSteven Cooreman <steven.cooreman@silabs.com>2020-07-13 10:59:40 +0200
commit0024df6b3744844d8b6f8fac961ec6d55b1633fe (patch)
tree83951553030bf41e1c7f8833e408901d4bd04dc6
parent14f0e526fb91b19ab147b7165c90141b8dde03b5 (diff)
downloadmbed-tls-0024df6b3744844d8b6f8fac961ec6d55b1633fe.tar.gz
Remove superfluous argument to ecp_write_key
Removed after feedback from PR review. Signed-off-by: Steven Cooreman <steven.cooreman@silabs.com>
-rw-r--r--include/mbedtls/ecp.h3
-rw-r--r--library/ecp.c15
-rw-r--r--library/pkwrite.c2
-rw-r--r--library/psa_crypto.c4
-rw-r--r--tests/suites/test_suite_ecp.function6
5 files changed, 12 insertions, 18 deletions
diff --git a/include/mbedtls/ecp.h b/include/mbedtls/ecp.h
index 2526273fb..803d08efd 100644
--- a/include/mbedtls/ecp.h
+++ b/include/mbedtls/ecp.h
@@ -1150,7 +1150,6 @@ int mbedtls_ecp_read_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
/**
* \brief This function exports an elliptic curve private key.
*
- * \param grp_id The ECP group identifier.
* \param key The private key.
* \param buf The output buffer for containing the binary representation
* of the key. (Big endian integer for Weierstrass curves, byte
@@ -1164,7 +1163,7 @@ int mbedtls_ecp_read_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
* the group is not implemented.
* \return Another negative error code on different kinds of failure.
*/
-int mbedtls_ecp_write_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
+int mbedtls_ecp_write_key( mbedtls_ecp_keypair *key,
unsigned char *buf, size_t buflen );
/**
diff --git a/library/ecp.c b/library/ecp.c
index 94c796049..63e08dfc1 100644
--- a/library/ecp.c
+++ b/library/ecp.c
@@ -2999,23 +2999,18 @@ cleanup:
/*
* Write a private key.
*/
-int mbedtls_ecp_write_key( mbedtls_ecp_group_id grp_id, mbedtls_ecp_keypair *key,
+int mbedtls_ecp_write_key( mbedtls_ecp_keypair *key,
unsigned char *buf, size_t buflen )
{
- int ret = 0;
-
- ECP_VALIDATE_RET( key != NULL );
- ECP_VALIDATE_RET( buf != NULL );
-
- if( ( ret = mbedtls_ecp_group_load( &key->grp, grp_id ) ) != 0 )
- return( ret );
+ int ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
- ret = MBEDTLS_ERR_ECP_FEATURE_UNAVAILABLE;
+ ECP_VALIDATE_RET( key != NULL );
+ ECP_VALIDATE_RET( buf != NULL );
#if defined(ECP_MONTGOMERY)
if( mbedtls_ecp_get_type( &key->grp ) == MBEDTLS_ECP_TYPE_MONTGOMERY )
{
- if( grp_id == MBEDTLS_ECP_DP_CURVE25519 )
+ if( key->grp.id == MBEDTLS_ECP_DP_CURVE25519 )
{
if( buflen < ECP_CURVE25519_KEY_SIZE )
return MBEDTLS_ERR_ECP_BUFFER_TOO_SMALL;
diff --git a/library/pkwrite.c b/library/pkwrite.c
index 4288cd769..ca5562a77 100644
--- a/library/pkwrite.c
+++ b/library/pkwrite.c
@@ -168,7 +168,7 @@ static int pk_write_ec_private( unsigned char **p, unsigned char *start,
size_t byte_length = ( ec->grp.pbits + 7 ) / 8;
unsigned char tmp[MBEDTLS_ECP_MAX_BYTES];
- ret = mbedtls_ecp_write_key( ec->grp.id, ec, tmp, byte_length );
+ ret = mbedtls_ecp_write_key( ec, tmp, byte_length );
if( ret != 0 )
goto exit;
ret = mbedtls_asn1_write_octet_string( p, start, tmp, byte_length );
diff --git a/library/psa_crypto.c b/library/psa_crypto.c
index a620d3085..b3da8f789 100644
--- a/library/psa_crypto.c
+++ b/library/psa_crypto.c
@@ -1326,8 +1326,8 @@ static psa_status_t psa_internal_export_key( const psa_key_slot_t *slot,
if( bytes > data_size )
return( PSA_ERROR_BUFFER_TOO_SMALL );
status = mbedtls_to_psa_error(
- mbedtls_ecp_write_key(slot->data.ecp->grp.id, slot->data.ecp,
- data, bytes) );
+ mbedtls_ecp_write_key( slot->data.ecp,
+ data, bytes ) );
if( status != PSA_SUCCESS )
return( status );
memset( data + bytes, 0, data_size - bytes );
diff --git a/tests/suites/test_suite_ecp.function b/tests/suites/test_suite_ecp.function
index d014e8a7d..ec31c11a1 100644
--- a/tests/suites/test_suite_ecp.function
+++ b/tests/suites/test_suite_ecp.function
@@ -1090,7 +1090,7 @@ void mbedtls_ecp_read_key( int grp_id, data_t* in_key, int expected, int canonic
{
unsigned char buf[MBEDTLS_ECP_MAX_BYTES];
- ret = mbedtls_ecp_write_key( grp_id, &key, buf, in_key->len );
+ ret = mbedtls_ecp_write_key( &key, buf, in_key->len );
TEST_ASSERT( ret == 0 );
ASSERT_COMPARE( in_key->x, in_key->len,
@@ -1101,13 +1101,13 @@ void mbedtls_ecp_read_key( int grp_id, data_t* in_key, int expected, int canonic
unsigned char export1[MBEDTLS_ECP_MAX_BYTES];
unsigned char export2[MBEDTLS_ECP_MAX_BYTES];
- ret = mbedtls_ecp_write_key( grp_id, &key, export1, in_key->len );
+ ret = mbedtls_ecp_write_key( &key, export1, in_key->len );
TEST_ASSERT( ret == 0 );
ret = mbedtls_ecp_read_key( grp_id, &key2, export1, in_key->len );
TEST_ASSERT( ret == expected );
- ret = mbedtls_ecp_write_key( grp_id, &key2, export2, in_key->len );
+ ret = mbedtls_ecp_write_key( &key2, export2, in_key->len );
TEST_ASSERT( ret == 0 );
ASSERT_COMPARE( export1, in_key->len,