From: Dmitry Belyavskiy Date: Mon, 4 Jan 2016 09:28:21 +0000 (+0300) Subject: Correct initializing the context X-Git-Tag: v1.1.0.2~22^2~11 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=6bea7d0e052ac677a6744d6f755006bb71f889a3;p=openssl-gost%2Fengine.git Correct initializing the context --- diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c index af773e2..457b308 100644 --- a/gost_ec_keyx.c +++ b/gost_ec_keyx.c @@ -77,20 +77,26 @@ static int VKO_compute_key(unsigned char *shared_key, size_t shared_key_size, for (i = 0; i < buf_len; i++) { hashbuf[buf_len - 1 - i] = databuf[i]; } + mdctx = EVP_MD_CTX_new(); + if (!mdctx) { + GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_MALLOC_FAILURE); + goto err; + } EVP_MD_CTX_init(mdctx); EVP_DigestInit_ex(mdctx, md, NULL); EVP_DigestUpdate(mdctx, hashbuf, buf_len); EVP_DigestFinal_ex(mdctx, shared_key, NULL); - EVP_MD_CTX_free(mdctx); err: BN_free(UKM); BN_CTX_end(ctx); BN_CTX_free(ctx); + EC_POINT_free(pnt); - if (databuf) - OPENSSL_free(databuf); - if (hashbuf) - OPENSSL_free(hashbuf); + + EVP_MD_CTX_free(mdctx); + + OPENSSL_free(databuf); + OPENSSL_free(hashbuf); return 32; }