From 68d5478d8d05fa02dbbac1e14a0c7afc9d5adcf8 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 20 Aug 2019 13:19:09 +0100 Subject: [PATCH] TinyCrypt PK parse: Simplify TinyCrypt public key parsing --- library/pkparse.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/library/pkparse.c b/library/pkparse.c index c8171f1de..7c8cd804b 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -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 );