Fixup: TinyCrypt PK verify wrapper uecc_ecdsa_verify_wrap()

- TinyCrypt uses `0` for errors.
- The first argument to uECC_verify() should be the public key,
  but the previous code passed the beginning of the entire
  private-public key structure.
This commit is contained in:
Hanno Becker 2019-08-20 15:39:13 +01:00
parent 9c7a359cc4
commit 8ea35458e4

View File

@ -548,6 +548,7 @@ static int uecc_eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
uint8_t signature[2*NUM_ECC_BYTES]; uint8_t signature[2*NUM_ECC_BYTES];
unsigned char *p; unsigned char *p;
const struct uECC_Curve_t * uecc_curve = uECC_secp256r1(); const struct uECC_Curve_t * uecc_curve = uECC_secp256r1();
const mbedtls_uecc_keypair *keypair = (const mbedtls_uecc_keypair *) ctx;
((void) md_alg); ((void) md_alg);
p = (unsigned char*) sig; p = (unsigned char*) sig;
@ -556,12 +557,12 @@ static int uecc_eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg,
if( ret != 0 ) if( ret != 0 )
return( ret ); return( ret );
ret = uECC_verify( (uint8_t *) ctx, hash, ret = uECC_verify( keypair->public_key, hash,
(unsigned) hash_len, signature, uecc_curve ); (unsigned) hash_len, signature, uecc_curve );
if( ret != 0 ) if( ret == 0 )
return( MBEDTLS_ERR_PK_SIG_LEN_MISMATCH ); return( MBEDTLS_ERR_PK_HW_ACCEL_FAILED );
return( ret ); return( 0 );
} }
/* /*