From e46f66a5fa898abea9873a75d5ab802ee90c18ad Mon Sep 17 00:00:00 2001 From: Dragios Date: Sun, 22 Oct 2017 13:18:13 +0800 Subject: [PATCH] Remove Crypto++ weak algorithm warning --- src/core/hle/service/nwm/uds_beacon.cpp | 9 ++++++--- src/core/hle/service/nwm/uds_data.cpp | 16 ++++++++++------ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/core/hle/service/nwm/uds_beacon.cpp b/src/core/hle/service/nwm/uds_beacon.cpp index 73a80d940..466c02ae8 100644 --- a/src/core/hle/service/nwm/uds_beacon.cpp +++ b/src/core/hle/service/nwm/uds_beacon.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 + #include #include #include @@ -204,9 +206,10 @@ std::vector GeneratedEncryptedData(const NetworkInfo& network_info, const No } // Calculate the MD5 hash of the data in the buffer, not including the hash field. - std::array hash; - CryptoPP::MD5().CalculateDigest(hash.data(), buffer.data() + offsetof(BeaconData, bitmask), - buffer.size() - sizeof(data.md5_hash)); + std::array hash; + CryptoPP::Weak::MD5().CalculateDigest(hash.data(), + buffer.data() + offsetof(BeaconData, bitmask), + buffer.size() - sizeof(data.md5_hash)); // Copy the hash into the buffer. std::memcpy(buffer.data(), hash.data(), hash.size()); diff --git a/src/core/hle/service/nwm/uds_data.cpp b/src/core/hle/service/nwm/uds_data.cpp index 4b389710f..cbeb75dfa 100644 --- a/src/core/hle/service/nwm/uds_data.cpp +++ b/src/core/hle/service/nwm/uds_data.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2 or any later version // Refer to the license.txt file included. +#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1 + #include #include #include @@ -62,7 +64,8 @@ static std::vector GenerateSecureDataHeader(u16 data_size, u8 channel, u16 d * the CCMP crypto key for data frames. * @returns The CTR used for data frames crypto key generation. */ -static std::array GetDataCryptoCTR(const NetworkInfo& network_info) { +static std::array GetDataCryptoCTR( + const NetworkInfo& network_info) { DataFrameCryptoCTR data{}; data.host_mac = network_info.host_mac_address; @@ -70,8 +73,8 @@ static std::array GetDataCryptoCTR(const NetworkI data.id = network_info.id; data.network_id = network_info.network_id; - std::array hash; - CryptoPP::MD5().CalculateDigest(hash.data(), reinterpret_cast(&data), sizeof(data)); + std::array hash; + CryptoPP::Weak::MD5().CalculateDigest(hash.data(), reinterpret_cast(&data), sizeof(data)); return hash; } @@ -83,15 +86,16 @@ static std::array GetDataCryptoCTR(const NetworkI static std::array GenerateDataCCMPKey( const std::vector& passphrase, const NetworkInfo& network_info) { // Calculate the MD5 hash of the input passphrase. - std::array passphrase_hash; - CryptoPP::MD5().CalculateDigest(passphrase_hash.data(), passphrase.data(), passphrase.size()); + std::array passphrase_hash; + CryptoPP::Weak::MD5().CalculateDigest(passphrase_hash.data(), passphrase.data(), + passphrase.size()); std::array ccmp_key; // The CCMP key is the result of encrypting the MD5 hash of the passphrase with AES-CTR using // keyslot 0x2D. using CryptoPP::AES; - std::array counter = GetDataCryptoCTR(network_info); + std::array counter = GetDataCryptoCTR(network_info); std::array key = HW::AES::GetNormalKey(HW::AES::KeySlotID::UDSDataKey); CryptoPP::CTR_Mode::Encryption aes; aes.SetKeyWithIV(key.data(), AES::BLOCKSIZE, counter.data());