From 96fb685e3181e4a56553ec352fced3a2c822d7b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Tue, 23 Jun 2015 11:39:01 +0200 Subject: [PATCH] Some more init calls --- library/cipher_wrap.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/library/cipher_wrap.c b/library/cipher_wrap.c index fafcfa0f7b..c795234bcc 100644 --- a/library/cipher_wrap.c +++ b/library/cipher_wrap.c @@ -78,7 +78,12 @@ /* shared by all GCM ciphers */ static void *gcm_ctx_alloc( void ) { - return mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) ); + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_gcm_context ) ); + + if( ctx != NULL ) + mbedtls_gcm_init( (mbedtls_gcm_context *) ctx ); + + return( ctx ); } static void gcm_ctx_free( void *ctx ) @@ -92,7 +97,12 @@ static void gcm_ctx_free( void *ctx ) /* shared by all CCM ciphers */ static void *ccm_ctx_alloc( void ) { - return mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) ); + void *ctx = mbedtls_calloc( 1, sizeof( mbedtls_ccm_context ) ); + + if( ctx != NULL ) + mbedtls_ccm_init( (mbedtls_ccm_context *) ctx ); + + return( ctx ); } static void ccm_ctx_free( void *ctx )