TinyCrypt PK wrap: Implement alloc/free PK wrappers

This commit is contained in:
Hanno Becker 2019-08-20 13:18:56 +01:00
parent 11cb2637e7
commit 4102972d31

View file

@ -48,7 +48,8 @@
#include "mbedtls/ecdsa.h" #include "mbedtls/ecdsa.h"
#endif #endif
#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) #if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) || \
defined(MBEDTLS_USE_TINYCRYPT)
#include "mbedtls/platform_util.h" #include "mbedtls/platform_util.h"
#endif #endif
@ -684,20 +685,16 @@ static int uecc_eckey_sign_wrap( void *ctx, mbedtls_md_type_t md_alg,
static void *uecc_eckey_alloc_wrap( void ) static void *uecc_eckey_alloc_wrap( void )
{ {
/*void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); return( mbedtls_calloc( 1, sizeof( mbedtls_uecc_keypair ) ) );
if( ctx != NULL )
mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx );
return( ctx );*/
return NULL;
} }
static void uecc_eckey_free_wrap( void *ctx ) static void uecc_eckey_free_wrap( void *ctx )
{ {
(void) ctx; if( ctx == NULL )
/*mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx ); return;
mbedtls_free( ctx );*/
mbedtls_platform_zeroize( ctx, sizeof( mbedtls_uecc_keypair ) );
mbedtls_free( ctx );
} }
const mbedtls_pk_info_t mbedtls_uecc_eckey_info = { const mbedtls_pk_info_t mbedtls_uecc_eckey_info = {