MySQL 8.4.0
Source Code Documentation
Stream_cipher Class Referenceabstract

This abstract class represents the interface of a replication logs encryption cipher that can be used to encrypt/decrypt a given stream content in both sequential and random way. More...

#include <stream_cipher.h>

Inheritance diagram for Stream_cipher:
[legend]

Public Member Functions

virtual ~Stream_cipher ()=default
 
virtual bool open (const Key_string &password, int header_size)=0
 Open the cipher with given password. More...
 
virtual void close ()=0
 Close the cipher. More...
 
virtual bool encrypt (unsigned char *dest, const unsigned char *src, int length)=0
 Encrypt data. More...
 
virtual bool decrypt (unsigned char *dest, const unsigned char *src, int length)=0
 Decrypt data. More...
 
virtual bool set_stream_offset (uint64_t offset)=0
 Support encrypting/decrypting data at random position of a stream. More...
 
int get_header_size ()
 Returns the size of the header of the stream being encrypted/decrypted. More...
 

Protected Attributes

int m_header_size = 0
 

Detailed Description

This abstract class represents the interface of a replication logs encryption cipher that can be used to encrypt/decrypt a given stream content in both sequential and random way.

  • Sequential means encrypting/decrypting a stream from the begin to end in order. For sequential encrypting/decrypting, you just need to call it like:

    open(); encrypt(); ... encrypt(); // call it again and again ... close();

  • Random means encrypting/decrypting a stream data without order. For example:

    • It first encrypts the data of a stream at the offset from 100 to 200.
    • And then encrypts the data of the stream at the offset from 0 to 99.

    For random encrypting/decrypting, you need to call set_stream_offset() before calling encrypt(). Example:

    open();

    set_stream_offset(100); encrypt(...); ... set_stream_offset(0); encrypt(...)

    close();

Constructor & Destructor Documentation

◆ ~Stream_cipher()

virtual Stream_cipher::~Stream_cipher ( )
virtualdefault

Member Function Documentation

◆ close()

virtual void Stream_cipher::close ( )
pure virtual

Close the cipher.

Implemented in Aes_ctr_cipher< TYPE >.

◆ decrypt()

virtual bool Stream_cipher::decrypt ( unsigned char *  dest,
const unsigned char *  src,
int  length 
)
pure virtual

Decrypt data.

Parameters
[in]destThe buffer for storing decrypted data. It should be at least 'length' bytes.
[in]srcThe data which will be decrypted.
[in]lengthLength of the data.
Return values
falseSuccess.
trueError.

Implemented in Aes_ctr_cipher< TYPE >.

◆ encrypt()

virtual bool Stream_cipher::encrypt ( unsigned char *  dest,
const unsigned char *  src,
int  length 
)
pure virtual

Encrypt data.

Parameters
[in]destThe buffer for storing encrypted data. It should be at least 'length' bytes.
[in]srcThe data which will be encrypted.
[in]lengthLength of the data.
Return values
falseSuccess.
trueError.

Implemented in Aes_ctr_cipher< TYPE >.

◆ get_header_size()

int Stream_cipher::get_header_size ( )

Returns the size of the header of the stream being encrypted/decrypted.

Returns
the size of the header of the stream being encrypted/decrypted.

◆ open()

virtual bool Stream_cipher::open ( const Key_string password,
int  header_size 
)
pure virtual

Open the cipher with given password.

Parameters
[in]passwordThe password which is used to initialize the cipher.
[in]header_sizeThe encrypted stream offset wrt the down stream.
Return values
falseSuccess.
trueError.

Implemented in Aes_ctr_cipher< TYPE >.

◆ set_stream_offset()

virtual bool Stream_cipher::set_stream_offset ( uint64_t  offset)
pure virtual

Support encrypting/decrypting data at random position of a stream.

Parameters
[in]offsetThe stream offset of the data which will be encrypted/ decrypted in next encrypt()/decrypt() call.
Return values
falseSuccess.
trueError.

Implemented in Aes_ctr_cipher< TYPE >.

Member Data Documentation

◆ m_header_size

int Stream_cipher::m_header_size = 0
protected

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