xref: /freebsd-src/crypto/openssl/test/modes_internal_test.c (revision e0c4386e7e71d93b0edc0c8fa156263fc4a8b0b6)
1*e0c4386eSCy Schubert /*
2*e0c4386eSCy Schubert  * Copyright 2016-2021 The OpenSSL Project Authors. All Rights Reserved.
3*e0c4386eSCy Schubert  *
4*e0c4386eSCy Schubert  * Licensed under the Apache License 2.0 (the "License").  You may not use
5*e0c4386eSCy Schubert  * this file except in compliance with the License.  You can obtain a copy
6*e0c4386eSCy Schubert  * in the file LICENSE in the source distribution or at
7*e0c4386eSCy Schubert  * https://www.openssl.org/source/license.html
8*e0c4386eSCy Schubert  */
9*e0c4386eSCy Schubert 
10*e0c4386eSCy Schubert /* Internal tests for the modes module */
11*e0c4386eSCy Schubert 
12*e0c4386eSCy Schubert /*
13*e0c4386eSCy Schubert  * This file uses the low level AES functions (which are deprecated for
14*e0c4386eSCy Schubert  * non-internal use) in order to test the modes code
15*e0c4386eSCy Schubert  */
16*e0c4386eSCy Schubert #include "internal/deprecated.h"
17*e0c4386eSCy Schubert 
18*e0c4386eSCy Schubert #include <stdio.h>
19*e0c4386eSCy Schubert #include <string.h>
20*e0c4386eSCy Schubert 
21*e0c4386eSCy Schubert #include <openssl/aes.h>
22*e0c4386eSCy Schubert #include <openssl/modes.h>
23*e0c4386eSCy Schubert #include "testutil.h"
24*e0c4386eSCy Schubert #include "crypto/modes.h"
25*e0c4386eSCy Schubert #include "internal/nelem.h"
26*e0c4386eSCy Schubert 
27*e0c4386eSCy Schubert typedef struct {
28*e0c4386eSCy Schubert     size_t size;
29*e0c4386eSCy Schubert     const unsigned char *data;
30*e0c4386eSCy Schubert }  SIZED_DATA;
31*e0c4386eSCy Schubert 
32*e0c4386eSCy Schubert /**********************************************************************
33*e0c4386eSCy Schubert  *
34*e0c4386eSCy Schubert  * Test of cts128
35*e0c4386eSCy Schubert  *
36*e0c4386eSCy Schubert  ***/
37*e0c4386eSCy Schubert 
38*e0c4386eSCy Schubert /* cts128 test vectors from RFC 3962 */
39*e0c4386eSCy Schubert static const unsigned char cts128_test_key[16] = "chicken teriyaki";
40*e0c4386eSCy Schubert static const unsigned char cts128_test_input[64] =
41*e0c4386eSCy Schubert     "I would like the" " General Gau's C"
42*e0c4386eSCy Schubert     "hicken, please, " "and wonton soup.";
43*e0c4386eSCy Schubert static const unsigned char cts128_test_iv[] =
44*e0c4386eSCy Schubert     { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
45*e0c4386eSCy Schubert 
46*e0c4386eSCy Schubert static const unsigned char vector_17[17] = {
47*e0c4386eSCy Schubert     0xc6, 0x35, 0x35, 0x68, 0xf2, 0xbf, 0x8c, 0xb4,
48*e0c4386eSCy Schubert     0xd8, 0xa5, 0x80, 0x36, 0x2d, 0xa7, 0xff, 0x7f,
49*e0c4386eSCy Schubert     0x97
50*e0c4386eSCy Schubert };
51*e0c4386eSCy Schubert 
52*e0c4386eSCy Schubert static const unsigned char vector_31[31] = {
53*e0c4386eSCy Schubert     0xfc, 0x00, 0x78, 0x3e, 0x0e, 0xfd, 0xb2, 0xc1,
54*e0c4386eSCy Schubert     0xd4, 0x45, 0xd4, 0xc8, 0xef, 0xf7, 0xed, 0x22,
55*e0c4386eSCy Schubert     0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
56*e0c4386eSCy Schubert     0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5
57*e0c4386eSCy Schubert };
58*e0c4386eSCy Schubert 
59*e0c4386eSCy Schubert static const unsigned char vector_32[32] = {
60*e0c4386eSCy Schubert     0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
61*e0c4386eSCy Schubert     0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
62*e0c4386eSCy Schubert     0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
63*e0c4386eSCy Schubert     0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84
64*e0c4386eSCy Schubert };
65*e0c4386eSCy Schubert 
66*e0c4386eSCy Schubert static const unsigned char vector_47[47] = {
67*e0c4386eSCy Schubert     0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
68*e0c4386eSCy Schubert     0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
69*e0c4386eSCy Schubert     0xb3, 0xff, 0xfd, 0x94, 0x0c, 0x16, 0xa1, 0x8c,
70*e0c4386eSCy Schubert     0x1b, 0x55, 0x49, 0xd2, 0xf8, 0x38, 0x02, 0x9e,
71*e0c4386eSCy Schubert     0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
72*e0c4386eSCy Schubert     0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5
73*e0c4386eSCy Schubert };
74*e0c4386eSCy Schubert 
75*e0c4386eSCy Schubert static const unsigned char vector_48[48] = {
76*e0c4386eSCy Schubert     0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
77*e0c4386eSCy Schubert     0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
78*e0c4386eSCy Schubert     0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
79*e0c4386eSCy Schubert     0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8,
80*e0c4386eSCy Schubert     0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
81*e0c4386eSCy Schubert     0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8
82*e0c4386eSCy Schubert };
83*e0c4386eSCy Schubert 
84*e0c4386eSCy Schubert static const unsigned char vector_64[64] = {
85*e0c4386eSCy Schubert     0x97, 0x68, 0x72, 0x68, 0xd6, 0xec, 0xcc, 0xc0,
86*e0c4386eSCy Schubert     0xc0, 0x7b, 0x25, 0xe2, 0x5e, 0xcf, 0xe5, 0x84,
87*e0c4386eSCy Schubert     0x39, 0x31, 0x25, 0x23, 0xa7, 0x86, 0x62, 0xd5,
88*e0c4386eSCy Schubert     0xbe, 0x7f, 0xcb, 0xcc, 0x98, 0xeb, 0xf5, 0xa8,
89*e0c4386eSCy Schubert     0x48, 0x07, 0xef, 0xe8, 0x36, 0xee, 0x89, 0xa5,
90*e0c4386eSCy Schubert     0x26, 0x73, 0x0d, 0xbc, 0x2f, 0x7b, 0xc8, 0x40,
91*e0c4386eSCy Schubert     0x9d, 0xad, 0x8b, 0xbb, 0x96, 0xc4, 0xcd, 0xc0,
92*e0c4386eSCy Schubert     0x3b, 0xc1, 0x03, 0xe1, 0xa1, 0x94, 0xbb, 0xd8
93*e0c4386eSCy Schubert };
94*e0c4386eSCy Schubert 
95*e0c4386eSCy Schubert #define CTS128_TEST_VECTOR(len)                 \
96*e0c4386eSCy Schubert     {                                           \
97*e0c4386eSCy Schubert         sizeof(vector_##len), vector_##len      \
98*e0c4386eSCy Schubert     }
99*e0c4386eSCy Schubert static const SIZED_DATA aes_cts128_vectors[] = {
100*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(17),
101*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(31),
102*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(32),
103*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(47),
104*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(48),
105*e0c4386eSCy Schubert     CTS128_TEST_VECTOR(64),
106*e0c4386eSCy Schubert };
107*e0c4386eSCy Schubert 
cts128_encrypt_key_schedule(void)108*e0c4386eSCy Schubert static AES_KEY *cts128_encrypt_key_schedule(void)
109*e0c4386eSCy Schubert {
110*e0c4386eSCy Schubert     static int init_key = 1;
111*e0c4386eSCy Schubert     static AES_KEY ks;
112*e0c4386eSCy Schubert 
113*e0c4386eSCy Schubert     if (init_key) {
114*e0c4386eSCy Schubert         AES_set_encrypt_key(cts128_test_key, 128, &ks);
115*e0c4386eSCy Schubert         init_key = 0;
116*e0c4386eSCy Schubert     }
117*e0c4386eSCy Schubert     return &ks;
118*e0c4386eSCy Schubert }
119*e0c4386eSCy Schubert 
cts128_decrypt_key_schedule(void)120*e0c4386eSCy Schubert static AES_KEY *cts128_decrypt_key_schedule(void)
121*e0c4386eSCy Schubert {
122*e0c4386eSCy Schubert     static int init_key = 1;
123*e0c4386eSCy Schubert     static AES_KEY ks;
124*e0c4386eSCy Schubert 
125*e0c4386eSCy Schubert     if (init_key) {
126*e0c4386eSCy Schubert         AES_set_decrypt_key(cts128_test_key, 128, &ks);
127*e0c4386eSCy Schubert         init_key = 0;
128*e0c4386eSCy Schubert     }
129*e0c4386eSCy Schubert     return &ks;
130*e0c4386eSCy Schubert }
131*e0c4386eSCy Schubert 
132*e0c4386eSCy Schubert typedef struct {
133*e0c4386eSCy Schubert     const char *case_name;
134*e0c4386eSCy Schubert     size_t (*last_blocks_correction)(const unsigned char *in,
135*e0c4386eSCy Schubert                                      unsigned char *out, size_t len);
136*e0c4386eSCy Schubert     size_t (*encrypt_block)(const unsigned char *in,
137*e0c4386eSCy Schubert                             unsigned char *out, size_t len,
138*e0c4386eSCy Schubert                             const void *key, unsigned char ivec[16],
139*e0c4386eSCy Schubert                             block128_f block);
140*e0c4386eSCy Schubert     size_t (*encrypt_stream)(const unsigned char *in, unsigned char *out,
141*e0c4386eSCy Schubert                              size_t len, const void *key,
142*e0c4386eSCy Schubert                              unsigned char ivec[16], cbc128_f cbc);
143*e0c4386eSCy Schubert     size_t (*decrypt_block)(const unsigned char *in,
144*e0c4386eSCy Schubert                             unsigned char *out, size_t len,
145*e0c4386eSCy Schubert                             const void *key, unsigned char ivec[16],
146*e0c4386eSCy Schubert                             block128_f block);
147*e0c4386eSCy Schubert     size_t (*decrypt_stream)(const unsigned char *in, unsigned char *out,
148*e0c4386eSCy Schubert                              size_t len, const void *key,
149*e0c4386eSCy Schubert                              unsigned char ivec[16], cbc128_f cbc);
150*e0c4386eSCy Schubert } CTS128_FIXTURE;
151*e0c4386eSCy Schubert 
last_blocks_correction(const unsigned char * in,unsigned char * out,size_t len)152*e0c4386eSCy Schubert static size_t last_blocks_correction(const unsigned char *in,
153*e0c4386eSCy Schubert                                      unsigned char *out, size_t len)
154*e0c4386eSCy Schubert {
155*e0c4386eSCy Schubert     size_t tail;
156*e0c4386eSCy Schubert 
157*e0c4386eSCy Schubert     memcpy(out, in, len);
158*e0c4386eSCy Schubert     if ((tail = len % 16) == 0)
159*e0c4386eSCy Schubert         tail = 16;
160*e0c4386eSCy Schubert     tail += 16;
161*e0c4386eSCy Schubert 
162*e0c4386eSCy Schubert     return tail;
163*e0c4386eSCy Schubert }
164*e0c4386eSCy Schubert 
last_blocks_correction_nist(const unsigned char * in,unsigned char * out,size_t len)165*e0c4386eSCy Schubert static size_t last_blocks_correction_nist(const unsigned char *in,
166*e0c4386eSCy Schubert                                           unsigned char *out, size_t len)
167*e0c4386eSCy Schubert {
168*e0c4386eSCy Schubert     size_t tail;
169*e0c4386eSCy Schubert 
170*e0c4386eSCy Schubert     if ((tail = len % 16) == 0)
171*e0c4386eSCy Schubert         tail = 16;
172*e0c4386eSCy Schubert     len -= 16 + tail;
173*e0c4386eSCy Schubert     memcpy(out, in, len);
174*e0c4386eSCy Schubert     /* flip two last blocks */
175*e0c4386eSCy Schubert     memcpy(out + len, in + len + 16, tail);
176*e0c4386eSCy Schubert     memcpy(out + len + tail, in + len, 16);
177*e0c4386eSCy Schubert     len += 16 + tail;
178*e0c4386eSCy Schubert     tail = 16;
179*e0c4386eSCy Schubert 
180*e0c4386eSCy Schubert     return tail;
181*e0c4386eSCy Schubert }
182*e0c4386eSCy Schubert 
execute_cts128(const CTS128_FIXTURE * fixture,int num)183*e0c4386eSCy Schubert static int execute_cts128(const CTS128_FIXTURE *fixture, int num)
184*e0c4386eSCy Schubert {
185*e0c4386eSCy Schubert     const unsigned char *test_iv = cts128_test_iv;
186*e0c4386eSCy Schubert     size_t test_iv_len = sizeof(cts128_test_iv);
187*e0c4386eSCy Schubert     const unsigned char *orig_vector = aes_cts128_vectors[num].data;
188*e0c4386eSCy Schubert     size_t len = aes_cts128_vectors[num].size;
189*e0c4386eSCy Schubert     const unsigned char *test_input = cts128_test_input;
190*e0c4386eSCy Schubert     const AES_KEY *encrypt_key_schedule = cts128_encrypt_key_schedule();
191*e0c4386eSCy Schubert     const AES_KEY *decrypt_key_schedule = cts128_decrypt_key_schedule();
192*e0c4386eSCy Schubert     unsigned char iv[16];
193*e0c4386eSCy Schubert     /* The largest test inputs are = 64 bytes. */
194*e0c4386eSCy Schubert     unsigned char cleartext[64], ciphertext[64], vector[64];
195*e0c4386eSCy Schubert     size_t tail, size;
196*e0c4386eSCy Schubert 
197*e0c4386eSCy Schubert     TEST_info("%s_vector_%lu", fixture->case_name, (unsigned long)len);
198*e0c4386eSCy Schubert 
199*e0c4386eSCy Schubert     tail = fixture->last_blocks_correction(orig_vector, vector, len);
200*e0c4386eSCy Schubert 
201*e0c4386eSCy Schubert     /* test block-based encryption */
202*e0c4386eSCy Schubert     memcpy(iv, test_iv, test_iv_len);
203*e0c4386eSCy Schubert     if (!TEST_size_t_eq(fixture->encrypt_block(test_input, ciphertext, len,
204*e0c4386eSCy Schubert                                                encrypt_key_schedule, iv,
205*e0c4386eSCy Schubert                                                (block128_f)AES_encrypt), len)
206*e0c4386eSCy Schubert             || !TEST_mem_eq(ciphertext, len, vector, len)
207*e0c4386eSCy Schubert             || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv)))
208*e0c4386eSCy Schubert         return 0;
209*e0c4386eSCy Schubert 
210*e0c4386eSCy Schubert     /* test block-based decryption */
211*e0c4386eSCy Schubert     memcpy(iv, test_iv, test_iv_len);
212*e0c4386eSCy Schubert     size = fixture->decrypt_block(ciphertext, cleartext, len,
213*e0c4386eSCy Schubert                                   decrypt_key_schedule, iv,
214*e0c4386eSCy Schubert                                   (block128_f)AES_decrypt);
215*e0c4386eSCy Schubert     if (!TEST_true(len == size || len + 16 == size)
216*e0c4386eSCy Schubert             || !TEST_mem_eq(cleartext, len, test_input, len)
217*e0c4386eSCy Schubert             || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv)))
218*e0c4386eSCy Schubert         return 0;
219*e0c4386eSCy Schubert 
220*e0c4386eSCy Schubert     /* test streamed encryption */
221*e0c4386eSCy Schubert     memcpy(iv, test_iv, test_iv_len);
222*e0c4386eSCy Schubert     if (!TEST_size_t_eq(fixture->encrypt_stream(test_input, ciphertext, len,
223*e0c4386eSCy Schubert                                                 encrypt_key_schedule, iv,
224*e0c4386eSCy Schubert                                                 (cbc128_f) AES_cbc_encrypt),
225*e0c4386eSCy Schubert                         len)
226*e0c4386eSCy Schubert             || !TEST_mem_eq(ciphertext, len, vector, len)
227*e0c4386eSCy Schubert             || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv)))
228*e0c4386eSCy Schubert         return 0;
229*e0c4386eSCy Schubert 
230*e0c4386eSCy Schubert     /* test streamed decryption */
231*e0c4386eSCy Schubert     memcpy(iv, test_iv, test_iv_len);
232*e0c4386eSCy Schubert     if (!TEST_size_t_eq(fixture->decrypt_stream(ciphertext, cleartext, len,
233*e0c4386eSCy Schubert                                                 decrypt_key_schedule, iv,
234*e0c4386eSCy Schubert                                                 (cbc128_f)AES_cbc_encrypt),
235*e0c4386eSCy Schubert                         len)
236*e0c4386eSCy Schubert             || !TEST_mem_eq(cleartext, len, test_input, len)
237*e0c4386eSCy Schubert             || !TEST_mem_eq(iv, sizeof(iv), vector + len - tail, sizeof(iv)))
238*e0c4386eSCy Schubert         return 0;
239*e0c4386eSCy Schubert 
240*e0c4386eSCy Schubert     return 1;
241*e0c4386eSCy Schubert }
242*e0c4386eSCy Schubert 
test_aes_cts128(int idx)243*e0c4386eSCy Schubert static int test_aes_cts128(int idx)
244*e0c4386eSCy Schubert {
245*e0c4386eSCy Schubert     static const CTS128_FIXTURE fixture_cts128 = {
246*e0c4386eSCy Schubert         "aes_cts128", last_blocks_correction,
247*e0c4386eSCy Schubert         CRYPTO_cts128_encrypt_block, CRYPTO_cts128_encrypt,
248*e0c4386eSCy Schubert         CRYPTO_cts128_decrypt_block, CRYPTO_cts128_decrypt
249*e0c4386eSCy Schubert     };
250*e0c4386eSCy Schubert 
251*e0c4386eSCy Schubert     return execute_cts128(&fixture_cts128, idx);
252*e0c4386eSCy Schubert }
253*e0c4386eSCy Schubert 
test_aes_cts128_nist(int idx)254*e0c4386eSCy Schubert static int test_aes_cts128_nist(int idx)
255*e0c4386eSCy Schubert {
256*e0c4386eSCy Schubert     static const CTS128_FIXTURE fixture_cts128_nist = {
257*e0c4386eSCy Schubert         "aes_cts128_nist", last_blocks_correction_nist,
258*e0c4386eSCy Schubert         CRYPTO_nistcts128_encrypt_block, CRYPTO_nistcts128_encrypt,
259*e0c4386eSCy Schubert         CRYPTO_nistcts128_decrypt_block, CRYPTO_nistcts128_decrypt
260*e0c4386eSCy Schubert     };
261*e0c4386eSCy Schubert 
262*e0c4386eSCy Schubert     return execute_cts128(&fixture_cts128_nist, idx);
263*e0c4386eSCy Schubert }
264*e0c4386eSCy Schubert 
265*e0c4386eSCy Schubert /*
266*e0c4386eSCy Schubert  *
267*e0c4386eSCy Schubert  * Test of gcm128
268*e0c4386eSCy Schubert  *
269*e0c4386eSCy Schubert  */
270*e0c4386eSCy Schubert 
271*e0c4386eSCy Schubert /* Test Case 1 */
272*e0c4386eSCy Schubert static const u8 K1[16], P1[] = { 0 }, A1[] = { 0 }, IV1[12], C1[] = { 0 };
273*e0c4386eSCy Schubert static const u8 T1[] = {
274*e0c4386eSCy Schubert     0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
275*e0c4386eSCy Schubert     0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a
276*e0c4386eSCy Schubert };
277*e0c4386eSCy Schubert 
278*e0c4386eSCy Schubert /* Test Case 2 */
279*e0c4386eSCy Schubert # define K2 K1
280*e0c4386eSCy Schubert # define A2 A1
281*e0c4386eSCy Schubert # define IV2 IV1
282*e0c4386eSCy Schubert static const u8 P2[16];
283*e0c4386eSCy Schubert static const u8 C2[] = {
284*e0c4386eSCy Schubert     0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
285*e0c4386eSCy Schubert     0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78
286*e0c4386eSCy Schubert };
287*e0c4386eSCy Schubert 
288*e0c4386eSCy Schubert static const u8 T2[] = {
289*e0c4386eSCy Schubert     0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
290*e0c4386eSCy Schubert     0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf
291*e0c4386eSCy Schubert };
292*e0c4386eSCy Schubert 
293*e0c4386eSCy Schubert /* Test Case 3 */
294*e0c4386eSCy Schubert # define A3 A2
295*e0c4386eSCy Schubert static const u8 K3[] = {
296*e0c4386eSCy Schubert     0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
297*e0c4386eSCy Schubert     0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
298*e0c4386eSCy Schubert };
299*e0c4386eSCy Schubert 
300*e0c4386eSCy Schubert static const u8 P3[] = {
301*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
302*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
303*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
304*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
305*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
306*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
307*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
308*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
309*e0c4386eSCy Schubert };
310*e0c4386eSCy Schubert 
311*e0c4386eSCy Schubert static const u8 IV3[] = {
312*e0c4386eSCy Schubert     0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
313*e0c4386eSCy Schubert     0xde, 0xca, 0xf8, 0x88
314*e0c4386eSCy Schubert };
315*e0c4386eSCy Schubert 
316*e0c4386eSCy Schubert static const u8 C3[] = {
317*e0c4386eSCy Schubert     0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
318*e0c4386eSCy Schubert     0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
319*e0c4386eSCy Schubert     0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
320*e0c4386eSCy Schubert     0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
321*e0c4386eSCy Schubert     0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
322*e0c4386eSCy Schubert     0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
323*e0c4386eSCy Schubert     0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
324*e0c4386eSCy Schubert     0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
325*e0c4386eSCy Schubert };
326*e0c4386eSCy Schubert 
327*e0c4386eSCy Schubert static const u8 T3[] = {
328*e0c4386eSCy Schubert     0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
329*e0c4386eSCy Schubert     0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4
330*e0c4386eSCy Schubert };
331*e0c4386eSCy Schubert 
332*e0c4386eSCy Schubert /* Test Case 4 */
333*e0c4386eSCy Schubert # define K4 K3
334*e0c4386eSCy Schubert # define IV4 IV3
335*e0c4386eSCy Schubert static const u8 P4[] = {
336*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
337*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
338*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
339*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
340*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
341*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
342*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
343*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39
344*e0c4386eSCy Schubert };
345*e0c4386eSCy Schubert 
346*e0c4386eSCy Schubert static const u8 A4[] = {
347*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
348*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
349*e0c4386eSCy Schubert     0xab, 0xad, 0xda, 0xd2
350*e0c4386eSCy Schubert };
351*e0c4386eSCy Schubert 
352*e0c4386eSCy Schubert static const u8 C4[] = {
353*e0c4386eSCy Schubert     0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
354*e0c4386eSCy Schubert     0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
355*e0c4386eSCy Schubert     0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
356*e0c4386eSCy Schubert     0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
357*e0c4386eSCy Schubert     0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
358*e0c4386eSCy Schubert     0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
359*e0c4386eSCy Schubert     0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
360*e0c4386eSCy Schubert     0x3d, 0x58, 0xe0, 0x91
361*e0c4386eSCy Schubert };
362*e0c4386eSCy Schubert 
363*e0c4386eSCy Schubert static const u8 T4[] = {
364*e0c4386eSCy Schubert     0x5b, 0xc9, 0x4f, 0xbc, 0x32, 0x21, 0xa5, 0xdb,
365*e0c4386eSCy Schubert     0x94, 0xfa, 0xe9, 0x5a, 0xe7, 0x12, 0x1a, 0x47
366*e0c4386eSCy Schubert };
367*e0c4386eSCy Schubert 
368*e0c4386eSCy Schubert /* Test Case 5 */
369*e0c4386eSCy Schubert # define K5 K4
370*e0c4386eSCy Schubert # define P5 P4
371*e0c4386eSCy Schubert # define A5 A4
372*e0c4386eSCy Schubert static const u8 IV5[] = {
373*e0c4386eSCy Schubert     0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad
374*e0c4386eSCy Schubert };
375*e0c4386eSCy Schubert 
376*e0c4386eSCy Schubert static const u8 C5[] = {
377*e0c4386eSCy Schubert     0x61, 0x35, 0x3b, 0x4c, 0x28, 0x06, 0x93, 0x4a,
378*e0c4386eSCy Schubert     0x77, 0x7f, 0xf5, 0x1f, 0xa2, 0x2a, 0x47, 0x55,
379*e0c4386eSCy Schubert     0x69, 0x9b, 0x2a, 0x71, 0x4f, 0xcd, 0xc6, 0xf8,
380*e0c4386eSCy Schubert     0x37, 0x66, 0xe5, 0xf9, 0x7b, 0x6c, 0x74, 0x23,
381*e0c4386eSCy Schubert     0x73, 0x80, 0x69, 0x00, 0xe4, 0x9f, 0x24, 0xb2,
382*e0c4386eSCy Schubert     0x2b, 0x09, 0x75, 0x44, 0xd4, 0x89, 0x6b, 0x42,
383*e0c4386eSCy Schubert     0x49, 0x89, 0xb5, 0xe1, 0xeb, 0xac, 0x0f, 0x07,
384*e0c4386eSCy Schubert     0xc2, 0x3f, 0x45, 0x98
385*e0c4386eSCy Schubert };
386*e0c4386eSCy Schubert 
387*e0c4386eSCy Schubert static const u8 T5[] = {
388*e0c4386eSCy Schubert     0x36, 0x12, 0xd2, 0xe7, 0x9e, 0x3b, 0x07, 0x85,
389*e0c4386eSCy Schubert     0x56, 0x1b, 0xe1, 0x4a, 0xac, 0xa2, 0xfc, 0xcb
390*e0c4386eSCy Schubert };
391*e0c4386eSCy Schubert 
392*e0c4386eSCy Schubert /* Test Case 6 */
393*e0c4386eSCy Schubert # define K6 K5
394*e0c4386eSCy Schubert # define P6 P5
395*e0c4386eSCy Schubert # define A6 A5
396*e0c4386eSCy Schubert static const u8 IV6[] = {
397*e0c4386eSCy Schubert     0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
398*e0c4386eSCy Schubert     0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
399*e0c4386eSCy Schubert     0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
400*e0c4386eSCy Schubert     0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
401*e0c4386eSCy Schubert     0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
402*e0c4386eSCy Schubert     0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
403*e0c4386eSCy Schubert     0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
404*e0c4386eSCy Schubert     0xa6, 0x37, 0xb3, 0x9b
405*e0c4386eSCy Schubert };
406*e0c4386eSCy Schubert 
407*e0c4386eSCy Schubert static const u8 C6[] = {
408*e0c4386eSCy Schubert     0x8c, 0xe2, 0x49, 0x98, 0x62, 0x56, 0x15, 0xb6,
409*e0c4386eSCy Schubert     0x03, 0xa0, 0x33, 0xac, 0xa1, 0x3f, 0xb8, 0x94,
410*e0c4386eSCy Schubert     0xbe, 0x91, 0x12, 0xa5, 0xc3, 0xa2, 0x11, 0xa8,
411*e0c4386eSCy Schubert     0xba, 0x26, 0x2a, 0x3c, 0xca, 0x7e, 0x2c, 0xa7,
412*e0c4386eSCy Schubert     0x01, 0xe4, 0xa9, 0xa4, 0xfb, 0xa4, 0x3c, 0x90,
413*e0c4386eSCy Schubert     0xcc, 0xdc, 0xb2, 0x81, 0xd4, 0x8c, 0x7c, 0x6f,
414*e0c4386eSCy Schubert     0xd6, 0x28, 0x75, 0xd2, 0xac, 0xa4, 0x17, 0x03,
415*e0c4386eSCy Schubert     0x4c, 0x34, 0xae, 0xe5
416*e0c4386eSCy Schubert };
417*e0c4386eSCy Schubert 
418*e0c4386eSCy Schubert static const u8 T6[] = {
419*e0c4386eSCy Schubert     0x61, 0x9c, 0xc5, 0xae, 0xff, 0xfe, 0x0b, 0xfa,
420*e0c4386eSCy Schubert     0x46, 0x2a, 0xf4, 0x3c, 0x16, 0x99, 0xd0, 0x50
421*e0c4386eSCy Schubert };
422*e0c4386eSCy Schubert 
423*e0c4386eSCy Schubert /* Test Case 7 */
424*e0c4386eSCy Schubert static const u8 K7[24], P7[] = { 0 }, A7[] = { 0 }, IV7[12], C7[] = { 0 };
425*e0c4386eSCy Schubert static const u8 T7[] = {
426*e0c4386eSCy Schubert     0xcd, 0x33, 0xb2, 0x8a, 0xc7, 0x73, 0xf7, 0x4b,
427*e0c4386eSCy Schubert     0xa0, 0x0e, 0xd1, 0xf3, 0x12, 0x57, 0x24, 0x35
428*e0c4386eSCy Schubert };
429*e0c4386eSCy Schubert 
430*e0c4386eSCy Schubert /* Test Case 8 */
431*e0c4386eSCy Schubert # define K8 K7
432*e0c4386eSCy Schubert # define IV8 IV7
433*e0c4386eSCy Schubert # define A8 A7
434*e0c4386eSCy Schubert static const u8 P8[16];
435*e0c4386eSCy Schubert static const u8 C8[] = {
436*e0c4386eSCy Schubert     0x98, 0xe7, 0x24, 0x7c, 0x07, 0xf0, 0xfe, 0x41,
437*e0c4386eSCy Schubert     0x1c, 0x26, 0x7e, 0x43, 0x84, 0xb0, 0xf6, 0x00
438*e0c4386eSCy Schubert };
439*e0c4386eSCy Schubert 
440*e0c4386eSCy Schubert static const u8 T8[] = {
441*e0c4386eSCy Schubert     0x2f, 0xf5, 0x8d, 0x80, 0x03, 0x39, 0x27, 0xab,
442*e0c4386eSCy Schubert     0x8e, 0xf4, 0xd4, 0x58, 0x75, 0x14, 0xf0, 0xfb
443*e0c4386eSCy Schubert };
444*e0c4386eSCy Schubert 
445*e0c4386eSCy Schubert /* Test Case 9 */
446*e0c4386eSCy Schubert # define A9 A8
447*e0c4386eSCy Schubert static const u8 K9[] = {
448*e0c4386eSCy Schubert     0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
449*e0c4386eSCy Schubert     0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
450*e0c4386eSCy Schubert     0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c
451*e0c4386eSCy Schubert };
452*e0c4386eSCy Schubert 
453*e0c4386eSCy Schubert static const u8 P9[] = {
454*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
455*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
456*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
457*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
458*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
459*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
460*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
461*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
462*e0c4386eSCy Schubert };
463*e0c4386eSCy Schubert 
464*e0c4386eSCy Schubert static const u8 IV9[] = {
465*e0c4386eSCy Schubert     0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
466*e0c4386eSCy Schubert     0xde, 0xca, 0xf8, 0x88
467*e0c4386eSCy Schubert };
468*e0c4386eSCy Schubert 
469*e0c4386eSCy Schubert static const u8 C9[] = {
470*e0c4386eSCy Schubert     0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
471*e0c4386eSCy Schubert     0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
472*e0c4386eSCy Schubert     0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
473*e0c4386eSCy Schubert     0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
474*e0c4386eSCy Schubert     0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
475*e0c4386eSCy Schubert     0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
476*e0c4386eSCy Schubert     0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
477*e0c4386eSCy Schubert     0xcc, 0xda, 0x27, 0x10, 0xac, 0xad, 0xe2, 0x56
478*e0c4386eSCy Schubert };
479*e0c4386eSCy Schubert 
480*e0c4386eSCy Schubert static const u8 T9[] = {
481*e0c4386eSCy Schubert     0x99, 0x24, 0xa7, 0xc8, 0x58, 0x73, 0x36, 0xbf,
482*e0c4386eSCy Schubert     0xb1, 0x18, 0x02, 0x4d, 0xb8, 0x67, 0x4a, 0x14
483*e0c4386eSCy Schubert };
484*e0c4386eSCy Schubert 
485*e0c4386eSCy Schubert /* Test Case 10 */
486*e0c4386eSCy Schubert # define K10 K9
487*e0c4386eSCy Schubert # define IV10 IV9
488*e0c4386eSCy Schubert static const u8 P10[] = {
489*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
490*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
491*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
492*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
493*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
494*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
495*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
496*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39
497*e0c4386eSCy Schubert };
498*e0c4386eSCy Schubert 
499*e0c4386eSCy Schubert static const u8 A10[] = {
500*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
501*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
502*e0c4386eSCy Schubert     0xab, 0xad, 0xda, 0xd2
503*e0c4386eSCy Schubert };
504*e0c4386eSCy Schubert 
505*e0c4386eSCy Schubert static const u8 C10[] = {
506*e0c4386eSCy Schubert     0x39, 0x80, 0xca, 0x0b, 0x3c, 0x00, 0xe8, 0x41,
507*e0c4386eSCy Schubert     0xeb, 0x06, 0xfa, 0xc4, 0x87, 0x2a, 0x27, 0x57,
508*e0c4386eSCy Schubert     0x85, 0x9e, 0x1c, 0xea, 0xa6, 0xef, 0xd9, 0x84,
509*e0c4386eSCy Schubert     0x62, 0x85, 0x93, 0xb4, 0x0c, 0xa1, 0xe1, 0x9c,
510*e0c4386eSCy Schubert     0x7d, 0x77, 0x3d, 0x00, 0xc1, 0x44, 0xc5, 0x25,
511*e0c4386eSCy Schubert     0xac, 0x61, 0x9d, 0x18, 0xc8, 0x4a, 0x3f, 0x47,
512*e0c4386eSCy Schubert     0x18, 0xe2, 0x44, 0x8b, 0x2f, 0xe3, 0x24, 0xd9,
513*e0c4386eSCy Schubert     0xcc, 0xda, 0x27, 0x10
514*e0c4386eSCy Schubert };
515*e0c4386eSCy Schubert 
516*e0c4386eSCy Schubert static const u8 T10[] = {
517*e0c4386eSCy Schubert     0x25, 0x19, 0x49, 0x8e, 0x80, 0xf1, 0x47, 0x8f,
518*e0c4386eSCy Schubert     0x37, 0xba, 0x55, 0xbd, 0x6d, 0x27, 0x61, 0x8c
519*e0c4386eSCy Schubert };
520*e0c4386eSCy Schubert 
521*e0c4386eSCy Schubert /* Test Case 11 */
522*e0c4386eSCy Schubert # define K11 K10
523*e0c4386eSCy Schubert # define P11 P10
524*e0c4386eSCy Schubert # define A11 A10
525*e0c4386eSCy Schubert static const u8 IV11[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
526*e0c4386eSCy Schubert 
527*e0c4386eSCy Schubert static const u8 C11[] = {
528*e0c4386eSCy Schubert     0x0f, 0x10, 0xf5, 0x99, 0xae, 0x14, 0xa1, 0x54,
529*e0c4386eSCy Schubert     0xed, 0x24, 0xb3, 0x6e, 0x25, 0x32, 0x4d, 0xb8,
530*e0c4386eSCy Schubert     0xc5, 0x66, 0x63, 0x2e, 0xf2, 0xbb, 0xb3, 0x4f,
531*e0c4386eSCy Schubert     0x83, 0x47, 0x28, 0x0f, 0xc4, 0x50, 0x70, 0x57,
532*e0c4386eSCy Schubert     0xfd, 0xdc, 0x29, 0xdf, 0x9a, 0x47, 0x1f, 0x75,
533*e0c4386eSCy Schubert     0xc6, 0x65, 0x41, 0xd4, 0xd4, 0xda, 0xd1, 0xc9,
534*e0c4386eSCy Schubert     0xe9, 0x3a, 0x19, 0xa5, 0x8e, 0x8b, 0x47, 0x3f,
535*e0c4386eSCy Schubert     0xa0, 0xf0, 0x62, 0xf7
536*e0c4386eSCy Schubert };
537*e0c4386eSCy Schubert 
538*e0c4386eSCy Schubert static const u8 T11[] = {
539*e0c4386eSCy Schubert     0x65, 0xdc, 0xc5, 0x7f, 0xcf, 0x62, 0x3a, 0x24,
540*e0c4386eSCy Schubert     0x09, 0x4f, 0xcc, 0xa4, 0x0d, 0x35, 0x33, 0xf8
541*e0c4386eSCy Schubert };
542*e0c4386eSCy Schubert 
543*e0c4386eSCy Schubert /* Test Case 12 */
544*e0c4386eSCy Schubert # define K12 K11
545*e0c4386eSCy Schubert # define P12 P11
546*e0c4386eSCy Schubert # define A12 A11
547*e0c4386eSCy Schubert static const u8 IV12[] = {
548*e0c4386eSCy Schubert     0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
549*e0c4386eSCy Schubert     0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
550*e0c4386eSCy Schubert     0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
551*e0c4386eSCy Schubert     0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
552*e0c4386eSCy Schubert     0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
553*e0c4386eSCy Schubert     0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
554*e0c4386eSCy Schubert     0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
555*e0c4386eSCy Schubert     0xa6, 0x37, 0xb3, 0x9b
556*e0c4386eSCy Schubert };
557*e0c4386eSCy Schubert 
558*e0c4386eSCy Schubert static const u8 C12[] = {
559*e0c4386eSCy Schubert     0xd2, 0x7e, 0x88, 0x68, 0x1c, 0xe3, 0x24, 0x3c,
560*e0c4386eSCy Schubert     0x48, 0x30, 0x16, 0x5a, 0x8f, 0xdc, 0xf9, 0xff,
561*e0c4386eSCy Schubert     0x1d, 0xe9, 0xa1, 0xd8, 0xe6, 0xb4, 0x47, 0xef,
562*e0c4386eSCy Schubert     0x6e, 0xf7, 0xb7, 0x98, 0x28, 0x66, 0x6e, 0x45,
563*e0c4386eSCy Schubert     0x81, 0xe7, 0x90, 0x12, 0xaf, 0x34, 0xdd, 0xd9,
564*e0c4386eSCy Schubert     0xe2, 0xf0, 0x37, 0x58, 0x9b, 0x29, 0x2d, 0xb3,
565*e0c4386eSCy Schubert     0xe6, 0x7c, 0x03, 0x67, 0x45, 0xfa, 0x22, 0xe7,
566*e0c4386eSCy Schubert     0xe9, 0xb7, 0x37, 0x3b
567*e0c4386eSCy Schubert };
568*e0c4386eSCy Schubert 
569*e0c4386eSCy Schubert static const u8 T12[] = {
570*e0c4386eSCy Schubert     0xdc, 0xf5, 0x66, 0xff, 0x29, 0x1c, 0x25, 0xbb,
571*e0c4386eSCy Schubert     0xb8, 0x56, 0x8f, 0xc3, 0xd3, 0x76, 0xa6, 0xd9
572*e0c4386eSCy Schubert };
573*e0c4386eSCy Schubert 
574*e0c4386eSCy Schubert /* Test Case 13 */
575*e0c4386eSCy Schubert static const u8 K13[32], P13[] = { 0 }, A13[] = { 0 }, IV13[12], C13[] = { 0 };
576*e0c4386eSCy Schubert static const u8 T13[] = {
577*e0c4386eSCy Schubert     0x53, 0x0f, 0x8a, 0xfb, 0xc7, 0x45, 0x36, 0xb9,
578*e0c4386eSCy Schubert     0xa9, 0x63, 0xb4, 0xf1, 0xc4, 0xcb, 0x73, 0x8b
579*e0c4386eSCy Schubert };
580*e0c4386eSCy Schubert 
581*e0c4386eSCy Schubert /* Test Case 14 */
582*e0c4386eSCy Schubert # define K14 K13
583*e0c4386eSCy Schubert # define A14 A13
584*e0c4386eSCy Schubert static const u8 P14[16], IV14[12];
585*e0c4386eSCy Schubert static const u8 C14[] = {
586*e0c4386eSCy Schubert     0xce, 0xa7, 0x40, 0x3d, 0x4d, 0x60, 0x6b, 0x6e,
587*e0c4386eSCy Schubert     0x07, 0x4e, 0xc5, 0xd3, 0xba, 0xf3, 0x9d, 0x18
588*e0c4386eSCy Schubert };
589*e0c4386eSCy Schubert 
590*e0c4386eSCy Schubert static const u8 T14[] = {
591*e0c4386eSCy Schubert     0xd0, 0xd1, 0xc8, 0xa7, 0x99, 0x99, 0x6b, 0xf0,
592*e0c4386eSCy Schubert     0x26, 0x5b, 0x98, 0xb5, 0xd4, 0x8a, 0xb9, 0x19
593*e0c4386eSCy Schubert };
594*e0c4386eSCy Schubert 
595*e0c4386eSCy Schubert /* Test Case 15 */
596*e0c4386eSCy Schubert # define A15 A14
597*e0c4386eSCy Schubert static const u8 K15[] = {
598*e0c4386eSCy Schubert     0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
599*e0c4386eSCy Schubert     0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08,
600*e0c4386eSCy Schubert     0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
601*e0c4386eSCy Schubert     0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
602*e0c4386eSCy Schubert };
603*e0c4386eSCy Schubert 
604*e0c4386eSCy Schubert static const u8 P15[] = {
605*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
606*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
607*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
608*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
609*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
610*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
611*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
612*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55
613*e0c4386eSCy Schubert };
614*e0c4386eSCy Schubert 
615*e0c4386eSCy Schubert static const u8 IV15[] = {
616*e0c4386eSCy Schubert     0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
617*e0c4386eSCy Schubert     0xde, 0xca, 0xf8, 0x88
618*e0c4386eSCy Schubert };
619*e0c4386eSCy Schubert 
620*e0c4386eSCy Schubert static const u8 C15[] = {
621*e0c4386eSCy Schubert     0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
622*e0c4386eSCy Schubert     0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
623*e0c4386eSCy Schubert     0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
624*e0c4386eSCy Schubert     0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
625*e0c4386eSCy Schubert     0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
626*e0c4386eSCy Schubert     0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
627*e0c4386eSCy Schubert     0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
628*e0c4386eSCy Schubert     0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
629*e0c4386eSCy Schubert };
630*e0c4386eSCy Schubert 
631*e0c4386eSCy Schubert static const u8 T15[] = {
632*e0c4386eSCy Schubert     0xb0, 0x94, 0xda, 0xc5, 0xd9, 0x34, 0x71, 0xbd,
633*e0c4386eSCy Schubert     0xec, 0x1a, 0x50, 0x22, 0x70, 0xe3, 0xcc, 0x6c
634*e0c4386eSCy Schubert };
635*e0c4386eSCy Schubert 
636*e0c4386eSCy Schubert /* Test Case 16 */
637*e0c4386eSCy Schubert # define K16 K15
638*e0c4386eSCy Schubert # define IV16 IV15
639*e0c4386eSCy Schubert static const u8 P16[] = {
640*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
641*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
642*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
643*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
644*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
645*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
646*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
647*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39
648*e0c4386eSCy Schubert };
649*e0c4386eSCy Schubert 
650*e0c4386eSCy Schubert static const u8 A16[] = {
651*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
652*e0c4386eSCy Schubert     0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
653*e0c4386eSCy Schubert     0xab, 0xad, 0xda, 0xd2
654*e0c4386eSCy Schubert };
655*e0c4386eSCy Schubert 
656*e0c4386eSCy Schubert static const u8 C16[] = {
657*e0c4386eSCy Schubert     0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
658*e0c4386eSCy Schubert     0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
659*e0c4386eSCy Schubert     0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
660*e0c4386eSCy Schubert     0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
661*e0c4386eSCy Schubert     0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
662*e0c4386eSCy Schubert     0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
663*e0c4386eSCy Schubert     0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
664*e0c4386eSCy Schubert     0xbc, 0xc9, 0xf6, 0x62
665*e0c4386eSCy Schubert };
666*e0c4386eSCy Schubert 
667*e0c4386eSCy Schubert static const u8 T16[] = {
668*e0c4386eSCy Schubert     0x76, 0xfc, 0x6e, 0xce, 0x0f, 0x4e, 0x17, 0x68,
669*e0c4386eSCy Schubert     0xcd, 0xdf, 0x88, 0x53, 0xbb, 0x2d, 0x55, 0x1b
670*e0c4386eSCy Schubert };
671*e0c4386eSCy Schubert 
672*e0c4386eSCy Schubert /* Test Case 17 */
673*e0c4386eSCy Schubert # define K17 K16
674*e0c4386eSCy Schubert # define P17 P16
675*e0c4386eSCy Schubert # define A17 A16
676*e0c4386eSCy Schubert static const u8 IV17[] = { 0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad };
677*e0c4386eSCy Schubert 
678*e0c4386eSCy Schubert static const u8 C17[] = {
679*e0c4386eSCy Schubert     0xc3, 0x76, 0x2d, 0xf1, 0xca, 0x78, 0x7d, 0x32,
680*e0c4386eSCy Schubert     0xae, 0x47, 0xc1, 0x3b, 0xf1, 0x98, 0x44, 0xcb,
681*e0c4386eSCy Schubert     0xaf, 0x1a, 0xe1, 0x4d, 0x0b, 0x97, 0x6a, 0xfa,
682*e0c4386eSCy Schubert     0xc5, 0x2f, 0xf7, 0xd7, 0x9b, 0xba, 0x9d, 0xe0,
683*e0c4386eSCy Schubert     0xfe, 0xb5, 0x82, 0xd3, 0x39, 0x34, 0xa4, 0xf0,
684*e0c4386eSCy Schubert     0x95, 0x4c, 0xc2, 0x36, 0x3b, 0xc7, 0x3f, 0x78,
685*e0c4386eSCy Schubert     0x62, 0xac, 0x43, 0x0e, 0x64, 0xab, 0xe4, 0x99,
686*e0c4386eSCy Schubert     0xf4, 0x7c, 0x9b, 0x1f
687*e0c4386eSCy Schubert };
688*e0c4386eSCy Schubert 
689*e0c4386eSCy Schubert static const u8 T17[] = {
690*e0c4386eSCy Schubert     0x3a, 0x33, 0x7d, 0xbf, 0x46, 0xa7, 0x92, 0xc4,
691*e0c4386eSCy Schubert     0x5e, 0x45, 0x49, 0x13, 0xfe, 0x2e, 0xa8, 0xf2
692*e0c4386eSCy Schubert };
693*e0c4386eSCy Schubert 
694*e0c4386eSCy Schubert /* Test Case 18 */
695*e0c4386eSCy Schubert # define K18 K17
696*e0c4386eSCy Schubert # define P18 P17
697*e0c4386eSCy Schubert # define A18 A17
698*e0c4386eSCy Schubert static const u8 IV18[] = {
699*e0c4386eSCy Schubert     0x93, 0x13, 0x22, 0x5d, 0xf8, 0x84, 0x06, 0xe5,
700*e0c4386eSCy Schubert     0x55, 0x90, 0x9c, 0x5a, 0xff, 0x52, 0x69, 0xaa,
701*e0c4386eSCy Schubert     0x6a, 0x7a, 0x95, 0x38, 0x53, 0x4f, 0x7d, 0xa1,
702*e0c4386eSCy Schubert     0xe4, 0xc3, 0x03, 0xd2, 0xa3, 0x18, 0xa7, 0x28,
703*e0c4386eSCy Schubert     0xc3, 0xc0, 0xc9, 0x51, 0x56, 0x80, 0x95, 0x39,
704*e0c4386eSCy Schubert     0xfc, 0xf0, 0xe2, 0x42, 0x9a, 0x6b, 0x52, 0x54,
705*e0c4386eSCy Schubert     0x16, 0xae, 0xdb, 0xf5, 0xa0, 0xde, 0x6a, 0x57,
706*e0c4386eSCy Schubert     0xa6, 0x37, 0xb3, 0x9b
707*e0c4386eSCy Schubert };
708*e0c4386eSCy Schubert 
709*e0c4386eSCy Schubert static const u8 C18[] = {
710*e0c4386eSCy Schubert     0x5a, 0x8d, 0xef, 0x2f, 0x0c, 0x9e, 0x53, 0xf1,
711*e0c4386eSCy Schubert     0xf7, 0x5d, 0x78, 0x53, 0x65, 0x9e, 0x2a, 0x20,
712*e0c4386eSCy Schubert     0xee, 0xb2, 0xb2, 0x2a, 0xaf, 0xde, 0x64, 0x19,
713*e0c4386eSCy Schubert     0xa0, 0x58, 0xab, 0x4f, 0x6f, 0x74, 0x6b, 0xf4,
714*e0c4386eSCy Schubert     0x0f, 0xc0, 0xc3, 0xb7, 0x80, 0xf2, 0x44, 0x45,
715*e0c4386eSCy Schubert     0x2d, 0xa3, 0xeb, 0xf1, 0xc5, 0xd8, 0x2c, 0xde,
716*e0c4386eSCy Schubert     0xa2, 0x41, 0x89, 0x97, 0x20, 0x0e, 0xf8, 0x2e,
717*e0c4386eSCy Schubert     0x44, 0xae, 0x7e, 0x3f
718*e0c4386eSCy Schubert };
719*e0c4386eSCy Schubert 
720*e0c4386eSCy Schubert static const u8 T18[] = {
721*e0c4386eSCy Schubert     0xa4, 0x4a, 0x82, 0x66, 0xee, 0x1c, 0x8e, 0xb0,
722*e0c4386eSCy Schubert     0xc8, 0xb5, 0xd4, 0xcf, 0x5a, 0xe9, 0xf1, 0x9a
723*e0c4386eSCy Schubert };
724*e0c4386eSCy Schubert 
725*e0c4386eSCy Schubert /* Test Case 19 */
726*e0c4386eSCy Schubert # define K19 K1
727*e0c4386eSCy Schubert # define P19 P1
728*e0c4386eSCy Schubert # define IV19 IV1
729*e0c4386eSCy Schubert # define C19 C1
730*e0c4386eSCy Schubert static const u8 A19[] = {
731*e0c4386eSCy Schubert     0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
732*e0c4386eSCy Schubert     0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
733*e0c4386eSCy Schubert     0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
734*e0c4386eSCy Schubert     0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
735*e0c4386eSCy Schubert     0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
736*e0c4386eSCy Schubert     0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
737*e0c4386eSCy Schubert     0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
738*e0c4386eSCy Schubert     0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55,
739*e0c4386eSCy Schubert     0x52, 0x2d, 0xc1, 0xf0, 0x99, 0x56, 0x7d, 0x07,
740*e0c4386eSCy Schubert     0xf4, 0x7f, 0x37, 0xa3, 0x2a, 0x84, 0x42, 0x7d,
741*e0c4386eSCy Schubert     0x64, 0x3a, 0x8c, 0xdc, 0xbf, 0xe5, 0xc0, 0xc9,
742*e0c4386eSCy Schubert     0x75, 0x98, 0xa2, 0xbd, 0x25, 0x55, 0xd1, 0xaa,
743*e0c4386eSCy Schubert     0x8c, 0xb0, 0x8e, 0x48, 0x59, 0x0d, 0xbb, 0x3d,
744*e0c4386eSCy Schubert     0xa7, 0xb0, 0x8b, 0x10, 0x56, 0x82, 0x88, 0x38,
745*e0c4386eSCy Schubert     0xc5, 0xf6, 0x1e, 0x63, 0x93, 0xba, 0x7a, 0x0a,
746*e0c4386eSCy Schubert     0xbc, 0xc9, 0xf6, 0x62, 0x89, 0x80, 0x15, 0xad
747*e0c4386eSCy Schubert };
748*e0c4386eSCy Schubert 
749*e0c4386eSCy Schubert static const u8 T19[] = {
750*e0c4386eSCy Schubert     0x5f, 0xea, 0x79, 0x3a, 0x2d, 0x6f, 0x97, 0x4d,
751*e0c4386eSCy Schubert     0x37, 0xe6, 0x8e, 0x0c, 0xb8, 0xff, 0x94, 0x92
752*e0c4386eSCy Schubert };
753*e0c4386eSCy Schubert 
754*e0c4386eSCy Schubert /* Test Case 20 */
755*e0c4386eSCy Schubert # define K20 K1
756*e0c4386eSCy Schubert # define A20 A1
757*e0c4386eSCy Schubert /* this results in 0xff in counter LSB */
758*e0c4386eSCy Schubert static const u8 IV20[64] = { 0xff, 0xff, 0xff, 0xff };
759*e0c4386eSCy Schubert 
760*e0c4386eSCy Schubert static const u8 P20[288];
761*e0c4386eSCy Schubert static const u8 C20[] = {
762*e0c4386eSCy Schubert     0x56, 0xb3, 0x37, 0x3c, 0xa9, 0xef, 0x6e, 0x4a,
763*e0c4386eSCy Schubert     0x2b, 0x64, 0xfe, 0x1e, 0x9a, 0x17, 0xb6, 0x14,
764*e0c4386eSCy Schubert     0x25, 0xf1, 0x0d, 0x47, 0xa7, 0x5a, 0x5f, 0xce,
765*e0c4386eSCy Schubert     0x13, 0xef, 0xc6, 0xbc, 0x78, 0x4a, 0xf2, 0x4f,
766*e0c4386eSCy Schubert     0x41, 0x41, 0xbd, 0xd4, 0x8c, 0xf7, 0xc7, 0x70,
767*e0c4386eSCy Schubert     0x88, 0x7a, 0xfd, 0x57, 0x3c, 0xca, 0x54, 0x18,
768*e0c4386eSCy Schubert     0xa9, 0xae, 0xff, 0xcd, 0x7c, 0x5c, 0xed, 0xdf,
769*e0c4386eSCy Schubert     0xc6, 0xa7, 0x83, 0x97, 0xb9, 0xa8, 0x5b, 0x49,
770*e0c4386eSCy Schubert     0x9d, 0xa5, 0x58, 0x25, 0x72, 0x67, 0xca, 0xab,
771*e0c4386eSCy Schubert     0x2a, 0xd0, 0xb2, 0x3c, 0xa4, 0x76, 0xa5, 0x3c,
772*e0c4386eSCy Schubert     0xb1, 0x7f, 0xb4, 0x1c, 0x4b, 0x8b, 0x47, 0x5c,
773*e0c4386eSCy Schubert     0xb4, 0xf3, 0xf7, 0x16, 0x50, 0x94, 0xc2, 0x29,
774*e0c4386eSCy Schubert     0xc9, 0xe8, 0xc4, 0xdc, 0x0a, 0x2a, 0x5f, 0xf1,
775*e0c4386eSCy Schubert     0x90, 0x3e, 0x50, 0x15, 0x11, 0x22, 0x13, 0x76,
776*e0c4386eSCy Schubert     0xa1, 0xcd, 0xb8, 0x36, 0x4c, 0x50, 0x61, 0xa2,
777*e0c4386eSCy Schubert     0x0c, 0xae, 0x74, 0xbc, 0x4a, 0xcd, 0x76, 0xce,
778*e0c4386eSCy Schubert     0xb0, 0xab, 0xc9, 0xfd, 0x32, 0x17, 0xef, 0x9f,
779*e0c4386eSCy Schubert     0x8c, 0x90, 0xbe, 0x40, 0x2d, 0xdf, 0x6d, 0x86,
780*e0c4386eSCy Schubert     0x97, 0xf4, 0xf8, 0x80, 0xdf, 0xf1, 0x5b, 0xfb,
781*e0c4386eSCy Schubert     0x7a, 0x6b, 0x28, 0x24, 0x1e, 0xc8, 0xfe, 0x18,
782*e0c4386eSCy Schubert     0x3c, 0x2d, 0x59, 0xe3, 0xf9, 0xdf, 0xff, 0x65,
783*e0c4386eSCy Schubert     0x3c, 0x71, 0x26, 0xf0, 0xac, 0xb9, 0xe6, 0x42,
784*e0c4386eSCy Schubert     0x11, 0xf4, 0x2b, 0xae, 0x12, 0xaf, 0x46, 0x2b,
785*e0c4386eSCy Schubert     0x10, 0x70, 0xbe, 0xf1, 0xab, 0x5e, 0x36, 0x06,
786*e0c4386eSCy Schubert     0x87, 0x2c, 0xa1, 0x0d, 0xee, 0x15, 0xb3, 0x24,
787*e0c4386eSCy Schubert     0x9b, 0x1a, 0x1b, 0x95, 0x8f, 0x23, 0x13, 0x4c,
788*e0c4386eSCy Schubert     0x4b, 0xcc, 0xb7, 0xd0, 0x32, 0x00, 0xbc, 0xe4,
789*e0c4386eSCy Schubert     0x20, 0xa2, 0xf8, 0xeb, 0x66, 0xdc, 0xf3, 0x64,
790*e0c4386eSCy Schubert     0x4d, 0x14, 0x23, 0xc1, 0xb5, 0x69, 0x90, 0x03,
791*e0c4386eSCy Schubert     0xc1, 0x3e, 0xce, 0xf4, 0xbf, 0x38, 0xa3, 0xb6,
792*e0c4386eSCy Schubert     0x0e, 0xed, 0xc3, 0x40, 0x33, 0xba, 0xc1, 0x90,
793*e0c4386eSCy Schubert     0x27, 0x83, 0xdc, 0x6d, 0x89, 0xe2, 0xe7, 0x74,
794*e0c4386eSCy Schubert     0x18, 0x8a, 0x43, 0x9c, 0x7e, 0xbc, 0xc0, 0x67,
795*e0c4386eSCy Schubert     0x2d, 0xbd, 0xa4, 0xdd, 0xcf, 0xb2, 0x79, 0x46,
796*e0c4386eSCy Schubert     0x13, 0xb0, 0xbe, 0x41, 0x31, 0x5e, 0xf7, 0x78,
797*e0c4386eSCy Schubert     0x70, 0x8a, 0x70, 0xee, 0x7d, 0x75, 0x16, 0x5c
798*e0c4386eSCy Schubert };
799*e0c4386eSCy Schubert 
800*e0c4386eSCy Schubert static const u8 T20[] = {
801*e0c4386eSCy Schubert     0x8b, 0x30, 0x7f, 0x6b, 0x33, 0x28, 0x6d, 0x0a,
802*e0c4386eSCy Schubert     0xb0, 0x26, 0xa9, 0xed, 0x3f, 0xe1, 0xe8, 0x5f
803*e0c4386eSCy Schubert };
804*e0c4386eSCy Schubert 
805*e0c4386eSCy Schubert #define GCM128_TEST_VECTOR(n)                   \
806*e0c4386eSCy Schubert     {                                           \
807*e0c4386eSCy Schubert         {sizeof(K##n), K##n},                   \
808*e0c4386eSCy Schubert         {sizeof(IV##n), IV##n},                 \
809*e0c4386eSCy Schubert         {sizeof(A##n), A##n},                   \
810*e0c4386eSCy Schubert         {sizeof(P##n), P##n},                   \
811*e0c4386eSCy Schubert         {sizeof(C##n), C##n},                   \
812*e0c4386eSCy Schubert         {sizeof(T##n), T##n}                    \
813*e0c4386eSCy Schubert     }
814*e0c4386eSCy Schubert static struct gcm128_data {
815*e0c4386eSCy Schubert     const SIZED_DATA K;
816*e0c4386eSCy Schubert     const SIZED_DATA IV;
817*e0c4386eSCy Schubert     const SIZED_DATA A;
818*e0c4386eSCy Schubert     const SIZED_DATA P;
819*e0c4386eSCy Schubert     const SIZED_DATA C;
820*e0c4386eSCy Schubert     const SIZED_DATA T;
821*e0c4386eSCy Schubert } gcm128_vectors[] = {
822*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(1),
823*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(2),
824*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(3),
825*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(4),
826*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(5),
827*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(6),
828*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(7),
829*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(8),
830*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(9),
831*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(10),
832*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(11),
833*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(12),
834*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(13),
835*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(14),
836*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(15),
837*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(16),
838*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(17),
839*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(18),
840*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(19),
841*e0c4386eSCy Schubert     GCM128_TEST_VECTOR(20)
842*e0c4386eSCy Schubert };
843*e0c4386eSCy Schubert 
test_gcm128(int idx)844*e0c4386eSCy Schubert static int test_gcm128(int idx)
845*e0c4386eSCy Schubert {
846*e0c4386eSCy Schubert     unsigned char out[512];
847*e0c4386eSCy Schubert     SIZED_DATA K = gcm128_vectors[idx].K;
848*e0c4386eSCy Schubert     SIZED_DATA IV = gcm128_vectors[idx].IV;
849*e0c4386eSCy Schubert     SIZED_DATA A = gcm128_vectors[idx].A;
850*e0c4386eSCy Schubert     SIZED_DATA P = gcm128_vectors[idx].P;
851*e0c4386eSCy Schubert     SIZED_DATA C = gcm128_vectors[idx].C;
852*e0c4386eSCy Schubert     SIZED_DATA T = gcm128_vectors[idx].T;
853*e0c4386eSCy Schubert     GCM128_CONTEXT ctx;
854*e0c4386eSCy Schubert     AES_KEY key;
855*e0c4386eSCy Schubert 
856*e0c4386eSCy Schubert     /* Size 1 inputs are special-cased to signal NULL. */
857*e0c4386eSCy Schubert     if (A.size == 1)
858*e0c4386eSCy Schubert         A.data = NULL;
859*e0c4386eSCy Schubert     if (P.size == 1)
860*e0c4386eSCy Schubert         P.data = NULL;
861*e0c4386eSCy Schubert     if (C.size == 1)
862*e0c4386eSCy Schubert         C.data = NULL;
863*e0c4386eSCy Schubert 
864*e0c4386eSCy Schubert     AES_set_encrypt_key(K.data, K.size * 8, &key);
865*e0c4386eSCy Schubert 
866*e0c4386eSCy Schubert     CRYPTO_gcm128_init(&ctx, &key, (block128_f)AES_encrypt);
867*e0c4386eSCy Schubert     CRYPTO_gcm128_setiv(&ctx, IV.data, IV.size);
868*e0c4386eSCy Schubert     memset(out, 0, P.size);
869*e0c4386eSCy Schubert     if (A.data != NULL)
870*e0c4386eSCy Schubert         CRYPTO_gcm128_aad(&ctx, A.data, A.size);
871*e0c4386eSCy Schubert     if (P.data != NULL)
872*e0c4386eSCy Schubert         if (!TEST_int_ge(CRYPTO_gcm128_encrypt( &ctx, P.data, out, P.size), 0))
873*e0c4386eSCy Schubert             return 0;
874*e0c4386eSCy Schubert     if (!TEST_false(CRYPTO_gcm128_finish(&ctx, T.data, 16))
875*e0c4386eSCy Schubert             || (C.data != NULL
876*e0c4386eSCy Schubert                     && !TEST_mem_eq(out, P.size, C.data, P.size)))
877*e0c4386eSCy Schubert         return 0;
878*e0c4386eSCy Schubert 
879*e0c4386eSCy Schubert     CRYPTO_gcm128_setiv(&ctx, IV.data, IV.size);
880*e0c4386eSCy Schubert     memset(out, 0, P.size);
881*e0c4386eSCy Schubert     if (A.data != NULL)
882*e0c4386eSCy Schubert         CRYPTO_gcm128_aad(&ctx, A.data, A.size);
883*e0c4386eSCy Schubert     if (C.data != NULL)
884*e0c4386eSCy Schubert         CRYPTO_gcm128_decrypt(&ctx, C.data, out, P.size);
885*e0c4386eSCy Schubert     if (!TEST_false(CRYPTO_gcm128_finish(&ctx, T.data, 16))
886*e0c4386eSCy Schubert             || (P.data != NULL
887*e0c4386eSCy Schubert                     && !TEST_mem_eq(out, P.size, P.data, P.size)))
888*e0c4386eSCy Schubert         return 0;
889*e0c4386eSCy Schubert 
890*e0c4386eSCy Schubert     return 1;
891*e0c4386eSCy Schubert }
892*e0c4386eSCy Schubert 
setup_tests(void)893*e0c4386eSCy Schubert int setup_tests(void)
894*e0c4386eSCy Schubert {
895*e0c4386eSCy Schubert     ADD_ALL_TESTS(test_aes_cts128, OSSL_NELEM(aes_cts128_vectors));
896*e0c4386eSCy Schubert     ADD_ALL_TESTS(test_aes_cts128_nist, OSSL_NELEM(aes_cts128_vectors));
897*e0c4386eSCy Schubert     ADD_ALL_TESTS(test_gcm128, OSSL_NELEM(gcm128_vectors));
898*e0c4386eSCy Schubert     return 1;
899*e0c4386eSCy Schubert }
900