X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_ec_keyx.c;h=2b4a96e54664aac98e1f31fc65eac6e6abe4022d;hb=c2696f14ed9d5ac2cd098461cf371ba0f037d0f7;hp=deca4f599896bf79c61cc7fb588fe99a150ba36a;hpb=6e5d6808c9ff3f7802bcb6bf3709c5475b1a87b7;p=openssl-gost%2Fengine.git diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c index deca4f5..2b4a96e 100644 --- a/gost_ec_keyx.c +++ b/gost_ec_keyx.c @@ -86,10 +86,15 @@ int VKO_compute_key(unsigned char *shared_key, 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, databuf, buf_len); - EVP_DigestFinal_ex(mdctx, shared_key, NULL); + + if (EVP_MD_CTX_init(mdctx) == 0 + || EVP_DigestInit_ex(mdctx, md, NULL) == 0 + || EVP_DigestUpdate(mdctx, databuf, buf_len) == 0 + || EVP_DigestFinal_ex(mdctx, shared_key, NULL) == 0) { + GOSTerr(GOST_F_VKO_COMPUTE_KEY, ERR_R_EVP_LIB); + goto err; + } + ret = (EVP_MD_size(md) > 0) ? EVP_MD_size(md) : 0; err: @@ -615,6 +620,19 @@ static int pkey_gost2018_decrypt(EVP_PKEY_CTX *pctx, unsigned char *key, o q * Q_eph is not equal to zero point. */ + if (data->shared_ukm == NULL && pst->ukm != NULL) { + if (EVP_PKEY_CTX_ctrl(pctx, -1, -1, EVP_PKEY_CTRL_SET_IV, + ASN1_STRING_length(pst->ukm), (void *)ASN1_STRING_get0_data(pst->ukm)) < 0) { + GOSTerr(GOST_F_PKEY_GOST2018_DECRYPT, GOST_R_UKM_NOT_SET); + goto err; + } + } + + if (data->shared_ukm == NULL) { + GOSTerr(GOST_F_PKEY_GOST2018_DECRYPT, GOST_R_UKM_NOT_SET); + goto err; + } + if (gost_keg(data->shared_ukm, pkey_nid, EC_KEY_get0_public_key(EVP_PKEY_get0(eph_key)), EVP_PKEY_get0(priv), expkeys) <= 0) {