Commit 7dafab75 authored by Eugene Kosov's avatar Eugene Kosov

MDEV-21949 key rotation for innodb_encrypt_log is not working in 10.5

log_t::has_encryption_key_rotation(): checks whether
key rotation is supported.

In a subsequent redo log format version, this key rotation
may be broken again.
parent 0c2365c4
......@@ -337,7 +337,7 @@ log_refresh_stats(void);
#define LOG_BLOCK_KEY 4 /* encryption key version
before LOG_BLOCK_CHECKSUM;
in log_t::FORMAT_ENC_10_4 only */
after log_t::FORMAT_ENC_10_4 only */
#define LOG_BLOCK_CHECKSUM 4 /* 4 byte checksum of the log block
contents; in InnoDB versions
< 3.23.52 this did not contain the
......@@ -742,17 +742,21 @@ struct log_t{
void set_check_flush_or_checkpoint(bool flag= true)
{ check_flush_or_checkpoint_.store(flag, std::memory_order_relaxed); }
bool has_encryption_key_rotation() const {
return log.format == FORMAT_ENC_10_4 || log.format == FORMAT_ENC_10_5;
}
/** @return the log block header + trailer size */
unsigned framing_size() const
{
return log.format == FORMAT_ENC_10_4
return has_encryption_key_rotation()
? LOG_BLOCK_HDR_SIZE + LOG_BLOCK_KEY + LOG_BLOCK_CHECKSUM
: LOG_BLOCK_HDR_SIZE + LOG_BLOCK_CHECKSUM;
}
/** @return the log block payload size */
unsigned payload_size() const
{
return log.format == FORMAT_ENC_10_4
return has_encryption_key_rotation()
? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM -
LOG_BLOCK_KEY
: OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_HDR_SIZE - LOG_BLOCK_CHECKSUM;
......@@ -760,7 +764,7 @@ struct log_t{
/** @return the log block trailer offset */
unsigned trailer_offset() const
{
return log.format == FORMAT_ENC_10_4
return has_encryption_key_rotation()
? OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM - LOG_BLOCK_KEY
: OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_CHECKSUM;
}
......
......@@ -156,10 +156,10 @@ bool log_crypt(byte* buf, lsn_t lsn, ulint size, log_crypt_t op)
byte* key_ver = &buf[OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_KEY
- LOG_BLOCK_CHECKSUM];
const size_t dst_size
= log_sys.log.format == log_t::FORMAT_ENC_10_4
= log_sys.has_encryption_key_rotation()
? sizeof dst - LOG_BLOCK_KEY
: sizeof dst;
if (log_sys.log.format == log_t::FORMAT_ENC_10_4) {
if (log_sys.has_encryption_key_rotation()) {
const uint key_version = info.key_version;
switch (op) {
case LOG_ENCRYPT_ROTATE_KEY:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment