-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This is based on WL#9290 in MySQL 8.0, while also adding a keyring based rotated key encryption. The encryption setting supports two options: * master_key, which works like the redo log encryption in MySQL 8.0 * keyring_key, which encrypts each new redo log tablespace with the latest percona_redo key from the keyring. Related commits in upstream 8.0: * 1a6dd57 * 8facbb0
- Loading branch information
Showing
58 changed files
with
4,552 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# WL#9290 InnoDB: Support transparent tablespace data encryption for redo log | ||
# This test case will test basic redo log encryption support features. | ||
|
||
--source include/no_valgrind_without_big.inc | ||
--source include/have_innodb.inc | ||
--source include/not_embedded.inc | ||
--source include/have_innodb_max_16k.inc | ||
|
||
call mtr.add_suppression("\\[Error\\] InnoDB: Encryption can't find master key, please check the keyring plugin is loaded."); | ||
|
||
# eNable redo log encryption, should report error in server log, since keyring is not loaded. | ||
eval SET GLOBAL innodb_redo_log_encrypt = $redo_log_mode; | ||
|
||
# Create a table with encryption, should fail since keyring is not | ||
# loaded. | ||
--error ER_CANNOT_FIND_KEY_IN_KEYRING | ||
CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB; | ||
|
||
CREATE TABLE t1(c1 INT, c2 char(20)) ENGINE = InnoDB; | ||
|
||
--error ER_CANNOT_FIND_KEY_IN_KEYRING | ||
ALTER TABLE t1 ENCRYPTION="Y", algorithm=copy; | ||
|
||
let $restart_parameters = restart: $KEYRING_PARAMS --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log $KEYRING_PLUGIN_OPT; | ||
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH | ||
--replace_regex /\.dll/.so/ | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
#Enable redo log encryption | ||
eval SET GLOBAL innodb_redo_log_encrypt = $redo_log_mode; | ||
|
||
SHOW CREATE TABLE t1; | ||
|
||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
|
||
SELECT * FROM t1 ORDER BY c1 LIMIT 10; | ||
|
||
# Restart to confirm the encryption info can be retrieved properly. | ||
let $restart_parameters = restart: $KEYRING_PARAMS --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log --innodb_redo_log_encrypt=$redo_log_mode; | ||
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH | ||
--replace_regex /\.dll/.so/ | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
SELECT * FROM t1 ORDER BY c1 LIMIT 10; | ||
|
||
DROP TABLE t1; | ||
|
||
# Crash/recovery test. | ||
CREATE TABLE t1(c1 INT, c2 char(20)) ENGINE = InnoDB; | ||
|
||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
|
||
# Restart to confirm the encryption info can be retrieved properly. | ||
--let $restart_parameters = restart: $KEYRING_PARAMS | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
SELECT * FROM t1 ORDER BY c1 LIMIT 10; | ||
DELETE FROM t1; | ||
|
||
START TRANSACTION; | ||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
|
||
# Restart to confirm the encryption info can be retrieved properly. | ||
let $restart_parameters = restart: $KEYRING_PARAMS --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log --innodb_redo_log_encrypt=$redo_log_mode; | ||
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH | ||
--replace_regex /\.dll/.so/ | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
SELECT * FROM t1 ORDER BY c1 LIMIT 10; | ||
|
||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
|
||
SELECT * FROM t1 ORDER BY c1 LIMIT 10; | ||
|
||
# Cleanup | ||
DROP TABLE t1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
# InnoDB transparent tablespace data encryption | ||
# This test case will test basic encryption support features. | ||
|
||
--source include/no_valgrind_without_big.inc | ||
--source include/have_innodb.inc | ||
--source include/not_embedded.inc | ||
|
||
CREATE TABLE t1(c1 int) ENGINE=InnoDB ENCRYPTION="Y"; | ||
|
||
DROP TABLE t1; | ||
|
||
# Restart the server with keyring loaded | ||
--let restart_parameters="restart:$KEYRING_PARAMS" | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; | ||
|
||
SET GLOBAL innodb_file_per_table = 1; | ||
SELECT @@innodb_file_per_table; | ||
|
||
# Create a table with encryption | ||
CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB; | ||
|
||
SHOW CREATE TABLE t1; | ||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
|
||
SELECT * FROM t1 LIMIT 10; | ||
|
||
# Restart to confirm the encryption info can be retrieved properly. | ||
--let restart_parameters="restart:$KEYRING_PARAMS" | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
SELECT * FROM t1 LIMIT 10; | ||
|
||
# Key rotation. | ||
ALTER INSTANCE ROTATE INNODB MASTER KEY; | ||
|
||
DROP TABLE t1; | ||
|
||
# Crash/recovery test. | ||
CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB; | ||
|
||
INSERT INTO t1 VALUES(0, "aaaaa"); | ||
INSERT INTO t1 VALUES(1, "bbbbb"); | ||
INSERT INTO t1 VALUES(2, "ccccc"); | ||
INSERT INTO t1 VALUES(3, "ddddd"); | ||
INSERT INTO t1 VALUES(4, "eeeee"); | ||
INSERT INTO t1 VALUES(5, "fffff"); | ||
INSERT INTO t1 VALUES(6, "ggggg"); | ||
INSERT INTO t1 VALUES(7, "hhhhh"); | ||
INSERT INTO t1 VALUES(8, "iiiii"); | ||
INSERT INTO t1 VALUES(9, "jjjjj"); | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
INSERT INTO t1 select * from t1; | ||
|
||
# Restart to confirm the encryption info can be retrieved properly. | ||
--let restart_parameters="restart:$KEYRING_PARAMS" | ||
--let $restart_hide_args = 1 | ||
--source include/kill_and_restart_mysqld.inc | ||
|
||
SELECT * FROM t1 LIMIT 10; | ||
DROP TABLE t1; | ||
|
||
let $restart_parameters = restart: $KEYRING_PARAMS --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log; | ||
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH | ||
--replace_regex /\.dll/.so/ | ||
--source include/restart_mysqld_no_echo.inc | ||
|
||
# Check no effect of block_encryption_mode = 'aes-256-cbc' variable on table encryption | ||
SET block_encryption_mode = 'aes-256-cbc'; | ||
# Test encryption . | ||
CREATE DATABASE tde_db; | ||
CREATE TABLE tde_db.t1(c1 INT PRIMARY KEY, c2 char(50)) ENCRYPTION = 'Y' ENGINE = InnoDB; | ||
|
||
INSERT INTO tde_db.t1 VALUES(0, 'abc'); | ||
INSERT INTO tde_db.t1 VALUES(1, 'xyz'); | ||
INSERT INTO tde_db.t1 VALUES(2, null); | ||
INSERT INTO tde_db.t1 VALUES(3, null); | ||
SELECT * FROM tde_db.t1 LIMIT 10; | ||
ALTER INSTANCE ROTATE INNODB MASTER KEY; | ||
SELECT * FROM tde_db.t1 LIMIT 10; | ||
--echo # Mysqldump output | ||
--exec $MYSQL_DUMP --compact --skip-comments --databases tde_db | ||
--echo # Redirecting mysqlpump output to MYSQL_TMP_DIR/mysqlpump_encrypt.sql | ||
--exec $MYSQL_PUMP --default-parallelism=1 --databases tde_db > $MYSQL_TMP_DIR/mysqlpump_encrypt.sql | ||
DROP DATABASE tde_db; | ||
|
||
--let SEARCH_FILE=$MYSQL_TMP_DIR/keyring_query_log | ||
let SEARCH_PATTERN= ALTER INSTANCE ROTATE INNODB MASTER KEY; | ||
--source include/search_pattern.inc | ||
|
||
--echo # Loading tables from mysqlpump_encrypt.sql | ||
--exec $MYSQL --skip-comments < $MYSQL_TMP_DIR/mysqlpump_encrypt.sql | ||
SELECT * FROM tde_db.t1 LIMIT 10; | ||
INSERT INTO tde_db.t1 VALUES(4, null); | ||
SELECT * FROM tde_db.t1 LIMIT 10; | ||
DROP DATABASE tde_db; | ||
# | ||
|
||
# Cleanup | ||
--remove_file $MYSQL_TMP_DIR/keyring_query_log | ||
--remove_file $MYSQL_TMP_DIR/mysecret_keyring2 | ||
--remove_file $MYSQL_TMP_DIR/mysqlpump_encrypt.sql | ||
eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table; |
Oops, something went wrong.