#ifndef CRYPTO_H #define CRYPTO_H #include #include class Crypto { public: /** * Generates a random key of specified length * * @param length The length of the key to generate * @return The generated key */ static std::vector generate_key(size_t length); /** * Encrypts data using AES-GCM * * @param plaintext The data to encrypt * @param key The encryption key * @param iv The initialization vector * @param auth_tag Output parameter for the authentication tag * @return The encrypted data */ static std::vector encrypt(const std::vector& plaintext, const std::vector& key, const std::vector& iv, std::vector& auth_tag); /** * Decrypts data using AES-GCM * * @param ciphertext The data to decrypt * @param key The decryption key * @param iv The initialization vector * @param auth_tag The authentication tag * @return The decrypted data */ static std::vector decrypt(const std::vector& ciphertext, const std::vector& key, const std::vector& iv, const std::vector& auth_tag); /** * Derives a key using PBKDF2-HMAC-SHA256 * * @param password The password to derive from * @param salt The salt to use * @param iterations The number of iterations * @param key_length The length of the derived key * @return The derived key */ static std::vector pbkdf2_hmac_sha256(const std::string& password, const std::vector& salt, int iterations, size_t key_length); /** * Compresses data using zlib * * @param data The data to compress * @return The compressed data */ static std::vector compress(const std::vector& data); /** * Decompresses data using zlib * * @param data The data to decompress * @return The decompressed data */ static std::vector decompress(const std::vector& data); }; #endif // CRYPTO_H