From 4102972d313e1d617a06f5f526b3f1e2018a7ee7 Mon Sep 17 00:00:00 2001 From: Hanno Becker Date: Tue, 20 Aug 2019 13:18:56 +0100 Subject: [PATCH] TinyCrypt PK wrap: Implement alloc/free PK wrappers --- library/pk_wrap.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/library/pk_wrap.c b/library/pk_wrap.c index 48eb602fd..838360405 100644 --- a/library/pk_wrap.c +++ b/library/pk_wrap.c @@ -48,7 +48,8 @@ #include "mbedtls/ecdsa.h" #endif -#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) +#if defined(MBEDTLS_PK_RSA_ALT_SUPPORT) || \ + defined(MBEDTLS_USE_TINYCRYPT) #include "mbedtls/platform_util.h" #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 ) { - /*void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ecdsa_context ) ); - - if( ctx != NULL ) - mbedtls_ecdsa_init( (mbedtls_ecdsa_context *) ctx ); - - return( ctx );*/ - return NULL; + return( mbedtls_calloc( 1, sizeof( mbedtls_uecc_keypair ) ) ); } static void uecc_eckey_free_wrap( void *ctx ) { - (void) ctx; - /*mbedtls_ecdsa_free( (mbedtls_ecdsa_context *) ctx ); - mbedtls_free( ctx );*/ + if( ctx == NULL ) + return; + + mbedtls_platform_zeroize( ctx, sizeof( mbedtls_uecc_keypair ) ); + mbedtls_free( ctx ); } const mbedtls_pk_info_t mbedtls_uecc_eckey_info = {