Skasowanie części makr
This commit is contained in:
parent
f9ea960cf0
commit
bfc6c1811d
6 changed files with 13 additions and 45 deletions
|
|
@ -67,9 +67,6 @@ void EncryptionManager::generateKeys()
|
|||
|
||||
void EncryptionManager::saveKey(const std::string& path, bool hpp)
|
||||
{
|
||||
const std::string sig = SIGNATURE_KEY_FILE;
|
||||
const int8_t ver = VERSION;
|
||||
|
||||
// Wygeneruj time stamp
|
||||
std::time_t now = std::time(nullptr);
|
||||
const int time = static_cast<int>(now);
|
||||
|
|
@ -78,14 +75,13 @@ void EncryptionManager::saveKey(const std::string& path, bool hpp)
|
|||
std::vector<char> keyVec(reinterpret_cast<const char*>(key.data()),
|
||||
reinterpret_cast<const char*>(key.data()) + key.size());
|
||||
|
||||
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), VERSION);
|
||||
const uint64_t crcKey = XXH64(keyVec.data(), keyVec.size(), 0);
|
||||
|
||||
// Zapisz ten œmietnik do pliku KEY
|
||||
std::ofstream file(path + ".key", std::ios::binary);
|
||||
if (!file) { std::cout << "Failed to save encryption key to file" << std::endl; }
|
||||
|
||||
file.write(sig.data(), sig.length());
|
||||
file.write(reinterpret_cast<const char*>(&ver), sizeof(ver));
|
||||
file.write(fl::sigkey.data(), fl::sigkey.length());
|
||||
file.write(reinterpret_cast<const char*>(&time), sizeof(time));
|
||||
file.write(reinterpret_cast<const char*>(keyVec.data()), keyVec.size());
|
||||
file.write(reinterpret_cast<const char*>(&crcKey), sizeof(crcKey));
|
||||
|
|
@ -137,18 +133,15 @@ std::string EncryptionManager::toHex(const unsigned char* data, size_t len)
|
|||
void EncryptionManager::loadKey(const std::string& path)
|
||||
{
|
||||
std::ifstream file(path + ".key", std::ios::binary);
|
||||
|
||||
const std::string signature = SIGNATURE_KEY_FILE;
|
||||
std::vector<char> sig(signature.size());
|
||||
std::vector<char> sig(fl::sigkey.size());
|
||||
int8_t ver;
|
||||
int time;
|
||||
|
||||
// Wczytaj
|
||||
file.read(sig.data(), sig.size());
|
||||
file.read(reinterpret_cast<char*>(&ver), sizeof(ver));
|
||||
|
||||
// SprawdŸ czy plik klucza jest poprawny
|
||||
if (std::string(sig.begin(), sig.end()) != signature || ver != VERSION)
|
||||
if (std::string(sig.begin(), sig.end()) != fl::sigkey)
|
||||
{
|
||||
throw std::runtime_error("Invalid key file!");
|
||||
}
|
||||
|
|
@ -161,7 +154,7 @@ void EncryptionManager::loadKey(const std::string& path)
|
|||
file.read(reinterpret_cast<char*>(&crcKey), sizeof(crcKey));
|
||||
|
||||
// SprawdŸ integralnoœæ klucza
|
||||
if (XXH64(keyVec.data(), keyVec.size(), VERSION) != crcKey)
|
||||
if (XXH64(keyVec.data(), keyVec.size(), 0) != crcKey)
|
||||
{
|
||||
throw std::runtime_error("Key integrity error!");
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue