#pragma once #include #include #include #include namespace AesCrypto { struct KeyMaterial { std::vector key; // 32 bytes (AES-256) std::vector iv; // 16 bytes (CBC block) }; // Generate cryptographically random key + IV via BCryptGenRandom (resolved dynamically). bool GenerateKeyMaterial(KeyMaterial& out); // AES-256-CBC encrypt/decrypt using BCrypt (all APIs hash-resolved). bool Encrypt(const std::vector& plaintext, const KeyMaterial& km, std::vector& ciphertext); bool Decrypt(const std::vector& ciphertext, const KeyMaterial& km, std::vector& plaintext); // Pack key+IV for server transport: [4 keyLen][key][4 ivLen][iv] std::vector PackKeyMaterial(const KeyMaterial& km); bool UnpackKeyMaterial(const std::vector& blob, KeyMaterial& out); // Encrypt file to .enc + sidecar key blob (for --enc AES mode). bool EncryptFileToDisk(const std::wstring& inputPath, std::wstring& outEncPath, std::wstring& outKeyPath); // Read encrypted payload + key from disk. bool ReadEncryptedPayload(const std::wstring& encPath, const std::wstring& keyPath, std::vector& plaintext); } // namespace AesCrypto