TinyCrypt PK parse: Pass TC keypair structure to ECDSA pubkey parse
This commit is contained in:
parent
68d5478d8d
commit
7e38c37302
1 changed files with 7 additions and 6 deletions
|
@ -547,7 +547,7 @@ static int pk_get_ecpubkey( unsigned char **p, const unsigned char *end,
|
||||||
/*
|
/*
|
||||||
* Import a point from unsigned binary data (SEC1 2.3.4)
|
* Import a point from unsigned binary data (SEC1 2.3.4)
|
||||||
*/
|
*/
|
||||||
static int uecc_public_key_read_binary( uint8_t *pt,
|
static int uecc_public_key_read_binary( mbedtls_uecc_keypair *uecc_keypair,
|
||||||
const unsigned char *buf, size_t ilen )
|
const unsigned char *buf, size_t ilen )
|
||||||
{
|
{
|
||||||
if( ilen != 2 * NUM_ECC_BYTES + 1 )
|
if( ilen != 2 * NUM_ECC_BYTES + 1 )
|
||||||
|
@ -558,7 +558,7 @@ static int uecc_public_key_read_binary( uint8_t *pt,
|
||||||
if( buf[0] != 0x04 )
|
if( buf[0] != 0x04 )
|
||||||
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
|
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
|
||||||
|
|
||||||
memcpy( pt, buf + 1, ilen - 1);
|
memcpy( uecc_keypair->public_key, buf + 1, 2 * NUM_ECC_BYTES );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
@ -567,9 +567,10 @@ static int pk_get_ueccpubkey( unsigned char **p,
|
||||||
const unsigned char *end,
|
const unsigned char *end,
|
||||||
uint8_t *pk_context)
|
uint8_t *pk_context)
|
||||||
{
|
{
|
||||||
|
mbedtls_uecc_keypair *uecc_keypair = (mbedtls_uecc_keypair *) pk_context;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = uecc_public_key_read_binary( pk_context,
|
ret = uecc_public_key_read_binary( uecc_keypair,
|
||||||
(const unsigned char *) *p, end - *p );
|
(const unsigned char *) *p, end - *p );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -956,7 +957,7 @@ static int pk_parse_key_sec1_der( mbedtls_uecc_keypair *keypair,
|
||||||
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
|
return( MBEDTLS_ERR_PK_KEY_INVALID_FORMAT +
|
||||||
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
|
MBEDTLS_ERR_ASN1_LENGTH_MISMATCH );
|
||||||
|
|
||||||
if( ( ret = uecc_public_key_read_binary( keypair->public_key,
|
if( ( ret = uecc_public_key_read_binary( keypair,
|
||||||
(const unsigned char *) p, end2 - p ) ) == 0 )
|
(const unsigned char *) p, end2 - p ) ) == 0 )
|
||||||
{
|
{
|
||||||
pubkey_done = 1;
|
pubkey_done = 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue