diff --git a/include/mbedtls/pk_internal.h b/include/mbedtls/pk_internal.h index 9ec2476f5..d3b501dd9 100644 --- a/include/mbedtls/pk_internal.h +++ b/include/mbedtls/pk_internal.h @@ -132,7 +132,7 @@ extern const mbedtls_pk_info_t mbedtls_ecdsa_info; #endif #if defined(MBEDTLS_USE_TINYCRYPT) -extern const mbedtls_pk_info_t mbedtls_uecc_ecdsa_info; +extern const mbedtls_pk_info_t mbedtls_uecc_eckey_info; #endif #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) diff --git a/library/pk.c b/library/pk.c index da34e56a3..161a135f1 100644 --- a/library/pk.c +++ b/library/pk.c @@ -115,19 +115,21 @@ const mbedtls_pk_info_t * mbedtls_pk_info_from_type( mbedtls_pk_type_t pk_type ) return( &mbedtls_rsa_info ); #endif #if defined(MBEDTLS_ECP_C) - case MBEDTLS_PK_ECKEY: - return( &mbedtls_eckey_info ); case MBEDTLS_PK_ECKEY_DH: return( &mbedtls_eckeydh_info ); #endif -#if defined(MBEDTLS_USE_TINYCRYPT) - case MBEDTLS_PK_ECDSA: - return( &mbedtls_uecc_ecdsa_info ); -#else #if defined(MBEDTLS_ECDSA_C) case MBEDTLS_PK_ECDSA: return( &mbedtls_ecdsa_info ); #endif +#if defined(MBEDTLS_USE_TINYCRYPT) + case MBEDTLS_PK_ECKEY: + return( &mbedtls_uecc_eckey_info ); +#else /* MBEDTLS_USE_TINYCRYPT */ +#if defined(MBEDTLS_ECP_C) + case MBEDTLS_PK_ECKEY: + return( &mbedtls_eckey_info ); +#endif #endif /* MBEDTLS_USE_TINYCRYPT */ /* MBEDTLS_PK_RSA_ALT omitted on purpose */ default: diff --git a/library/pk_wrap.c b/library/pk_wrap.c index c6f6302b3..cf606914e 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -528,18 +528,19 @@ static int extract_ecdsa_sig( unsigned char **p, const unsigned char *end, return( 0 ); } -static size_t uecc_ecdsa_get_bitlen( const void *ctx ) +static size_t uecc_eckey_get_bitlen( const void *ctx ) { (void) ctx; return( (size_t) 2 * NUM_ECC_BYTES ); } -static int uecc_ecdsa_can_do( mbedtls_pk_type_t type ) +static int uecc_eckey_can_do( mbedtls_pk_type_t type ) { - return( type == MBEDTLS_PK_ECDSA ); + return( type == MBEDTLS_PK_ECDSA || + type == MBEDTLS_PK_ECKEY ); } -static int uecc_ecdsa_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, +static int uecc_eckey_verify_wrap( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, const unsigned char *sig, size_t sig_len ) { @@ -642,7 +643,7 @@ static int pk_ecdsa_sig_asn1_from_psa( unsigned char *sig, size_t *sig_len, return( 0 ); } -static int uecc_ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, +static int uecc_eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, const unsigned char *hash, size_t hash_len, unsigned char *sig, size_t *sig_len, int (*f_rng)(void *, unsigned char *, size_t), void *p_rng ) @@ -660,7 +661,7 @@ static int uecc_ecdsa_sign_wrap( void *ctx, mbedtls_md_type_t md_alg, return( pk_ecdsa_sig_asn1_from_psa( sig, sig_len, 2*NUM_ECC_BYTES ) ); } -static void *uecc_ecdsa_alloc_wrap( void ) +static void *uecc_eckey_alloc_wrap( void ) { /*void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); @@ -671,25 +672,25 @@ static void *uecc_ecdsa_alloc_wrap( void ) return NULL; } -static void uecc_ecdsa_free_wrap( void *ctx ) +static void uecc_eckey_free_wrap( void *ctx ) { (void) ctx; /*mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx ); mbedtls_free( ctx );*/ } -const mbedtls_pk_info_t mbedtls_uecc_ecdsa_info = { - MBEDTLS_PK_ECDSA, - "ECDSA", - uecc_ecdsa_get_bitlen, - uecc_ecdsa_can_do, - uecc_ecdsa_verify_wrap, - uecc_ecdsa_sign_wrap, +const mbedtls_pk_info_t mbedtls_uecc_eckey_info = { + MBEDTLS_PK_ECKEY, + "EC", + uecc_eckey_get_bitlen, + uecc_eckey_can_do, + uecc_eckey_verify_wrap, + uecc_eckey_sign_wrap, NULL, NULL, NULL, - uecc_ecdsa_alloc_wrap, - uecc_ecdsa_free_wrap, + uecc_eckey_alloc_wrap, + uecc_eckey_free_wrap, NULL, }; #else diff --git a/library/pkparse.c b/library/pkparse.c index bc016be43..7573bdc86 100644 --- a/library/pkparse.c +++ b/library/pkparse.c @@ -1545,7 +1545,7 @@ int mbedtls_pk_parse_key( mbedtls_pk_context *pk, #endif /* MBEDTLS_RSA_C */ #if defined(MBEDTLS_USE_TINYCRYPT) - pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECDSA ); + pk_info = mbedtls_pk_info_from_type( MBEDTLS_PK_ECKEY ); if( mbedtls_pk_setup( pk, pk_info ) == 0 && pk_parse_key_sec1_der( mbedtls_uecc_pk( *pk), key, keylen) == 0)