Imported Upstream version 16.04
[deb_dpdk.git] / app / test / test_cryptodev_gcm_test_vectors.h
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2015 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *       * Redistributions of source code must retain the above copyright
11  *         notice, this list of conditions and the following disclaimer.
12  *       * Redistributions in binary form must reproduce the above copyright
13  *         notice, this list of conditions and the following disclaimer in
14  *         the documentation and/or other materials provided with the
15  *         distribution.
16  *       * Neither the name of Intel Corporation nor the names of its
17  *         contributors may be used to endorse or promote products derived
18  *         from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32
33 #ifndef TEST_CRYPTODEV_GCM_TEST_VECTORS_H_
34 #define TEST_CRYPTODEV_GCM_TEST_VECTORS_H_
35
36 struct gcm_test_data {
37         struct {
38                 uint8_t data[64];
39                 unsigned len;
40         } key;
41
42         struct {
43                 uint8_t data[64] __rte_aligned(16);
44                 unsigned len;
45         } iv;
46
47         struct {
48                 uint8_t data[64];
49                 unsigned len;
50         } aad;
51
52         struct {
53                 uint8_t data[1024];
54                 unsigned len;
55         } plaintext;
56
57         struct {
58                 uint8_t data[1024];
59                 unsigned len;
60         } ciphertext;
61
62         struct {
63                 uint8_t data[16];
64                 unsigned len;
65         } auth_tag;
66 };
67
68 /** AES-128 Test Vectors */
69 static const struct gcm_test_data gcm_test_case_1 = {
70         .key = {
71                 .data = {
72                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
73                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
74                 .len = 16
75         },
76         .iv = {
77                 .data = {
78                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
79                         0x00, 0x00, 0x00, 0x00 },
80                 .len = 12
81         },
82         .aad = {
83                 .data = { 0 },
84                 .len = 0
85         },
86         .plaintext = {
87                 .data = {
88                         0x00 },
89                 .len = 0
90         },
91         .ciphertext = {
92                 .data = {
93                         0x00
94                 },
95                 .len = 0
96         },
97         .auth_tag = {
98                 .data = {
99                         0x58, 0xe2, 0xfc, 0xce, 0xfa, 0x7e, 0x30, 0x61,
100                         0x36, 0x7f, 0x1d, 0x57, 0xa4, 0xe7, 0x45, 0x5a },
101                 .len = 16
102         }
103 };
104
105 /** AES-128 Test Vectors */
106 static const struct gcm_test_data gcm_test_case_2 = {
107         .key = {
108                 .data = {
109                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
110                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
111                 .len = 16
112         },
113         .iv = {
114                 .data = {
115                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
116                         0x00, 0x00, 0x00, 0x00 },
117                 .len = 12
118         },
119         .aad = {
120                 .data = { 0 },
121                 .len = 0
122         },
123         .plaintext = {
124                 .data = {
125                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
126                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
127                 .len = 16
128         },
129         .ciphertext = {
130                 .data = {
131                         0x03, 0x88, 0xda, 0xce, 0x60, 0xb6, 0xa3, 0x92,
132                         0xf3, 0x28, 0xc2, 0xb9, 0x71, 0xb2, 0xfe, 0x78 },
133                 .len = 16
134         },
135         .auth_tag = {
136                 .data = {
137                         0xab, 0x6e, 0x47, 0xd4, 0x2c, 0xec, 0x13, 0xbd,
138                         0xf5, 0x3a, 0x67, 0xb2, 0x12, 0x57, 0xbd, 0xdf },
139                 .len = 16
140         }
141 };
142
143 /** AES-128 Test Vectors */
144 static const struct gcm_test_data gcm_test_case_3 = {
145         .key = {
146                 .data = {
147                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
148                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08 },
149                 .len = 16
150         },
151         .iv = {
152                 .data = {
153                         0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
154                         0xde, 0xca, 0xf8, 0x88 },
155                 .len = 12
156         },
157         .aad = {
158                 .data = { 0 },
159                 .len = 0
160         },
161         .plaintext = {
162                 .data = {
163                         0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
164                         0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
165                         0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
166                         0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
167                         0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
168                         0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
169                         0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
170                         0xba, 0x63, 0x7b, 0x39, 0x1a, 0xaf, 0xd2, 0x55 },
171                 .len = 64
172         },
173         .ciphertext = {
174                 .data = {
175                         0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
176                         0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
177                         0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
178                         0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
179                         0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
180                         0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
181                         0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
182                         0x3d, 0x58, 0xe0, 0x91, 0x47, 0x3f, 0x59, 0x85
183                 },
184                 .len = 64
185         },
186         .auth_tag = {
187                 .data = {
188                         0x4d, 0x5c, 0x2a, 0xf3, 0x27, 0xcd, 0x64, 0xa6,
189                         0x2c, 0xf3, 0x5a, 0xbd, 0x2b, 0xa6, 0xfa, 0xb4 },
190                 .len = 16
191         }
192 };
193
194 /** AES-128 Test Vectors */
195 static const struct gcm_test_data gcm_test_case_4 = {
196         .key = {
197                 .data = {
198                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
199                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
200                 },
201                 .len = 16
202         },
203         .iv = {
204                 .data = {
205                         0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
206                         0xde, 0xca, 0xf8, 0x88 },
207                 .len = 12
208         },
209         .aad = {
210                 .data = {
211                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 },
212                 .len = 8
213         },
214         .plaintext = {
215                 .data = {
216                         0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
217                         0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
218                         0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
219                         0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
220                         0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
221                         0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
222                         0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
223                         0xba, 0x63, 0x7b, 0x39
224                 },
225                 .len = 60
226         },
227         .ciphertext = {
228                 .data = {
229                         0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
230                         0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
231                         0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
232                         0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
233                         0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
234                         0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
235                         0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
236                         0x3d, 0x58, 0xe0, 0x91
237                 },
238                 .len = 60
239         },
240         .auth_tag = {
241                 .data = {
242                         0xA2, 0xA4, 0x35, 0x75, 0xDC, 0xB0, 0x57, 0x74,
243                         0x07, 0x02, 0x30, 0xC2, 0xE7, 0x52, 0x02, 0x00
244                 },
245                 .len = 16
246         }
247
248 };
249
250 /** AES-128 Test Vectors */
251 static const struct gcm_test_data gcm_test_case_5 = {
252         .key = {
253                 .data = {
254                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
255                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
256                 },
257                 .len = 16
258         },
259         .iv = {
260                 .data = {
261                         0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
262                         0xde, 0xca, 0xf8, 0x88 },
263                 .len = 12
264         },
265         .aad = {
266                 .data = {
267                         0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef },
268                 .len = 8
269         },
270         .plaintext = {
271                 .data = {
272                         0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
273                         0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
274                         0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
275                         0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
276                         0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
277                         0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
278                         0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
279                         0xba, 0x63, 0x7b, 0x39
280                 },
281                 .len = 60
282         },
283         .ciphertext = {
284                 .data = {
285                         0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
286                         0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
287                         0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
288                         0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
289                         0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
290                         0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
291                         0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
292                         0x3d, 0x58, 0xe0, 0x91
293                 },
294                 .len = 60
295         },
296         .auth_tag = {
297                 .data = {
298                         0xC5, 0x2D, 0xFB, 0x54, 0xAF, 0xBB, 0x07, 0xA1,
299                         0x9A, 0xFF, 0xBE, 0xE0, 0x61, 0x4C, 0xE7, 0xA5
300                 },
301                 .len = 16
302         }
303
304 };
305
306 /** AES-128 Test Vectors */
307 static const struct gcm_test_data gcm_test_case_6 = {
308         .key = {
309                 .data = {
310                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
311                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
312                 },
313                 .len = 16
314         },
315         .iv = {
316                 .data = {
317                         0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
318                         0xde, 0xca, 0xf8, 0x88
319                 },
320                 .len = 12
321         },
322         .aad = {
323                 .data = {
324                         0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
325                         0x00, 0x00, 0x00, 0x00
326                 },
327                 .len = 12
328         },
329         .plaintext = {
330                 .data = {
331                         0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
332                         0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
333                         0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
334                         0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
335                         0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
336                         0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
337                         0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
338                         0xba, 0x63, 0x7b, 0x39
339                 },
340                 .len = 60
341         },
342         .ciphertext = {
343                 .data = {
344                         0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
345                         0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
346                         0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
347                         0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
348                         0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
349                         0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
350                         0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
351                         0x3d, 0x58, 0xe0, 0x91
352                 },
353                 .len = 60
354         },
355         .auth_tag = {
356                 .data = {
357                         0x74, 0xFC, 0xFA, 0x29, 0x3E, 0x60, 0xCC, 0x66,
358                         0x09, 0xD6, 0xFD, 0x00, 0xC8, 0x86, 0xD5, 0x42
359                 },
360                 .len = 16
361         }
362 };
363
364 /** AES-128 Test Vectors */
365 static const struct gcm_test_data gcm_test_case_7 = {
366         .key = {
367                 .data = {
368                         0xfe, 0xff, 0xe9, 0x92, 0x86, 0x65, 0x73, 0x1c,
369                         0x6d, 0x6a, 0x8f, 0x94, 0x67, 0x30, 0x83, 0x08
370                 },
371                 .len = 16
372         },
373         .iv = {
374                 .data = {
375                         0xca, 0xfe, 0xba, 0xbe, 0xfa, 0xce, 0xdb, 0xad,
376                         0xde, 0xca, 0xf8, 0x88
377                 },
378                 .len = 12
379         },
380         .aad = {
381                 .data = {
382                         0xfe, 0xed, 0xfa, 0xce, 0xde, 0xad, 0xbe, 0xef,
383                         0xfe, 0xed, 0xfa, 0xce
384                 },
385                 .len = 12
386         },
387         .plaintext = {
388                 .data = {
389                         0xd9, 0x31, 0x32, 0x25, 0xf8, 0x84, 0x06, 0xe5,
390                         0xa5, 0x59, 0x09, 0xc5, 0xaf, 0xf5, 0x26, 0x9a,
391                         0x86, 0xa7, 0xa9, 0x53, 0x15, 0x34, 0xf7, 0xda,
392                         0x2e, 0x4c, 0x30, 0x3d, 0x8a, 0x31, 0x8a, 0x72,
393                         0x1c, 0x3c, 0x0c, 0x95, 0x95, 0x68, 0x09, 0x53,
394                         0x2f, 0xcf, 0x0e, 0x24, 0x49, 0xa6, 0xb5, 0x25,
395                         0xb1, 0x6a, 0xed, 0xf5, 0xaa, 0x0d, 0xe6, 0x57,
396                         0xba, 0x63, 0x7b, 0x39
397                 },
398                 .len = 60
399         },
400         .ciphertext = {
401                 .data = {
402                         0x42, 0x83, 0x1e, 0xc2, 0x21, 0x77, 0x74, 0x24,
403                         0x4b, 0x72, 0x21, 0xb7, 0x84, 0xd0, 0xd4, 0x9c,
404                         0xe3, 0xaa, 0x21, 0x2f, 0x2c, 0x02, 0xa4, 0xe0,
405                         0x35, 0xc1, 0x7e, 0x23, 0x29, 0xac, 0xa1, 0x2e,
406                         0x21, 0xd5, 0x14, 0xb2, 0x54, 0x66, 0x93, 0x1c,
407                         0x7d, 0x8f, 0x6a, 0x5a, 0xac, 0x84, 0xaa, 0x05,
408                         0x1b, 0xa3, 0x0b, 0x39, 0x6a, 0x0a, 0xac, 0x97,
409                         0x3d, 0x58, 0xe0, 0x91
410                 },
411                 .len = 60
412         },
413         .auth_tag = {
414                 .data = {
415                         0xE9, 0xE4, 0xAB, 0x76, 0xB7, 0xFF, 0xEA, 0xDC,
416                         0x69, 0x79, 0x38, 0xA2, 0x0D, 0xCA, 0xF5, 0x92
417                 },
418                 .len = 16
419         }
420 };
421
422
423 #endif /* TEST_CRYPTODEV_GCM_TEST_VECTORS_H_ */