Fix CTS cipher decrypt so that the updated IV is returned correctly.
[openssl.git] / test / recipes / 30-test_evp_data / evpciph_aes_cts.txt
1 #
2 # Copyright 2020 The OpenSSL Project Authors. All Rights Reserved.
3 #
4 # Licensed under the Apache License 2.0 (the "License").  You may not use
5 # this file except in compliance with the License.  You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
8
9 # Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3
10 # These have an IV of all zeros, for a 128 bit AES key.
11
12 Title = AES CBC Test vectors
13
14 #------------------------------------------------------
15 # AES_CBC results for aligned block lengths. (Result should be the same as 32 byte CTS1 & CTS2)
16
17 # 32 bytes input
18 Cipher = AES-128-CBC
19 Key = 636869636b656e207465726979616b69
20 IV = 00000000000000000000000000000000
21 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
22 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
23
24 # 48 bytes input
25 Cipher = AES-128-CBC
26 Key = 636869636b656e207465726979616b69
27 IV = 00000000000000000000000000000000
28 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20
29 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd8
30
31 # 64 bytes input
32 Cipher = AES-128-CBC
33 Key = 636869636b656e207465726979616b69
34 IV = 00000000000000000000000000000000
35 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
36 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
37
38 Title = AES CBC CTS1 Test vectors
39
40 #------------------------------------------------------
41 # Manually edited using the same inputs to also produce CS1 ciphertext
42 # where aligned blocks are the same as CBC mode, and partial lengths
43 # have the last 2 blocks swapped compared to CS3.
44
45 # 17 bytes Input((Default is CS1 if CTSMode is not specified)
46 Cipher = AES-128-CBC-CTS
47 Key = 636869636b656e207465726979616b69
48 IV = 00000000000000000000000000000000
49 Plaintext = 4920776f756c64206c696b652074686520
50 Ciphertext = 97c6353568f2bf8cb4d8a580362da7ff7f
51 NextIV = c6353568f2bf8cb4d8a580362da7ff7f
52
53 # 31 bytes input
54 Cipher = AES-128-CBC-CTS
55 CTSMode = CS1
56 Key = 636869636b656e207465726979616b69
57 IV = 00000000000000000000000000000000
58 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
59 Ciphertext = 97687268d6ecccc0c07b25e25ecfe5fc00783e0efdb2c1d445d4c8eff7ed22
60 NextIV = fc00783e0efdb2c1d445d4c8eff7ed22
61
62 # 32 bytes input
63 Cipher = AES-128-CBC-CTS
64 CTSMode = CS1
65 Key = 636869636b656e207465726979616b69
66 IV = 00000000000000000000000000000000
67 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
68 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
69 NextIV = 39312523a78662d5be7fcbcc98ebf5a8
70
71 # 47 bytes input
72 Cipher = AES-128-CBC-CTS
73 Key = 636869636b656e207465726979616b69
74 IV = 00000000000000000000000000000000
75 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
76 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5b3fffd940c16a18c1b5549d2f838029e
77 NextIV = b3fffd940c16a18c1b5549d2f838029e
78
79 # 64 bytes input (CS1 is equivalent to CBC when the last block in full)
80 Cipher = AES-128-CBC-CTS
81 CTSMode = CS1
82 Key = 636869636b656e207465726979616b69
83 IV = 00000000000000000000000000000000
84 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
85 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
86 NextIV = 4807efe836ee89a526730dbc2f7bc840
87
88 #-------------------------------------------------------------------------------
89 # Generated test values using an IV.
90
91 # 47 bytes input
92 Cipher = AES-128-CBC-CTS
93 CTSMode = CS1
94 Key = 636869636b656e207465726979616b69
95 IV =000102030405060708090A0B0C0D0E0F
96 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
97 Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472426da5c54a9990f5ae0b7825f51f0060
98
99 # 127 bytes
100 Cipher = AES-128-CBC-CTS
101 CTSMode = CS1
102 Key = 636869636b656e207465726979616b69
103 IV = 000102030405060708090A0B0C0D0E0F
104 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f7570
105 Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d652a4721bf0f082ede80b6399800a92f
106
107 # 129 bytes
108 Cipher = AES-128-CBC-CTS
109 CTSMode = CS1
110 Key = 636869636b656e207465726979616b69
111 IV = 000102030405060708090A0B0C0D0E0F
112 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e49
113 Ciphertext = 5432a630742dee7beb70f9f1400ee6a0b557cfb581949a4bdf3bb67dedd472b9fc50e4e7dacf9e3d94b6cc031f9997a22d2fea7e6ef4aba2b717b0fa3f150e5e86e46b9e51c6ea5091a92aa791ce826b2e4fbaaf0e0314939625434b9530ce56f299891a48d26bdc287f54b230340d14fde9fd1098b9b1db788b5868a8d009eeef
114
115 # 17 Bytes
116 Cipher = AES-192-CBC-CTS
117 CTSMode = CS1
118 Key = 636869636b656e207465726979616b69636869636b656e20
119 IV = 000102030405060708090A0B0C0D0E0F
120 Plaintext = 4920776f756c64206c696b652074686520
121 Ciphertext = e9de1b402de8f79f947cc6b5880588d9b6
122
123 # 31 Bytes
124 Cipher = AES-192-CBC-CTS
125 CTSMode = CS1
126 Key = 636869636b656e207465726979616b69636869636b656e20
127 IV = 000102030405060708090A0B0C0D0E0F
128 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
129 Ciphertext = e9de17d6248fb492bdea1fb2e09c8edea2b610546f3b1e1d231821e283e153
130
131 # 32 Bytes
132 Cipher = AES-192-CBC-CTS
133 CTSMode = CS1
134 Key = 636869636b656e207465726979616b69636869636b656e20
135 IV = 000102030405060708090A0B0C0D0E0F
136 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
137 Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1
138
139 #------------------------------------------------------------------------------
140 # Failure test
141
142 # 15 bytes should fail for CS1
143 Cipher = AES-128-CBC-CTS
144 CTSMode = CS1
145 Key = 636869636b656e207465726979616b69
146 IV = 00000000000000000000000000000000
147 Plaintext = 0102030405060708090A0B0C0D0E0F
148 Result = CIPHERUPDATE_ERROR
149
150 # Original test vectors were taken from https://www.ietf.org/rfc/rfc3962.txt for CS3
151 # These have an IV of all zeros, for a 128 bit AES key.
152
153 Title = AES CBC CTS2 Test vectors
154
155 #------------------------------------------------------
156 # Manually edited using the same inputs to also produce CS2 ciphertext
157 # where aligned blocks are the same as CBC mode, and partial lengths
158 # are the same as CS3.
159
160 # 17 bytes Input (For partial blocks the output should match CS3)
161 Cipher = AES-128-CBC-CTS
162 CTSMode = CS2
163 Key = 636869636b656e207465726979616b69
164 IV = 00000000000000000000000000000000
165 Plaintext = 4920776f756c64206c696b652074686520
166 Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97
167 NextIV = c6353568f2bf8cb4d8a580362da7ff7f
168
169 # 31 bytes input (For partial blocks the output should match CS3)
170 Cipher = AES-128-CBC-CTS
171 CTSMode = CS2
172 Key = 636869636b656e207465726979616b69
173 IV = 00000000000000000000000000000000
174 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
175 Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5
176 NextIV = fc00783e0efdb2c1d445d4c8eff7ed22
177
178 # 32 bytes input (Aligned blocks should match normal CBC mode)
179 Cipher = AES-128-CBC-CTS
180 CTSMode = CS2
181 Key = 636869636b656e207465726979616b69
182 IV = 00000000000000000000000000000000
183 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
184 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a8
185 NextIV = 39312523a78662d5be7fcbcc98ebf5a8
186
187 # 47 bytes input
188 Cipher = AES-128-CBC-CTS
189 CTSMode = CS2
190 Key = 636869636b656e207465726979616b69
191 IV = 00000000000000000000000000000000
192 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
193 Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5
194 NextIV = b3fffd940c16a18c1b5549d2f838029e
195
196 # 64 bytes input (CS2 is equivalent to CBC when the last block in full)
197 Cipher = AES-128-CBC-CTS
198 CTSMode = CS2
199 Key = 636869636b656e207465726979616b69
200 IV = 00000000000000000000000000000000
201 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
202 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a89dad8bbb96c4cdc03bc103e1a194bbd84807efe836ee89a526730dbc2f7bc840
203 NextIV = 4807efe836ee89a526730dbc2f7bc840
204
205 # Generated test values using an IV.
206
207 # 17 Bytes
208 Cipher = AES-192-CBC-CTS
209 CTSMode = CS2
210 Key = 636869636b656e207465726979616b69636869636b656e20
211 IV = 000102030405060708090A0B0C0D0E0F
212 Plaintext = 4920776f756c64206c696b652074686520
213 Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9
214
215 # 31 Bytes
216 Cipher = AES-192-CBC-CTS
217 CTSMode = CS2
218 Key = 636869636b656e207465726979616b69636869636b656e20
219 IV = 000102030405060708090A0B0C0D0E0F
220 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
221 Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e
222
223 # 32 Bytes
224 Cipher = AES-192-CBC-CTS
225 CTSMode = CS2
226 Key = 636869636b656e207465726979616b69636869636b656e20
227 IV = 000102030405060708090A0B0C0D0E0F
228 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
229 Ciphertext = e9de17d6248fb492bdea1fb2e09c8e8e31d005cc9fea948fed1ba6308dad9dd1
230
231 # Failure test - 15 bytes should fail for CS2
232 Cipher = AES-128-CBC-CTS
233 CTSMode = CS2
234 Key = 636869636b656e207465726979616b69
235 IV = 00000000000000000000000000000000
236 Plaintext = 0102030405060708090A0B0C0D0E0F
237 Result = CIPHERUPDATE_ERROR
238
239
240 Title = AES CBC CTS3 Test vectors
241
242 # 17 bytes Input
243 Cipher = AES-128-CBC-CTS
244 CTSMode = CS3
245 Key = 636869636b656e207465726979616b69
246 IV = 00000000000000000000000000000000
247 Plaintext = 4920776f756c64206c696b652074686520
248 Ciphertext = c6353568f2bf8cb4d8a580362da7ff7f97
249 NextIV = c6353568f2bf8cb4d8a580362da7ff7f
250
251 # 31 bytes input
252 Cipher = AES-128-CBC-CTS
253 CTSMode = CS3
254 Key = 636869636b656e207465726979616b69
255 IV = 00000000000000000000000000000000
256 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
257 Ciphertext = fc00783e0efdb2c1d445d4c8eff7ed2297687268d6ecccc0c07b25e25ecfe5
258 NextIV = fc00783e0efdb2c1d445d4c8eff7ed22
259
260 # 32 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block)
261 Cipher = AES-128-CBC-CTS
262 CTSMode = CS3
263 Key = 636869636b656e207465726979616b69
264 IV = 00000000000000000000000000000000
265 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
266 Ciphertext = 39312523a78662d5be7fcbcc98ebf5a897687268d6ecccc0c07b25e25ecfe584
267 NextIV = 39312523a78662d5be7fcbcc98ebf5a8
268
269 # 47 bytes input
270 Cipher = AES-128-CBC-CTS
271 CTSMode = CS3
272 Key = 636869636b656e207465726979616b69
273 IV = 00000000000000000000000000000000
274 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
275 Ciphertext = 97687268d6ecccc0c07b25e25ecfe584b3fffd940c16a18c1b5549d2f838029e39312523a78662d5be7fcbcc98ebf5
276 NextIV = b3fffd940c16a18c1b5549d2f838029e
277
278 # 48 bytes input
279 Cipher = AES-128-CBC-CTS
280 CTSMode = CS3
281 Key = 636869636b656e207465726979616b69
282 IV = 00000000000000000000000000000000
283 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20
284 Ciphertext = 97687268d6ecccc0c07b25e25ecfe5849dad8bbb96c4cdc03bc103e1a194bbd839312523a78662d5be7fcbcc98ebf5a8
285 NextIV = 9dad8bbb96c4cdc03bc103e1a194bbd8
286
287 # 64 bytes input (CS3 always swaps the last 2 byte blocks - so it is not equivalent to CBC for a full block)
288 Cipher = AES-128-CBC-CTS
289 CTSMode = CS3
290 Key = 636869636b656e207465726979616b69
291 IV = 00000000000000000000000000000000
292 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c20616e6420776f6e746f6e20736f75702e
293 Ciphertext = 97687268d6ecccc0c07b25e25ecfe58439312523a78662d5be7fcbcc98ebf5a84807efe836ee89a526730dbc2f7bc8409dad8bbb96c4cdc03bc103e1a194bbd8
294
295
296 # Generated test values using an IV.
297 # 47 bytes input
298 Cipher = AES-128-CBC-CTS
299 CTSMode = CS3
300 Key = 636869636b656e207465726979616b69
301 IV = 000102030405060708090A0B0C0D0E0F
302 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320436869636b656e2c20706c656173652c
303 Ciphertext = 5432a630742dee7beb70f9f1400ee6a0426da5c54a9990f5ae0b7825f51f0060b557cfb581949a4bdf3bb67dedd472
304
305 # 17 Bytes
306 Cipher = AES-192-CBC-CTS
307 CTSMode = CS3
308 Key = 636869636b656e207465726979616b69636869636b656e20
309 IV =000102030405060708090A0B0C0D0E0F
310 Plaintext = 4920776f756c64206c696b652074686520
311 Ciphertext = de1b402de8f79f947cc6b5880588d9b6e9
312
313 # 31 Bytes
314 Cipher = AES-192-CBC-CTS
315 CTSMode = CS3
316 Key = 636869636b656e207465726979616b69636869636b656e20
317 IV = 000102030405060708090A0B0C0D0E0F
318 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
319 Ciphertext = dea2b610546f3b1e1d231821e283e153e9de17d6248fb492bdea1fb2e09c8e
320
321 # 32 Bytes
322 Cipher = AES-192-CBC-CTS
323 CTSMode = CS3
324 Key = 636869636b656e207465726979616b69636869636b656e20
325 IV = 000102030405060708090A0B0C0D0E0F
326 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
327 Ciphertext = 31d005cc9fea948fed1ba6308dad9dd1e9de17d6248fb492bdea1fb2e09c8e8e
328
329 # 17 Bytes
330 Cipher = AES-256-CBC-CTS
331 CTSMode = CS3
332 Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
333 IV = 000102030405060708090A0B0C0D0E0F
334 Plaintext = 4920776f756c64206c696b652074686520
335 Ciphertext = 6b5f5abc21c4d04156c73850da3bba29e9
336
337 # 31 Bytes
338 Cipher = AES-256-CBC-CTS
339 CTSMode = CS3
340 Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
341 IV = 000102030405060708090A0B0C0D0E0F
342 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c20476175277320
343 Ciphertext = f22553af78ee4f468f02fbe6f0f2168ee954e79fae9310dc75b6070e1d6253
344
345 # 32 Bytes
346 Cipher = AES-256-CBC-CTS
347 CTSMode = CS3
348 Key = 636869636b656e207465726979616b69636869636b656e207465726979616b69
349 IV = 000102030405060708090A0B0C0D0E0F
350 Plaintext = 4920776f756c64206c696b65207468652047656e6572616c2047617527732043
351 Ciphertext = 2c0463982174df10baa9d8f782c5a5b3e954e79fae9310dc75b6070e1d625346
352
353 # Failure tests
354 # 15 bytes should fail for CS3
355 Cipher = AES-128-CBC-CTS
356 CTSMode = CS3
357 Key = 636869636b656e207465726979616b69
358 IV = 00000000000000000000000000000000
359 Plaintext = 0102030405060708090A0B0C0D0E0F
360 Result = CIPHERUPDATE_ERROR
361
362 # 16 bytes input
363 Cipher = AES-128-CBC
364 Key = 636869636b656e207465726979616b69
365 IV = 00000000000000000000000000000000
366 Plaintext = 0102030405060708090A0B0C0D0E0F00
367 Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e
368
369 # 16 bytes with CS3 should return the same as plain CBC mode.
370 Cipher = AES-128-CBC-CTS
371 CTSMode = CS1
372 Key = 636869636b656e207465726979616b69
373 IV = 00000000000000000000000000000000
374 Plaintext = 0102030405060708090A0B0C0D0E0F00
375 Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e
376
377 Cipher = AES-128-CBC-CTS
378 CTSMode = CS2
379 Key = 636869636b656e207465726979616b69
380 IV = 00000000000000000000000000000000
381 Plaintext = 0102030405060708090A0B0C0D0E0F00
382 Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e
383
384 Cipher = AES-128-CBC-CTS
385 CTSMode = CS3
386 Key = 636869636b656e207465726979616b69
387 IV = 00000000000000000000000000000000
388 Plaintext = 0102030405060708090A0B0C0D0E0F00
389 Ciphertext = 011ca8de3bd20ebc2f8701d56dcf768e
390