MySQL 9.1.0
Source Code Documentation
Binlog_encryption_istream Class Reference

Seekable_istream with decryption feature. More...

#include <binlog_istream.h>

Inheritance diagram for Binlog_encryption_istream:
[legend]

Public Member Functions

 ~Binlog_encryption_istream () override
 
bool open (std::unique_ptr< Basic_seekable_istream > down_istream, Binlog_read_error *binlog_read_error)
 Initialize the context used in the decryption stream. More...
 
void close ()
 Closes the stream. More...
 
ssize_t read (unsigned char *buffer, size_t length) override
 Read some bytes from the input stream. More...
 
bool seek (my_off_t offset) override
 Puts the read position to a given offset. More...
 
my_off_t length () override
 The total length of the stream. More...
 
- Public Member Functions inherited from Basic_seekable_istream
 ~Basic_seekable_istream () override=default
 
- Public Member Functions inherited from Basic_istream
virtual ~Basic_istream ()=default
 

Private Attributes

std::unique_ptr< Stream_cipherm_decryptor
 
std::unique_ptr< Basic_seekable_istreamm_down_istream
 

Detailed Description

Seekable_istream with decryption feature.

It can be setup into an stream pipeline. In the pipeline, it decrypts the data from down stream and then feeds the decrypted data into up stream.

Constructor & Destructor Documentation

◆ ~Binlog_encryption_istream()

Binlog_encryption_istream::~Binlog_encryption_istream ( )
override

Member Function Documentation

◆ close()

void Binlog_encryption_istream::close ( )

Closes the stream.

It also closes the down stream and the decryptor.

◆ length()

my_off_t Binlog_encryption_istream::length ( )
overridevirtual

The total length of the stream.

Implements Basic_seekable_istream.

◆ open()

bool Binlog_encryption_istream::open ( std::unique_ptr< Basic_seekable_istream down_istream,
Binlog_read_error binlog_read_error 
)

Initialize the context used in the decryption stream.

Parameters
[in]down_istreamThe down stream where the encrypted data is stored.
[in]binlog_read_errorBinlog_encryption_istream doesn't own a Binlog_read_error. So the caller should provide one to it. When error happens, the error type will be set into 'binlog_read_error'.
Return values
falseSucceed.
trueError.

◆ read()

ssize_t Binlog_encryption_istream::read ( unsigned char *  buffer,
size_t  length 
)
overridevirtual

Read some bytes from the input stream.

It should read exact 'length' bytes unless error happens or it reaches the end of the stream. It should block when reaching the end of a pipe that is not closed.

Parameters
[out]bufferWhere data will be put in.
[in]lengthThe number of bytes that you want to read. length should not be larger than max long.
Returns
Return values fall into three cases:
Return values
'length'Read 'length' bytes successfully
>=0Reach EOF, return the number of bytes actually read. It is between 0 and length-1.
-1Error.

Implements Basic_istream.

◆ seek()

bool Binlog_encryption_istream::seek ( my_off_t  offset)
overridevirtual

Puts the read position to a given offset.

The offset counts from the beginning of the stream. In case an implementing class transforms the data in a way that does not preserve positions, the offset here will be relative to the bytes that are read out from the stream, not relative to the bytes in lower layer storage.

it is allowed for a subclass to return success even if the position is greater than the size of the file. Error may be returned by the next read for this case. Users should call length() if they need to check that the position is within bounds.

Parameters
[in]offsetWhere the read position will be.
Return values
falseSuccess
trueError

Implements Basic_seekable_istream.

Member Data Documentation

◆ m_decryptor

std::unique_ptr<Stream_cipher> Binlog_encryption_istream::m_decryptor
private

◆ m_down_istream

std::unique_ptr<Basic_seekable_istream> Binlog_encryption_istream::m_down_istream
private

The documentation for this class was generated from the following files: