File: func_aes_misc.result

package info (click to toggle)
percona-xtrabackup 2.2.3-2.1
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 293,260 kB
  • ctags: 146,881
  • sloc: cpp: 1,051,960; ansic: 570,217; java: 54,595; perl: 53,495; pascal: 44,194; sh: 27,826; yacc: 15,314; python: 12,142; xml: 7,848; sql: 4,125; makefile: 1,459; awk: 785; lex: 758
file content (255 lines) | stat: -rw-r--r-- 8,480 bytes parent folder | download
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
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
##############################################
#### Tests for ECB Mode
##############################################
SET @IV='abcd1234efgh5678';
SET @KEYS=REPEAT('c', 16);
SET @ENCSTR=REPEAT('d', 256);
"--------------------------------------------"
##################### Testing with mode : aes-128-ecb
SET SESSION block_encryption_mode="aes-128-ecb";
SELECT @@global.block_encryption_mode;
@@global.block_encryption_mode
aes-128-ecb
SELECT @@session.block_encryption_mode;
@@session.block_encryption_mode
aes-128-ecb
####Test without tables
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with InnoDB tables
DROP TABLE IF EXISTS t1;
Warnings:
Note	1051	Unknown table 'test.t1'
CREATE TABLE t1(f1 varchar(256));
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with MyISAM tables
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 varchar(256)) engine=MyISAM;
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
"--------------------------------------------"
##################### Testing with mode : aes-192-ecb
SET SESSION block_encryption_mode="aes-192-ecb";
SELECT @@global.block_encryption_mode;
@@global.block_encryption_mode
aes-128-ecb
SELECT @@session.block_encryption_mode;
@@session.block_encryption_mode
aes-192-ecb
####Test without tables
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with InnoDB tables
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 varchar(256));
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with MyISAM tables
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 varchar(256)) engine=MyISAM;
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
"--------------------------------------------"
##################### Testing with mode : aes-256-ecb
SET SESSION block_encryption_mode="aes-256-ecb";
should return 1
SELECT @@global.block_encryption_mode;
@@global.block_encryption_mode
aes-128-ecb
should return 1
SELECT @@session.block_encryption_mode;
@@session.block_encryption_mode
aes-256-ecb
####Test without tables
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with InnoDB tables
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 varchar(256));
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
####Test with MyISAM tables
DROP TABLE IF EXISTS t1;
CREATE TABLE t1(f1 varchar(256)) engine=MyISAM;
INSERT INTO t1 values(@ENCSTR);
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS), @KEYS)=@ENCSTR
1
should return 1
SELECT AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(AES_ENCRYPT(@ENCSTR, @KEYS, @IV), @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
Warning	1618	<IV> option ignored
DROP TABLE IF EXISTS t1;
"--------------------------------------------"
##############################################
"Tests related to RANDOM_BYTES()"
##############################################
should return 1
select LENGTH(RANDOM_BYTES(1))=1;
LENGTH(RANDOM_BYTES(1))=1
1
should return 1
select LENGTH(RANDOM_BYTES(1024))=1024;
LENGTH(RANDOM_BYTES(1024))=1024
1
SET @KEYS=RANDOM_BYTES(1);
SET @KEYS=RANDOM_BYTES(1024);
select RANDOM_BYTES(0);
ERROR 22003: length value is out of range in 'random_bytes'
select RANDOM_BYTES(1025);
ERROR 22003: length value is out of range in 'random_bytes'
##############################################
"Tests related to boundary values of IV"
##############################################
SET @IV='abcdefghijklmnophelloworldworldisgreat';
SET @IV1='abcdefghijklmnopqrstuvwxyz';
SET @KEYS='helloworld';
SET @ENCSTR=REPEAT('K',100);
SET @@session.block_encryption_mode = 'aes-256-cbc';
should return 1
select AES_ENCRYPT(@ENCSTR, @KEYS, @IV)=AES_ENCRYPT(@ENCSTR, @KEYS, @IV1);
AES_ENCRYPT(@ENCSTR, @KEYS, @IV)=AES_ENCRYPT(@ENCSTR, @KEYS, @IV1)
1
##############################################
"Few negative tests with invalid/different keys and IV"
##############################################
SET @IV='ijkl8765mnop2345';
SET @KEYS='helloworld1234567890';
SET @ENCSTR=REPEAT('J',255);
SET @@session.block_encryption_mode = 'aes-128-ecb';
DROP TABLE IF EXISTS t1;
Warnings:
Note	1051	Unknown table 'test.t1'
CREATE TABLE t1(f1 varchar(256));
INSERT INTO t1 values(AES_ENCRYPT(@ENCSTR, @KEYS, @IV));
Warnings:
Warning	1618	<IV> option ignored
Combination1..............
SET @@session.block_encryption_mode = 'aes-192-ecb';
should return NULL
SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR
NULL
Warnings:
Warning	1618	<IV> option ignored
Combination2..............
SET @@session.block_encryption_mode = 'aes-256-ecb';
should return NULL
SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR
NULL
Warnings:
Warning	1618	<IV> option ignored
Combination3..............
SET @@session.block_encryption_mode = 'aes-128-cbc';
should return 0 or NULL
SELECT COALESCE (AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR,0) FROM t1;
COALESCE (AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR,0)
0
Combination4..............
SET @@session.block_encryption_mode = 'aes-192-cbc';
should return NULL
SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR
NULL
Combination5..............
SET @@session.block_encryption_mode = 'aes-256-cbc';
should return NULL
SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR
NULL
Combination6..............
SET @@session.block_encryption_mode = 'aes-128-ecb';
should return 1
SELECT AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR FROM t1;
AES_DECRYPT(f1, @KEYS, @IV)=@ENCSTR
1
Warnings:
Warning	1618	<IV> option ignored
SET @@session.block_encryption_mode = DEFAULT;
DROP TABLE IF EXISTS t1;
#
# End of 5.7 tests
#