X-Git-Url: http://wagner.pp.ru/gitweb/?a=blobdiff_plain;f=gost_keyexpimp.c;h=5564387a973bc1779e816122e43514f7417467e1;hb=refs%2Fheads%2Fgost_provider;hp=caa6171d1fbb36dccf2bfb3efca90535e97e7bad;hpb=d02ac6b47941f4b49fa70edad3419fa5a81eb284;p=openssl-gost%2Fengine.git diff --git a/gost_keyexpimp.c b/gost_keyexpimp.c index caa6171..5564387 100644 --- a/gost_keyexpimp.c +++ b/gost_keyexpimp.c @@ -1,4 +1,8 @@ +#ifdef _WIN32 +#include +#else #include +#endif #include #include #include @@ -6,6 +10,7 @@ #include "gost_lcl.h" #include "e_gost_err.h" +int omac_imit_ctrl(EVP_MD_CTX *ctx, int type, int arg, void *ptr); /* * Function expects that out is a preallocated buffer of length * defined as sum of shared_len and mac length defined by mac_nid @@ -44,12 +49,12 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len, } if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0 - || EVP_MD_CTX_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0 - || EVP_MD_CTX_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0 + || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 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; } @@ -84,7 +89,7 @@ int gost_kexp15(const unsigned char *shared_key, const int shared_len, /* * Function expects that shared_key is a preallocated buffer - * with length defined as expkeylen - mac_len defined by mac_nid + * with length defined as expkeylen + mac_len defined by mac_nid * */ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen, int cipher_nid, const unsigned char *cipher_key, @@ -137,12 +142,12 @@ int gost_kimp15(const unsigned char *expkey, const size_t expkeylen, } if (EVP_DigestInit_ex(mac, EVP_get_digestbynid(mac_nid), NULL) <= 0 - || EVP_MD_CTX_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 0 - || EVP_MD_CTX_ctrl(mac, EVP_MD_CTRL_MAC_LEN, mac_len, NULL) <= 0 + || omac_imit_ctrl(mac, EVP_MD_CTRL_SET_KEY, 32, mac_key) <= 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; }