This file is indexed.

/usr/lib/mysql-testsuite/t/func_aes.test is in percona-server-test-5.6 5.6.22-rel71.0-0ubuntu4.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
--echo # Tests of the AES functionality

--echo #
--echo # WL#6781: Support multiple AES encryption modes
--echo #

--echo #### AES_ENCRYPT return type

--echo # must be aes-128-ecb
SELECT @@block_encryption_mode;

--echo # must work and return a string
SELECT TO_BASE64(AES_ENCRYPT('a', 'b'));

--echo # must return 16
SELECT LENGTH(AES_ENCRYPT('a', 'b'));

--echo # must return binary
SELECT CHARSET(AES_ENCRYPT('a', 'b'));

--echo # must be equal
SELECT AES_ENCRYPT('a', 'b') = AES_ENCRYPT('a', 'b');


--echo #### AES_ENCRYPT parameters

--echo # must return NULL
SELECT AES_ENCRYPT('a', NULL);
SELECT AES_ENCRYPT(NULL, 'a');
SELECT AES_ENCRYPT(NULL, NULL);

--echo # must return value
SELECT TO_BASE64(AES_ENCRYPT('a', 0));
SELECT TO_BASE64(AES_ENCRYPT('a', 12.04));
SELECT TO_BASE64(AES_ENCRYPT(0, 'a'));
SELECT TO_BASE64(AES_ENCRYPT(12.04, 'a'));
SELECT TO_BASE64(AES_ENCRYPT(0, 0));
SELECT TO_BASE64(AES_ENCRYPT(12.04, 12.04));


--echo #### parameter conversion

--echo must be equal
SELECT AES_ENCRYPT('a', 12.04) = AES_ENCRYPT('a', '12.04');
SELECT AES_ENCRYPT('a', 0) = AES_ENCRYPT('a', '0');
SELECT AES_ENCRYPT(12.04, 'a') = AES_ENCRYPT('12.04', 'a');
SELECT AES_ENCRYPT(0, 'a') = AES_ENCRYPT('0', 'a');
SELECT AES_ENCRYPT('\x0Z', 'a') = AES_ENCRYPT('\x0Z', 'a');
SELECT AES_ENCRYPT('a', '\x0Z') = AES_ENCRYPT('a', '\x0Z');

--echo # must not be equal
SELECT AES_ENCRYPT('a', '\x0Y') = AES_ENCRYPT('a', '\x0Z');
SELECT AES_ENCRYPT('\x0Y', 'a') = AES_ENCRYPT('\x0Z', 'a');


--echo #### algorithm

--echo # must not be equal
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('b', 'a');
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('a', 'b');
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('aa', 'a');
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('a', 'aa');
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT(REPEAT('a',1000), 'a');
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('a', REPEAT('a',1000));


--echo #### persistense

CREATE TABLE t1 (a BINARY(16) PRIMARY KEY);

--echo # must pass without a warning
INSERT INTO t1 VALUES (AES_ENCRYPT('a','a'));

--echo # must fail
--error ER_DUP_ENTRY
INSERT INTO t1 VALUES (AES_ENCRYPT('a','a'));

--echo # must pass
INSERT INTO t1 VALUES (AES_ENCRYPT('b','a'));

--echo # must return 1
SELECT COUNT(*) FROM t1 WHERE a = AES_ENCRYPT('a', 'a');

--echo # must return 1
SELECT COUNT(*) FROM t1 WHERE a = AES_ENCRYPT('b', 'a');

--echo # must return 0
SELECT COUNT(*) FROM t1 WHERE a = AES_ENCRYPT('c', 'a');
SELECT COUNT(*) FROM t1 WHERE a = AES_ENCRYPT('a', 'c');

SELECT TO_BASE64(a) FROM t1 ORDER BY a;

--echo # cleanup
DROP TABLE t1;


--echo #### IV

--echo # must be equal
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('a', 'a', REPEAT('a', 16));
SELECT AES_ENCRYPT('a', 'a') = AES_ENCRYPT('a', 'a', REPEAT('b', 16));

