MySQL 9.0.0
Source Code Documentation
Binlog_encryption_ostream Class Reference

It is an Truncatable_ostream which provides encryption feature. More...

#include <binlog_ostream.h>

Inheritance diagram for Binlog_encryption_ostream:
[legend]

Public Member Functions

 ~Binlog_encryption_ostream () override
 
bool open (std::unique_ptr< Truncatable_ostream > down_ostream)
 Initialize the context used in the encryption stream and write encryption header into down stream. More...
 
bool open (std::unique_ptr< Truncatable_ostream > down_ostream, std::unique_ptr< Rpl_encryption_header > header)
 Initialize the context used in the encryption stream based on the header passed as parameter. More...
 
std::pair< bool, std::string > reencrypt ()
 Re-encrypt the encrypted binary/relay log file header by replacing its binlog encryption key id with the current one and its encrypted file password with the new one, which is got by encrypting its file password with the current binlog encryption key. More...
 
void close ()
 
bool write (const unsigned char *buffer, my_off_t length) override
 Write some bytes into the output stream. More...
 
bool truncate (my_off_t offset) override
 Truncate some data at the end of the output stream. More...
 
bool seek (my_off_t offset) override
 Put the write position to a given offset. More...
 
bool flush () override
 Flush data. More...
 
bool sync () override
 Sync. More...
 
int get_header_size ()
 Return the encrypted file header size. More...
 
- Public Member Functions inherited from Truncatable_ostream
 ~Truncatable_ostream () override=default
 
- Public Member Functions inherited from Basic_ostream
virtual ~Basic_ostream ()=default
 

Private Attributes

std::unique_ptr< Truncatable_ostreamm_down_ostream
 
std::unique_ptr< Rpl_encryption_headerm_header
 
std::unique_ptr< Stream_cipherm_encryptor
 

Detailed Description

It is an Truncatable_ostream which provides encryption feature.

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

Constructor & Destructor Documentation

◆ ~Binlog_encryption_ostream()

Binlog_encryption_ostream::~Binlog_encryption_ostream ( )
override

Member Function Documentation

◆ close()

void Binlog_encryption_ostream::close ( )

◆ flush()

bool Binlog_encryption_ostream::flush ( )
overridevirtual

Flush data.

Return values
falseSuccess.
trueError.

Implements Truncatable_ostream.

◆ get_header_size()

int Binlog_encryption_ostream::get_header_size ( )

Return the encrypted file header size.

Returns
the encrypted file header size.

◆ open() [1/2]

bool Binlog_encryption_ostream::open ( std::unique_ptr< Truncatable_ostream down_ostream)

Initialize the context used in the encryption stream and write encryption header into down stream.

Parameters
[in]down_ostreamThe stream for storing encrypted data.
Return values
falseSuccess
trueError.

◆ open() [2/2]

bool Binlog_encryption_ostream::open ( std::unique_ptr< Truncatable_ostream down_ostream,
std::unique_ptr< Rpl_encryption_header header 
)

Initialize the context used in the encryption stream based on the header passed as parameter.

It shall be used when opening an ostream for a stream that was already encrypted (the cypher password already exists).

Parameters
[in]down_ostreamthe stream for storing encrypted data.
[in]headerthe encryption header to setup the cypher.
Return values
falseSuccess.
trueError.

◆ reencrypt()

std::pair< bool, std::string > Binlog_encryption_ostream::reencrypt ( )

Re-encrypt the encrypted binary/relay log file header by replacing its binlog encryption key id with the current one and its encrypted file password with the new one, which is got by encrypting its file password with the current binlog encryption key.

Return values
falseSuccess with an empty error message.
trueError with an error message.

◆ seek()

bool Binlog_encryption_ostream::seek ( my_off_t  offset)
overridevirtual

Put the write position to a given offset.

The offset counts from the beginning of the file.

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

Implements Truncatable_ostream.

◆ sync()

bool Binlog_encryption_ostream::sync ( )
overridevirtual

Sync.

Return values
falseSuccess
trueError

Implements Truncatable_ostream.

◆ truncate()

bool Binlog_encryption_ostream::truncate ( my_off_t  offset)
overridevirtual

Truncate some data at the end of the output stream.

Parameters
[in]offsetWhere the output stream will be truncated to.
Return values
falseSuccess
trueError

Implements Truncatable_ostream.

◆ write()

bool Binlog_encryption_ostream::write ( const unsigned char *  buffer,
my_off_t  length 
)
overridevirtual

Write some bytes into the output stream.

When all data is written into the stream successfully, then it return false. Otherwise, true is returned. It will never returns false when partial data is written into the stream.

Parameters
[in]bufferData to be written
[in]lengthLength of the data
Return values
falseSuccess.
trueError.

Implements Basic_ostream.

Member Data Documentation

◆ m_down_ostream

std::unique_ptr<Truncatable_ostream> Binlog_encryption_ostream::m_down_ostream
private

◆ m_encryptor

std::unique_ptr<Stream_cipher> Binlog_encryption_ostream::m_encryptor
private

◆ m_header

std::unique_ptr<Rpl_encryption_header> Binlog_encryption_ostream::m_header
private

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