write all to encrypted file instead
This commit is contained in:
+10
-16
@@ -150,25 +150,19 @@ int main(int argc, char* argv[]) {
|
||||
}
|
||||
|
||||
try {
|
||||
// Read encrypted files
|
||||
std::vector<uint8_t> ciphertext = readFile("encrypted_Input.bin");
|
||||
std::vector<uint8_t> metadata = readFile("decryption_metadata.bin");
|
||||
|
||||
if (metadata.size() < 48) { // 32 salt + 12 nonce + 4 size
|
||||
throw std::runtime_error("Invalid metadata file");
|
||||
}
|
||||
|
||||
// Parse metadata: salt (32) + iv (16) + size (4) = 52 bytes
|
||||
std::vector<uint8_t> salt(metadata.begin(), metadata.begin() + 32);
|
||||
std::vector<uint8_t> iv(metadata.begin() + 32, metadata.begin() + 48);
|
||||
uint32_t expected_size = *reinterpret_cast<const uint32_t*>(metadata.data() + 48);
|
||||
// Read encrypted DLL file
|
||||
std::vector<uint8_t> data = readFile("encrypted_dll.dll");
|
||||
|
||||
// Validate metadata
|
||||
|
||||
if (ciphertext.size() != expected_size) {
|
||||
throw std::runtime_error("Ciphertext size mismatch");
|
||||
if (data.size() < 52) {
|
||||
throw std::runtime_error("File too small");
|
||||
}
|
||||
|
||||
// Parse: salt (32) + iv (16) + size (4) + ciphertext
|
||||
std::vector<uint8_t> salt(data.begin(), data.begin() + 32);
|
||||
std::vector<uint8_t> iv(data.begin() + 32, data.begin() + 48);
|
||||
uint32_t ciphertext_len = *reinterpret_cast<const uint32_t*>(&data[48]);
|
||||
std::vector<uint8_t> ciphertext(data.begin() + 52, data.begin() + 52 + ciphertext_len);
|
||||
|
||||
// Decrypt
|
||||
AESCBCDecryptor decryptor;
|
||||
std::string password = argv[1];
|
||||
|
||||
Reference in New Issue
Block a user