aboutsummaryrefslogtreecommitdiff
path: root/gost_ec_keyx.c
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2016-01-04 12:28:21 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2016-01-04 12:28:21 +0300
commit6bea7d0e052ac677a6744d6f755006bb71f889a3 (patch)
tree264211773fc1bb4c075bfb98245626d2efea7259 /gost_ec_keyx.c
parent51a91e8230a0d9794031dd9ee539a3bb8ecf9587 (diff)
downloadgost-engine-6bea7d0e052ac677a6744d6f755006bb71f889a3.zip
gost-engine-6bea7d0e052ac677a6744d6f755006bb71f889a3.tar.gz
gost-engine-6bea7d0e052ac677a6744d6f755006bb71f889a3.tar.bz2
Correct initializing the context
Diffstat (limited to 'gost_ec_keyx.c')
-rw-r--r--gost_ec_keyx.c16
1 files changed, 11 insertions, 5 deletions
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;
}