MySQL 8.4.2
Source Code Documentation
|
#include <rpl_log_encryption.h>
Public Member Functions | |
Rpl_encryption_header_v1 ()=default | |
~Rpl_encryption_header_v1 () override | |
bool | serialize (Basic_ostream *ostream) override |
Serialize the header into an output stream. More... | |
bool | deserialize (Basic_istream *istream) override |
Deserialize encryption header from a stream. More... | |
char | get_version () const override |
Get the header version. More... | |
int | get_header_size () override |
Return the header size to be taken into account when serializing an deserializing encrypted file headers from replication log files. More... | |
Key_string | decrypt_file_password () override |
Decrypt the file password. More... | |
std::unique_ptr< Stream_cipher > | get_encryptor () override |
Factory to generate ciphers to encrypt streams based on current header. More... | |
std::unique_ptr< Stream_cipher > | get_decryptor () override |
Factory to generate ciphers to decrypt streams based on current header. More... | |
Key_string | generate_new_file_password () override |
Setup the header with current master key and generates a new random file password. More... | |
bool | encrypt_file_password (Key_string password_str) override |
Encrypt a file password using current replication encryption master key. More... | |
Public Member Functions inherited from Rpl_encryption_header | |
virtual | ~Rpl_encryption_header () |
Static Public Member Functions | |
static std::string | key_id_prefix () |
Build a key id prefix. More... | |
static std::string | seqno_to_key_id (uint32_t seqno) |
Build a key id using the given sequence number. More... | |
static std::string | key_id_with_suffix (const char *suffix) |
Build a key id using the given suffix. More... | |
Static Public Member Functions inherited from Rpl_encryption_header | |
static std::unique_ptr< Rpl_encryption_header > | get_header (Basic_istream *istream) |
Deserialize the replication encrypted log file header from the given stream. More... | |
static std::unique_ptr< Rpl_encryption_header > | get_new_default_header () |
Generate a new replication encryption header based on the default replication encrypted log file header version. More... | |
static std::string | key_id_prefix () |
Build a key id prefix using default header version. More... | |
static std::string | seqno_to_key_id (uint32_t seqno) |
Build a key id using the given sequence number using default header version. More... | |
static std::string | key_id_with_suffix (const char *suffix) |
Build a key id using the given suffix using default header version. More... | |
static const char * | get_key_type () |
Return the default header version encryption key type. More... | |
Static Public Attributes | |
static const char * | KEY_TYPE = "AES" |
static const int | KEY_LENGTH = 32 |
static const int | HEADER_SIZE = 512 |
static const int | IV_FIELD_SIZE = 16 |
static const int | PASSWORD_FIELD_SIZE = 32 |
Static Public Attributes inherited from Rpl_encryption_header | |
static const int | ENCRYPTION_MAGIC_SIZE = 4 |
static const char * | ENCRYPTION_MAGIC = "\xfd\x62\x69\x6e" |
Private Types | |
enum | Field_type { KEY_ID = 1 , ENCRYPTED_FILE_PASSWORD = 2 , IV_FOR_FILE_PASSWORD = 3 } |
Private Attributes | |
char | m_version = 1 |
std::string | m_key_id |
Key_string | m_encrypted_password |
Key_string | m_iv |
Static Private Attributes | |
static const char * | KEY_ID_PREFIX = "MySQLReplicationKey" |
Additional Inherited Members | |
Static Protected Attributes inherited from Rpl_encryption_header | |
static const int | VERSION_OFFSET = ENCRYPTION_MAGIC_SIZE |
static const int | VERSION_SIZE = 1 |
static const int | OPTIONAL_FIELD_OFFSET = VERSION_OFFSET + VERSION_SIZE |
+------------------------+----------------------------------------------+ | MAGIC HEADER (4 bytes) | Replication logs encryption version (1 byte) | +------------------------+----------------------------------------------+ | Replication Encryption Key ID (60 to 69 bytes) | +-----------------------------------------------------------------------+ | Encrypted File Password (33 bytes) | +-----------------------------------------------------------------------+ | IV For Encrypting File Password (17 bytes) | +-----------------------------------------------------------------------+ | Padding (388 to 397 bytes) | +-----------------------------------------------------------------------+ Encrypted binary log file header format version 1
Name | Format | Description |
---|---|---|
Replication Encryption Key ID | Variable length field that uses Type, Length, Value (TLV) format. Type takes 1 byte. Length takes 1 byte. Values takes Length bytes. | ID of the key that shall be retrieved from keyring to be used to decrypt the file password field. |
Encrypted File Password | Fixed length field that uses Type, Value format. Type takes 1 byte. Value takes 32 bytes. | It is the encrypted file password. |
IV for Encrypting File Password | Fixed length field that uses Type, Value format. Type takes 1 byte. Value takes 16 bytes. | The iv, together with the key, is used to encrypt/decrypt the file password. |
Padding | Variable length, all bytes are 0. | Encryption header has 512 bytes. Above fields don't take all bytes. All unused bytes are filled with 0 as padding. |
|
private |
|
default |
|
override |
|
overridevirtual |
Decrypt the file password.
Implements Rpl_encryption_header.
|
overridevirtual |
Deserialize encryption header from a stream.
[in] | istream | The input stream for deserializing the encryption header. |
false | Success. |
true | Error. |
Implements Rpl_encryption_header.
|
overridevirtual |
Encrypt a file password using current replication encryption master key.
[in] | password_str | The plain file password. |
false | Success. |
true | Error. |
Implements Rpl_encryption_header.
|
overridevirtual |
Setup the header with current master key and generates a new random file password.
This function shall be called when creating new replication log files.
Implements Rpl_encryption_header.
|
overridevirtual |
Factory to generate ciphers to decrypt streams based on current header.
Implements Rpl_encryption_header.
|
overridevirtual |
Factory to generate ciphers to encrypt streams based on current header.
Implements Rpl_encryption_header.
|
overridevirtual |
Return the header size to be taken into account when serializing an deserializing encrypted file headers from replication log files.
Implements Rpl_encryption_header.
|
overridevirtual |
|
static |
Build a key id prefix.
|
static |
Build a key id using the given suffix.
[in] | suffix | The suffix used to build key id. |
|
static |
Build a key id using the given sequence number.
[in] | seqno | The sequence number used to build key id. |
|
overridevirtual |
Serialize the header into an output stream.
ostream | The output stream to serialize the header. |
false | Success. |
true | Error. |
Implements Rpl_encryption_header.
|
static |
|
static |
|
staticprivate |
|
static |
|
static |
|
private |
|
private |
|
private |
|
private |
|
static |