mirror of
https://github.com/Lime3DS/Lime3DS
synced 2024-12-27 01:22:37 -06:00
Merge pull request #3031 from Dragios/cryptopp-weak
externals: Remove Crypto++ weak algorithm warning
This commit is contained in:
commit
6f5f09b6c2
2 changed files with 16 additions and 9 deletions
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
|
||||||
|
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cryptopp/aes.h>
|
#include <cryptopp/aes.h>
|
||||||
#include <cryptopp/md5.h>
|
#include <cryptopp/md5.h>
|
||||||
|
@ -204,8 +206,9 @@ std::vector<u8> GeneratedEncryptedData(const NetworkInfo& network_info, const No
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate the MD5 hash of the data in the buffer, not including the hash field.
|
// Calculate the MD5 hash of the data in the buffer, not including the hash field.
|
||||||
std::array<u8, CryptoPP::MD5::DIGESTSIZE> hash;
|
std::array<u8, CryptoPP::Weak::MD5::DIGESTSIZE> hash;
|
||||||
CryptoPP::MD5().CalculateDigest(hash.data(), buffer.data() + offsetof(BeaconData, bitmask),
|
CryptoPP::Weak::MD5().CalculateDigest(hash.data(),
|
||||||
|
buffer.data() + offsetof(BeaconData, bitmask),
|
||||||
buffer.size() - sizeof(data.md5_hash));
|
buffer.size() - sizeof(data.md5_hash));
|
||||||
|
|
||||||
// Copy the hash into the buffer.
|
// Copy the hash into the buffer.
|
||||||
|
|
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#define CRYPTOPP_ENABLE_NAMESPACE_WEAK 1
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <cryptopp/aes.h>
|
#include <cryptopp/aes.h>
|
||||||
|
@ -62,7 +64,8 @@ static std::vector<u8> GenerateSecureDataHeader(u16 data_size, u8 channel, u16 d
|
||||||
* the CCMP crypto key for data frames.
|
* the CCMP crypto key for data frames.
|
||||||
* @returns The CTR used for data frames crypto key generation.
|
* @returns The CTR used for data frames crypto key generation.
|
||||||
*/
|
*/
|
||||||
static std::array<u8, CryptoPP::MD5::DIGESTSIZE> GetDataCryptoCTR(const NetworkInfo& network_info) {
|
static std::array<u8, CryptoPP::Weak::MD5::DIGESTSIZE> GetDataCryptoCTR(
|
||||||
|
const NetworkInfo& network_info) {
|
||||||
DataFrameCryptoCTR data{};
|
DataFrameCryptoCTR data{};
|
||||||
|
|
||||||
data.host_mac = network_info.host_mac_address;
|
data.host_mac = network_info.host_mac_address;
|
||||||
|
@ -70,8 +73,8 @@ static std::array<u8, CryptoPP::MD5::DIGESTSIZE> GetDataCryptoCTR(const NetworkI
|
||||||
data.id = network_info.id;
|
data.id = network_info.id;
|
||||||
data.network_id = network_info.network_id;
|
data.network_id = network_info.network_id;
|
||||||
|
|
||||||
std::array<u8, CryptoPP::MD5::DIGESTSIZE> hash;
|
std::array<u8, CryptoPP::Weak::MD5::DIGESTSIZE> hash;
|
||||||
CryptoPP::MD5().CalculateDigest(hash.data(), reinterpret_cast<u8*>(&data), sizeof(data));
|
CryptoPP::Weak::MD5().CalculateDigest(hash.data(), reinterpret_cast<u8*>(&data), sizeof(data));
|
||||||
|
|
||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
@ -83,15 +86,16 @@ static std::array<u8, CryptoPP::MD5::DIGESTSIZE> GetDataCryptoCTR(const NetworkI
|
||||||
static std::array<u8, CryptoPP::AES::BLOCKSIZE> GenerateDataCCMPKey(
|
static std::array<u8, CryptoPP::AES::BLOCKSIZE> GenerateDataCCMPKey(
|
||||||
const std::vector<u8>& passphrase, const NetworkInfo& network_info) {
|
const std::vector<u8>& passphrase, const NetworkInfo& network_info) {
|
||||||
// Calculate the MD5 hash of the input passphrase.
|
// Calculate the MD5 hash of the input passphrase.
|
||||||
std::array<u8, CryptoPP::MD5::DIGESTSIZE> passphrase_hash;
|
std::array<u8, CryptoPP::Weak::MD5::DIGESTSIZE> passphrase_hash;
|
||||||
CryptoPP::MD5().CalculateDigest(passphrase_hash.data(), passphrase.data(), passphrase.size());
|
CryptoPP::Weak::MD5().CalculateDigest(passphrase_hash.data(), passphrase.data(),
|
||||||
|
passphrase.size());
|
||||||
|
|
||||||
std::array<u8, CryptoPP::AES::BLOCKSIZE> ccmp_key;
|
std::array<u8, CryptoPP::AES::BLOCKSIZE> ccmp_key;
|
||||||
|
|
||||||
// The CCMP key is the result of encrypting the MD5 hash of the passphrase with AES-CTR using
|
// The CCMP key is the result of encrypting the MD5 hash of the passphrase with AES-CTR using
|
||||||
// keyslot 0x2D.
|
// keyslot 0x2D.
|
||||||
using CryptoPP::AES;
|
using CryptoPP::AES;
|
||||||
std::array<u8, CryptoPP::MD5::DIGESTSIZE> counter = GetDataCryptoCTR(network_info);
|
std::array<u8, CryptoPP::Weak::MD5::DIGESTSIZE> counter = GetDataCryptoCTR(network_info);
|
||||||
std::array<u8, AES::BLOCKSIZE> key = HW::AES::GetNormalKey(HW::AES::KeySlotID::UDSDataKey);
|
std::array<u8, AES::BLOCKSIZE> key = HW::AES::GetNormalKey(HW::AES::KeySlotID::UDSDataKey);
|
||||||
CryptoPP::CTR_Mode<AES>::Encryption aes;
|
CryptoPP::CTR_Mode<AES>::Encryption aes;
|
||||||
aes.SetKeyWithIV(key.data(), AES::BLOCKSIZE, counter.data());
|
aes.SetKeyWithIV(key.data(), AES::BLOCKSIZE, counter.data());
|
||||||
|
|
Loading…
Reference in a new issue