aboutsummaryrefslogtreecommitdiff
path: root/gost_ec_keyx.c
diff options
context:
space:
mode:
authorDmitry Belyavskiy <beldmit@gmail.com>2020-05-03 16:45:59 +0300
committerDmitry Belyavskiy <beldmit@gmail.com>2020-05-04 15:50:12 +0300
commitff31ce4db29fb59fa607e12d3f45b89191473819 (patch)
treee546789903d4bd4437c5a7d3104bae77497510dc /gost_ec_keyx.c
parent3b31dea89630ecd3f741171ed3e1d4259adabf0e (diff)
downloadgost-engine-ff31ce4db29fb59fa607e12d3f45b89191473819.zip
gost-engine-ff31ce4db29fb59fa607e12d3f45b89191473819.tar.gz
gost-engine-ff31ce4db29fb59fa607e12d3f45b89191473819.tar.bz2
UKM must be set
Diffstat (limited to 'gost_ec_keyx.c')
-rw-r--r--gost_ec_keyx.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/gost_ec_keyx.c b/gost_ec_keyx.c
index deca4f5..4a0eb82 100644
--- a/gost_ec_keyx.c
+++ b/gost_ec_keyx.c
@@ -615,6 +615,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) {