]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
UKM must be set
authorDmitry Belyavskiy <beldmit@gmail.com>
Sun, 3 May 2020 13:45:59 +0000 (16:45 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Mon, 4 May 2020 12:50:12 +0000 (15:50 +0300)
gost_ec_keyx.c

index deca4f599896bf79c61cc7fb588fe99a150ba36a..4a0eb826e5cca3565e0dc9e7b667e3f92711289d 100644 (file)
@@ -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) {