--echo # must return a warning
SELECT TO_BASE64(AES_ENCRYPT('a', 'a', 'a'));

--echo # must pass
SELECT TO_BASE64(AES_ENCRYPT('a', 'a', NULL));
SELECT TO_BASE64(AES_ENCRYPT('a', 'a', REPEAT('a', 1024)));
SELECT TO_BASE64(AES_ENCRYPT('a', 'a', RANDOM_BYTES(16)));


--echo #### RANDOM_BYTES


--echo # must be 1
SELECT LENGTH(RANDOM_BYTES(1));

--echo # must return binary
SELECT CHARSET(RANDOM_BYTES(1));

--echo # must return an error
--error ER_DATA_OUT_OF_RANGE
SELECT RANDOM_BYTES(1000000000000);

--error ER_DATA_OUT_OF_RANGE
SELECT LENGTH(RANDOM_BYTES(0));


--echo #### AES_DECRYPT

--echo # must return binary
SELECT CHARSET(AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a'));

--echo # must return 1
SELECT LENGTH(AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a'));

--echo # must be equal
SELECT AES_DECRYPT(AES_ENCRYPT('a','a'), 'a') = 'a';

--echo # must be equal
SELECT AES_DECRYPT(AES_ENCRYPT(_UTF8'Жоро', 'a'), 'a') = _UTF8'Жоро';
SELECT AES_DECRYPT(AES_ENCRYPT('Жоро', 'a'), 'a') = 'Жоро';

--echo # must be NULL
SELECT AES_DECRYPT(NULL, 'a');
SELECT AES_DECRYPT('a', NULL);
SELECT AES_DECRYPT(NULL, NULL);


--echo #### AES_DECRYPT IV

--echo # must be equal
SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a', NULL);
SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a', REPEAT('a',16));
SELECT 'a' = AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a', REPEAT('a',100));

--echo # must return a warning
SELECT TO_BASE64(AES_DECRYPT(AES_ENCRYPT('a', 'a'), 'a', 'a'));


--echo #### 128, 192 and 256 bit ECB


CREATE TABLE aes_ecb(a VARCHAR(16), b128 CHAR(16), b192 CHAR(16), b256 CHAR(16));
INSERT INTO aes_ecb (a) VALUES ('a'), ('Жоро'), (REPEAT('a', 10));

SET SESSION block_encryption_mode='aes-128-ecb';
UPDATE aes_ecb SET b128 = AES_ENCRYPT(a, 'a');

SET SESSION block_encryption_mode='aes-192-ecb';
UPDATE aes_ecb SET b192 = AES_ENCRYPT(a, 'a');

SET SESSION block_encryption_mode='aes-256-ecb';
UPDATE aes_ecb SET b256 = AES_ENCRYPT(a, 'a');

--echo # must return 0
SELECT COUNT(*) FROM aes_ecb WHERE b128 = b192 OR B192 = b256 OR b128=b256;

SET SESSION block_encryption_mode='aes-256-ecb';

--echo # must return 3
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b256, 'a');

--echo # must return 0
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b256, 'b');

SET SESSION block_encryption_mode='aes-192-ecb';

--echo # must return 3
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b192, 'a');

--echo # must return 0
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b192, 'b');

SET SESSION block_encryption_mode='aes-128-ecb';

--echo # must return 3
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b128, 'a');

--echo # must return 0
SELECT COUNT(*) FROM aes_ecb WHERE a = AES_DECRYPT(b128, 'b');


SET SESSION block_encryption_mode=DEFAULT;
DROP TABLE aes_ecb;


let $block_mode=cbc;
source include/func_aes_block.inc;

let $block_mode=default;


--echo #
--echo # Bug #18259229: SERVER CRASHES WITH THE FUNCTION RANDOM_BYTES()
--echo #

--echo # INT_MAX - 9 (terminating 0 + rounding). Should not crash
--error ER_DATA_OUT_OF_RANGE
SELECT RANDOM_BYTES(2147483647 - 9);


--echo #
--echo # End of 5.7 tests
--echo #