]> wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Get rid of EVP_MD_CTRL_MAC_LEN
authorDmitry Belyavskiy <beldmit@gmail.com>
Wed, 4 Sep 2019 19:45:37 +0000 (22:45 +0300)
committerDmitry Belyavskiy <beldmit@gmail.com>
Wed, 4 Sep 2019 19:45:37 +0000 (22:45 +0300)
gost_crypt.c
gost_keyexpimp.c
gost_lcl.h
gost_omac.c
gost_omac_acpkm.c
gost_pmeth.c

index 930d40adc76941aedef3479efb841c44d7e55801..16fb6610682a31cab052c615e7c433753aa1629c 100644 (file)
@@ -302,7 +302,7 @@ EVP_MD *imit_gost_cpa(void)
             || !EVP_MD_meth_set_input_blocksize(md, 8)
             || !EVP_MD_meth_set_app_datasize(md,
                                              sizeof(struct ossl_gost_imit_ctx))
-            || !EVP_MD_meth_set_flags(md, 0)
+            || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF)
             || !EVP_MD_meth_set_init(md, gost_imit_init_cpa)
             || !EVP_MD_meth_set_update(md, gost_imit_update)
             || !EVP_MD_meth_set_final(md, gost_imit_final)
@@ -333,7 +333,7 @@ EVP_MD *imit_gost_cp_12(void)
             || !EVP_MD_meth_set_input_blocksize(md, 8)
             || !EVP_MD_meth_set_app_datasize(md,
                                              sizeof(struct ossl_gost_imit_ctx))
-            || !EVP_MD_meth_set_flags(md, 0)
+            || !EVP_MD_meth_set_flags(md, EVP_MD_FLAG_XOF)
             || !EVP_MD_meth_set_init(md, gost_imit_init_cp_12)
             || !EVP_MD_meth_set_update(md, gost_imit_update)
             || !EVP_MD_meth_set_final(md, gost_imit_final)
@@ -1180,7 +1180,7 @@ int gost_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr)
             GOSTerr(GOST_F_GOST_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE);
             return 0;
         }
-    case EVP_MD_CTRL_MAC_LEN:
+    case EVP_MD_CTRL_XOF_LEN:
         {
             struct ossl_gost_imit_ctx *c = EVP_MD_CTX_md_data(ctx);
             if (arg < 1 || arg > 8) {
index 6df1b2a6168246b74f0fd26a1bb1522bd8a50d76..e8ee1ebedce5e9a129f7d1874a78109a6fc73234 100644 (file)
@@ -46,11 +46,11 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len,
 
     if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0
         || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0
-        || omac_imit_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0
+        || omac_imit_ctrl(mac, EVP_MD_CTRL_XOF_LEN, mac_len, NULL) <= 0
         || EVP_DigestUpdate(mac, iv, ivlen) <= 0
         || EVP_DigestUpdate(mac, shared_key, shared_len) <= 0
         /* As we set MAC length directly, we should not allow overwriting it */
-        || EVP_DigestFinal_ex(mac, mac_buf, NULL) <= 0) {
+        || EVP_DigestFinalXOF(mac, mac_buf, mac_len) <= 0) {
         GOSTerr(GOST_F_GOST_KEXP15, ERR_R_INTERNAL_ERROR);
         goto err;
     }
@@ -139,11 +139,11 @@ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen,
 
     if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0
         || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0
-        || omac_imit_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0
+        || omac_imit_ctrl(mac, EVP_MD_CTRL_XOF_LEN, mac_len, NULL) <= 0
         || EVP_DigestUpdate(mac, iv, ivlen) <= 0
         || EVP_DigestUpdate(mac, out, shared_len) <= 0
         /* As we set MAC length directly, we should not allow overwriting it */
-        || EVP_DigestFinal_ex(mac, mac_buf, NULL) <= 0) {
+        || EVP_DigestFinalXOF(mac, mac_buf, mac_len) <= 0) {
         GOSTerr(GOST_F_GOST_KIMP15, ERR_R_INTERNAL_ERROR);
         goto err;
     }
index 6623d6d3a6bb46fae1447678bc9e0270a188d8af..15ff31ead28813bde1ee7ceb4df9ecc0ca2a5aae 100644 (file)
@@ -245,7 +245,6 @@ void inc_counter(unsigned char *buffer, size_t buf_len);
 
 # define EVP_MD_CTRL_KEY_LEN (EVP_MD_CTRL_ALG_CTRL+3)
 # define EVP_MD_CTRL_SET_KEY (EVP_MD_CTRL_ALG_CTRL+4)
-# define EVP_MD_CTRL_MAC_LEN (EVP_MD_CTRL_ALG_CTRL+5)
 /* EVP_PKEY_METHOD key encryption callbacks */
 /* From gost_ec_keyx.c */
 int pkey_gost_encrypt(EVP_PKEY_CTX *ctx, unsigned char *out,
index 075c26fd9b286e1896daa780a795ef5c30a34005..97fb5c0b9d6308365555a7c766fd9e1102901da9 100644 (file)
@@ -202,7 +202,6 @@ int omac_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr)
             GOSTerr(GOST_F_OMAC_IMIT_CTRL, GOST_R_INVALID_MAC_KEY_SIZE);
             return 0;
         }
-    case EVP_MD_CTRL_MAC_LEN:
     case EVP_MD_CTRL_XOF_LEN:   /* Supported in OpenSSL */
         {
             OMAC_CTX *c = EVP_MD_CTX_md_data(ctx);
index 7447a67b10d97c3a8956624dba02cf386c0b27cb..3820c904e47fca6c660840ed16a8f384fcac6854 100644 (file)
@@ -465,7 +465,6 @@ int omac_acpkm_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr)
             }
             return 1;
         }
-    case EVP_MD_CTRL_MAC_LEN:
     case EVP_MD_CTRL_XOF_LEN:   /* Supported in OpenSSL */
         {
             OMAC_ACPKM_CTX *c = EVP_MD_CTX_md_data(ctx);
index 2b94e36298d3c3d71495fce6e422c485db7343da..41e53b67e2da2794977868dda2b20b7f81cc83fd 100644 (file)
@@ -967,7 +967,7 @@ static int pkey_gost_mac_signctx(EVP_PKEY_CTX *ctx, unsigned char *sig,
     }
 
     EVP_MD_meth_get_ctrl(EVP_MD_CTX_md(mctx))
-        (mctx, EVP_MD_CTRL_MAC_LEN, data->mac_size, NULL);
+        (mctx, EVP_MD_CTRL_XOF_LEN, data->mac_size, NULL);
     ret = EVP_DigestFinal_ex(mctx, sig, &tmpsiglen);
     *siglen = data->mac_size;
     return ret;