TinyCrypt PK parse: Simplify TinyCrypt public key parsing

This commit is contained in:
Hanno Becker 2019-08-20 13:19:09 +01:00
parent aebffdd363
commit 68d5478d8d

View file

@ -550,8 +550,7 @@ static int pk_get_ecpubkey( unsigned char **p, const unsigned char *end,
static int uecc_public_key_read_binary( uint8_t *pt,
const unsigned char *buf, size_t ilen )
{
if( ilen < 1 )
if( ilen != 2 * NUM_ECC_BYTES + 1 )
return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
/* We are not handling the point at infinity. */
@ -559,9 +558,6 @@ static int uecc_public_key_read_binary( uint8_t *pt,
if( buf[0] != 0x04 )
return( MBEDTLS_ERR_PK_FEATURE_UNAVAILABLE );
if( ilen != 2 * NUM_ECC_BYTES + 1 )
return( MBEDTLS_ERR_PK_INVALID_PUBKEY );
memcpy( pt, buf + 1, ilen - 1);
return( 0 );