diff --git a/src/Utils/Cryptography.cpp b/src/Utils/Cryptography.cpp index dd4047c7..66b791a2 100644 --- a/src/Utils/Cryptography.cpp +++ b/src/Utils/Cryptography.cpp @@ -25,7 +25,7 @@ namespace Utils pos += sprintf_s(&buffer[pos], sizeof(buffer) - pos, "%X", ~timeGetTime() ^ GenerateInt()); pos += sprintf_s(&buffer[pos], sizeof(buffer) - pos, "%X", GenerateInt()); - return std::string(buffer, static_cast(pos)); + return std::string{ buffer, static_cast(pos) }; } std::uint32_t Rand::GenerateInt() @@ -62,13 +62,13 @@ namespace Utils if (!key.isValid()) return {}; std::uint8_t buffer[512]; - DWORD length = sizeof(buffer); + unsigned long length = sizeof(buffer); ltc_mp = ltm_desc; register_prng(&sprng_desc); ecc_sign_hash(reinterpret_cast(message.data()), message.size(), buffer, &length, nullptr, find_prng("sprng"), key.getKeyPtr()); - return {reinterpret_cast(buffer), length}; + return std::string{ reinterpret_cast(buffer), length }; } bool ECC::VerifyMessage(Key key, const std::string& message, const std::string& signature) @@ -78,7 +78,9 @@ namespace Utils ltc_mp = ltm_desc; int result = 0; - return (ecc_verify_hash(reinterpret_cast(signature.data()), signature.size(), reinterpret_cast(message.data()), message.size(), &result, key.getKeyPtr()) == CRYPT_OK && result != 0); + return (ecc_verify_hash(reinterpret_cast(signature.data()), signature.size(), + reinterpret_cast(message.data()), message.size(), + &result, key.getKeyPtr()) == CRYPT_OK && result != 0); } #pragma endregion @@ -104,7 +106,7 @@ namespace Utils if (!key.isValid()) return {}; std::uint8_t buffer[512]; - DWORD length = sizeof(buffer); + unsigned long length = sizeof(buffer); register_prng(&sprng_desc); register_hash(&sha1_desc); @@ -113,7 +115,7 @@ namespace Utils rsa_sign_hash(reinterpret_cast(message.data()), message.size(), buffer, &length, NULL, find_prng("sprng"), find_hash("sha1"), 0, key.getKeyPtr()); - return {reinterpret_cast(buffer), length}; + return std::string{ reinterpret_cast(buffer), length }; } bool RSA::VerifyMessage(Key key, const std::string& message, const std::string& signature) @@ -185,7 +187,7 @@ namespace Utils tiger_process(&state, data, length); tiger_done(&state, buffer); - std::string hash(reinterpret_cast(buffer), sizeof(buffer)); + std::string hash{ reinterpret_cast(buffer), sizeof(buffer) }; if (!hex) return hash; return String::DumpHex(hash, {}); @@ -209,7 +211,7 @@ namespace Utils sha1_process(&state, data, length); sha1_done(&state, buffer); - std::string hash(reinterpret_cast(buffer), sizeof(buffer)); + std::string hash{ reinterpret_cast(buffer), sizeof(buffer) }; if (!hex) return hash; return String::DumpHex(hash, {}); @@ -233,7 +235,7 @@ namespace Utils sha256_process(&state, data, length); sha256_done(&state, buffer); - std::string hash(reinterpret_cast(buffer), sizeof(buffer)); + std::string hash{ reinterpret_cast(buffer), sizeof(buffer) }; if (!hex) return hash; return String::DumpHex(hash, {}); @@ -257,7 +259,7 @@ namespace Utils sha512_process(&state, data, length); sha512_done(&state, buffer); - std::string hash(reinterpret_cast(buffer), sizeof(buffer)); + std::string hash{ reinterpret_cast(buffer), sizeof(buffer) }; if (!hex) return hash; return String::DumpHex(hash, {});