]> www.wagner.pp.ru Git - openssl-gost/engine.git/blobdiff - gost_keyexpimp.c
cppcheck: Variable is reassigned a value before the old one has been used.
[openssl-gost/engine.git] / gost_keyexpimp.c
index 6df1b2a6168246b74f0fd26a1bb1522bd8a50d76..e0961ff5f0bba2cc421f4716dc11af3f8b0b2486 100644 (file)
@@ -1,4 +1,8 @@
+#ifdef _WIN32
+#include <winsock.h>
+#else
 #include <arpa/inet.h>
+#endif
 #include <string.h>
 #include <openssl/evp.h>
 #include <openssl/hmac.h>
@@ -46,11 +50,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 +143,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;
     }
@@ -172,7 +176,7 @@ int gost_kdftree2012_256(unsigned char *keyout, size_t keyout_len,
     int iters, i = 0;
     unsigned char zero = 0;
     unsigned char *ptr = keyout;
-    HMAC_CTX *ctx = NULL;
+    HMAC_CTX *ctx;
     unsigned char *len_ptr = NULL;
     uint32_t len_repr = htonl(keyout_len * 8);
     size_t len_repr_len = 4;