#pragma once #include "config.h" #include #if USE_SSL #include #include #include namespace DB { /// Encrypts data and writes the encrypted data to the underlying write buffer. class WriteBufferFromEncryptedFile : public WriteBufferDecorator { public: /// `old_file_size` should be set to non-zero if we're going to append an existing file. WriteBufferFromEncryptedFile( size_t buffer_size_, std::unique_ptr out_, const String & key_, const FileEncryption::Header & header_, size_t old_file_size = 0); ~WriteBufferFromEncryptedFile() override; void sync() override; std::string getFileName() const override { return assert_cast(out)->getFileName(); } private: void nextImpl() override; void finalizeBefore() override; FileEncryption::Header header; bool flush_header = false; FileEncryption::Encryptor encryptor; LoggerPtr log = getLogger("WriteBufferFromEncryptedFile"); }; } #endif