ClickHouse/src/IO/ReadBufferFromEncryptedFile.h

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
1.1 KiB
C++
Raw Normal View History

#pragma once
#include "config.h"
#if USE_SSL
#include <IO/ReadBufferFromFileBase.h>
#include <IO/FileEncryptionCommon.h>
namespace DB
{
/// Reads data from the underlying read buffer and decrypts it.
class ReadBufferFromEncryptedFile : public ReadBufferFromFileBase
{
public:
ReadBufferFromEncryptedFile(
size_t buffer_size_,
std::unique_ptr<ReadBufferFromFileBase> in_,
const String & key_,
const FileEncryption::Header & header_,
size_t offset_ = 0);
off_t seek(off_t off, int whence) override;
off_t getPosition() override;
std::string getFileName() const override { return in->getFileName(); }
2022-05-13 15:17:13 +00:00
void setReadUntilPosition(size_t position) override { in->setReadUntilPosition(position + FileEncryption::Header::kSize); }
2022-05-13 15:17:13 +00:00
void setReadUntilEnd() override { in->setReadUntilEnd(); }
size_t getFileSize() override { return in->getFileSize(); }
2022-05-25 14:49:40 +00:00
private:
bool nextImpl() override;
std::unique_ptr<ReadBufferFromFileBase> in;
off_t offset = 0;
bool need_seek = false;
Memory<> encrypted_buffer;
FileEncryption::Encryptor encryptor;
};
}
#endif