| 1 |
# InnoDB transparent tablespace data encryption |
| 2 |
# This test case will test basic encryption support features. |
| 3 |
|
| 4 |
--source include/no_valgrind_without_big.inc |
| 5 |
|
| 6 |
#Suppress following messages from myslqd log |
| 7 |
--disable_query_log |
| 8 |
call mtr.add_suppression("keyring_file initialization failure. Please check if the keyring_file_data points to readable keyring file or keyring file can be created in the specified location. The keyring_file will stay unusable until correct path to the keyring file gets provided"); |
| 9 |
call mtr.add_suppression("\\[Error\\] .*MY-\\d+.* Can't generate new master key for tablespace encryption, please check the keyring plugin is loaded."); |
| 10 |
call mtr.add_suppression("\\[Error\\] .*MY-\\d+.* Encryption can't find master key, please check the keyring plugin is loaded."); |
| 11 |
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Function 'keyring_file' already exists"); |
| 12 |
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Couldn't load plugin named 'keyring_file' with soname 'keyring_file.*'."); |
| 13 |
call mtr.add_suppression("Plugin keyring_file reported"); |
| 14 |
call mtr.add_suppression("\\[ERROR\\] .*MY-\\d+.* Can't set redo log files to be encrypted."); |
| 15 |
call mtr.add_suppression("You need to use --log-bin to make --binlog-format work"); |
| 16 |
--enable_query_log |
| 17 |
|
| 18 |
SHOW VARIABLES LIKE "%innodb_redo_log_encrypt%"; |
| 19 |
|
| 20 |
--disable_warnings |
| 21 |
DROP TABLE IF EXISTS t1; |
| 22 |
--enable_warnings |
| 23 |
|
| 24 |
let $innodb_file_per_table = `SELECT @@innodb_file_per_table`; |
| 25 |
|
| 26 |
SET GLOBAL innodb_file_per_table = 1; |
| 27 |
SELECT @@innodb_file_per_table; |
| 28 |
|
| 29 |
# Create a table with encryption |
| 30 |
CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB; |
| 31 |
|
| 32 |
SHOW CREATE TABLE t1; |
| 33 |
INSERT INTO t1 VALUES(0, "aaaaa"); |
| 34 |
INSERT INTO t1 VALUES(1, "bbbbb"); |
| 35 |
INSERT INTO t1 VALUES(2, "ccccc"); |
| 36 |
INSERT INTO t1 VALUES(3, "ddddd"); |
| 37 |
INSERT INTO t1 VALUES(4, "eeeee"); |
| 38 |
INSERT INTO t1 VALUES(5, "fffff"); |
| 39 |
INSERT INTO t1 VALUES(6, "ggggg"); |
| 40 |
INSERT INTO t1 VALUES(7, "hhhhh"); |
| 41 |
INSERT INTO t1 VALUES(8, "iiiii"); |
| 42 |
INSERT INTO t1 VALUES(9, "jjjjj"); |
| 43 |
INSERT INTO t1 select * from t1; |
| 44 |
INSERT INTO t1 select * from t1; |
| 45 |
INSERT INTO t1 select * from t1; |
| 46 |
INSERT INTO t1 select * from t1; |
| 47 |
INSERT INTO t1 select * from t1; |
| 48 |
INSERT INTO t1 select * from t1; |
| 49 |
|
| 50 |
SELECT * FROM t1 LIMIT 10; |
| 51 |
|
| 52 |
# Restart to confirm the encryption info can be retrieved properly. |
| 53 |
--let $restart_parameters= restart: |
| 54 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH |
| 55 |
--replace_regex /\.dll/.so/ |
| 56 |
--source include/restart_mysqld.inc |
| 57 |
|
| 58 |
SHOW VARIABLES LIKE "%innodb_redo_log_encrypt%"; |
| 59 |
|
| 60 |
SELECT * FROM t1 LIMIT 10; |
| 61 |
|
| 62 |
# Key rotation. |
| 63 |
ALTER INSTANCE ROTATE INNODB MASTER KEY; |
| 64 |
|
| 65 |
DROP TABLE t1; |
| 66 |
|
| 67 |
# Crash/recovery test. |
| 68 |
CREATE TABLE t1(c1 INT, c2 char(20)) ENCRYPTION="Y" ENGINE = InnoDB; |
| 69 |
|
| 70 |
INSERT INTO t1 VALUES(0, "aaaaa"); |
| 71 |
INSERT INTO t1 VALUES(1, "bbbbb"); |
| 72 |
INSERT INTO t1 VALUES(2, "ccccc"); |
| 73 |
INSERT INTO t1 VALUES(3, "ddddd"); |
| 74 |
INSERT INTO t1 VALUES(4, "eeeee"); |
| 75 |
INSERT INTO t1 VALUES(5, "fffff"); |
| 76 |
INSERT INTO t1 VALUES(6, "ggggg"); |
| 77 |
INSERT INTO t1 VALUES(7, "hhhhh"); |
| 78 |
INSERT INTO t1 VALUES(8, "iiiii"); |
| 79 |
INSERT INTO t1 VALUES(9, "jjjjj"); |
| 80 |
|
| 81 |
# Restart to confirm the encryption info can be retrieved properly. |
| 82 |
|
| 83 |
--let $restart_parameters= restart: |
| 84 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH |
| 85 |
--replace_regex /\.dll/.so/ |
| 86 |
--source include/kill_and_restart_mysqld.inc |
| 87 |
|
| 88 |
SHOW VARIABLES LIKE "%innodb_redo_log_encrypt%"; |
| 89 |
|
| 90 |
SELECT * FROM t1 LIMIT 10; |
| 91 |
DROP TABLE t1; |
| 92 |
|
| 93 |
--let $restart_parameters = restart: --early-plugin-load="keyring_file=$KEYRING_PLUGIN" --loose-keyring_file_data=$MYSQL_TMP_DIR/mysecret_keyring2 --general-log --log-output=FILE --general_log_file=$MYSQL_TMP_DIR/keyring_query_log $KEYRING_PLUGIN_OPT --innodb_redo_log_encrypt=ON |
| 94 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH |
| 95 |
--replace_regex /\.dll/.so/ |
| 96 |
--source include/restart_mysqld.inc |
| 97 |
|
| 98 |
SHOW VARIABLES LIKE "%innodb_redo_log_encrypt%"; |
| 99 |
|
| 100 |
# |
| 101 |
# Check no effect of block_encryption_mode = 'aes-256-cbc' variable on table encryption |
| 102 |
SET block_encryption_mode = 'aes-256-cbc'; |
| 103 |
# Test encryption . |
| 104 |
--disable_warnings |
| 105 |
DROP DATABASE IF EXISTS tde_db; |
| 106 |
CREATE DATABASE tde_db; |
| 107 |
CREATE TABLE tde_db.t1(c1 INT PRIMARY KEY, c2 char(50)) ENCRYPTION = 'Y' ENGINE = InnoDB; |
| 108 |
--enable_warnings |
| 109 |
# |
| 110 |
INSERT INTO tde_db.t1 VALUES(0, 'abc'); |
| 111 |
INSERT INTO tde_db.t1 VALUES(1, 'xyz'); |
| 112 |
INSERT INTO tde_db.t1 VALUES(2, null); |
| 113 |
INSERT INTO tde_db.t1 VALUES(3, null); |
| 114 |
SELECT * FROM tde_db.t1 LIMIT 10; |
| 115 |
ALTER INSTANCE ROTATE INNODB MASTER KEY; |
| 116 |
SELECT * FROM tde_db.t1 LIMIT 10; |
| 117 |
--echo # Mysqldump output |
| 118 |
--exec $MYSQL_DUMP --compact --skip-comments --databases tde_db |
| 119 |
--echo # Redirecting mysqlpump output to MYSQL_TMP_DIR/mysqlpump_encrypt.sql |
| 120 |
--exec $MYSQL_PUMP --default-parallelism=1 --databases tde_db > $MYSQL_TMP_DIR/mysqlpump_encrypt.sql |
| 121 |
DROP DATABASE tde_db; |
| 122 |
|
| 123 |
--let SEARCH_FILE=$MYSQL_TMP_DIR/keyring_query_log |
| 124 |
let SEARCH_PATTERN= ALTER INSTANCE ROTATE INNODB MASTER KEY; |
| 125 |
--source include/search_pattern.inc |
| 126 |
|
| 127 |
--echo # Loading tables from mysqlpump_encrypt.sql |
| 128 |
--exec $MYSQL --skip-comments < $MYSQL_TMP_DIR/mysqlpump_encrypt.sql |
| 129 |
SELECT * FROM tde_db.t1 LIMIT 10; |
| 130 |
INSERT INTO tde_db.t1 VALUES(4, null); |
| 131 |
SELECT * FROM tde_db.t1 LIMIT 10; |
| 132 |
DROP DATABASE tde_db; |
| 133 |
# |
| 134 |
--let $restart_parameters = restart: |
| 135 |
--replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR $KEYRING_PLUGIN_OPT --plugin-dir=KEYRING_PLUGIN_PATH |
| 136 |
--replace_regex /\.dll/.so/ |
| 137 |
--source include/restart_mysqld.inc |
| 138 |
|
| 139 |
# Cleanup |
| 140 |
--remove_file $MYSQL_TMP_DIR/keyring_query_log |
| 141 |
--remove_file $MYSQL_TMP_DIR/mysqlpump_encrypt.sql |
| 142 |
eval SET GLOBAL innodb_file_per_table=$innodb_file_per_table; |