Osadziłem w extraktorze wykrywanie metody pakowania na podstawie wartości flagi. Klucz jest importowany w momęcie jego wykrycia, Podmieniłem poprzednią metodę pliku konfiguracyjnego z txt na json (nie przetestowano). Brak flagi do generowania pliku HPP z tablicami kluczy.

This commit is contained in:
yanczi 2025-11-08 03:00:57 +01:00
parent 8402ce1b65
commit 293c1412ad
10 changed files with 18 additions and 34 deletions

View file

@ -33,8 +33,6 @@ void EncryptionManager::generateKeys()
{
if (keyReady) return;
std::cout << "GENEROWANIE KLUCZA" << std::endl;
//randombytes_buf(key.data(), key.size());
crypto_stream_chacha20_ietf_keygen(key.data());
randombytes_buf(nonce.data(), nonce.size());
@ -44,8 +42,6 @@ void EncryptionManager::generateKeys()
void EncryptionManager::saveKey(const std::string& path)
{
std::cout << "ZAPISYWANIE KLUCZA" << std::endl;
const int sig = SIGNATURE_KEY_FILE;
const short ver = VERSION;
@ -65,7 +61,7 @@ void EncryptionManager::saveKey(const std::string& path)
// Zapisz ten œmietnik do pliku KEY
std::ofstream file(path + ".key", std::ios::binary);
if (!file) { std::cout << "Dupa nie zapisa³o" << std::endl; }
if (!file) { std::cout << "Failed to save encryption key to file" << std::endl; }
file.write(reinterpret_cast<const char*>(&sig), sizeof(sig));
file.write(reinterpret_cast<const char*>(&ver), sizeof(ver));
@ -75,8 +71,6 @@ void EncryptionManager::saveKey(const std::string& path)
file.write(reinterpret_cast<const char*>(nonceVec.data()), nonceVec.size());
file.write(reinterpret_cast<const char*>(&crcNonce), sizeof(crcNonce));
if (!file.good()) { std::cout << "Dupa nie zapisa³o" << std::endl; }
file.close();
//saveCppHeadFile(path);
@ -129,7 +123,6 @@ std::string EncryptionManager::toHex(const std::vector<unsigned char>& data)
// Wczytaj klucz
void EncryptionManager::loadKey(const std::string& path)
{
std::cout << "ODCZYT KLUCZA" << std::endl;
std::ifstream file(path + ".key", std::ios::binary);
int sig;
@ -157,8 +150,6 @@ void EncryptionManager::loadKey(const std::string& path)
file.read(nonceVec.data(), nonceVec.size());
file.read(reinterpret_cast<char*>(&crcNonce), sizeof(crcNonce));
std::cout << crcKey << " - " << XXH64(keyVec.data(), keyVec.size(), VERSION) << std::endl;
// SprawdŸ integralnoœæ klucza
if (XXH64(keyVec.data(), keyVec.size(), VERSION) != crcKey
|| XXH64(nonceVec.data(), nonceVec.size(), VERSION) != crcNonce)