1/*-
2 *   BSD LICENSE
3 *
4 *   Copyright(c) 2016 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_ZUC_HASH_TEST_VECTORS_H_
34#define TEST_CRYPTODEV_ZUC_HASH_TEST_VECTORS_H_
35
36struct zuc_hash_test_data {
37	struct {
38		uint8_t data[64];
39		unsigned len;
40	} key;
41
42	struct {
43		uint8_t data[64];
44		unsigned len;
45	} aad;
46
47	struct {
48		uint8_t data[2056];
49		unsigned len; /* length must be in Bits */
50	} plaintext;
51
52	struct {
53		unsigned len;
54	} validAuthLenInBits;
55
56	struct {
57		unsigned len;
58	} validAuthOffsetLenInBits;
59
60	struct {
61		uint8_t data[64];
62		unsigned len;
63	} digest;
64};
65
66struct zuc_hash_test_data zuc_hash_test_case_1 = {
67	.key = {
68		.data = {
69			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
70			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
71		},
72		.len = 16
73	},
74	.aad = {
75		.data = {
76			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
77			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
78		},
79		.len = 16
80	},
81	.plaintext = {
82		.data = {0x00},
83		.len = 8
84	},
85	.validAuthLenInBits = {
86		.len = 1
87	},
88	.validAuthOffsetLenInBits = {
89		.len = 128
90	},
91	.digest = {
92		.data = {0xC8, 0xA9, 0x59, 0x5E},
93		.len  = 4
94	}
95};
96
97struct zuc_hash_test_data zuc_hash_test_case_2 = {
98	.key = {
99		.data = {
100			0x47, 0x05, 0x41, 0x25, 0x56, 0x1E, 0xB2, 0xDD,
101			0xA9, 0x40, 0x59, 0xDA, 0x05, 0x09, 0x78, 0x50
102		},
103		.len = 16
104	},
105	.aad = {
106		.data = {
107			0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00,
108			0x56, 0x1E, 0xB2, 0xDD, 0xA0, 0x00, 0x00, 0x00
109		},
110		.len = 16
111	},
112	.plaintext = {
113		.data = {
114			0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
115			0x00, 0x00, 0x00, 0x00
116		},
117		.len = 96
118	},
119	.validAuthLenInBits = {
120		.len = 90
121	},
122	.validAuthOffsetLenInBits = {
123		.len = 128
124	},
125	.digest = {
126		.data = {0x67, 0x19, 0xA0, 0x88},
127		.len  = 4
128	}
129};
130
131struct zuc_hash_test_data zuc_hash_test_case_3 = {
132	.key = {
133		.data = {
134			0xC9, 0xE6, 0xCE, 0xC4, 0x60, 0x7C, 0x72, 0xDB,
135			0x00, 0x0A, 0xEF, 0xA8, 0x83, 0x85, 0xAB, 0x0A
136		},
137		.len = 16
138	},
139	.aad = {
140		.data = {
141			0xA9, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x00, 0x00,
142			0x29, 0x40, 0x59, 0xDA, 0x50, 0x00, 0x80, 0x00
143		},
144		.len = 16
145	},
146	.plaintext = {
147		.data = {
148			0x98, 0x3B, 0x41, 0xD4, 0x7D, 0x78, 0x0C, 0x9E,
149			0x1A, 0xD1, 0x1D, 0x7E, 0xB7, 0x03, 0x91, 0xB1,
150			0xDE, 0x0B, 0x35, 0xDA, 0x2D, 0xC6, 0x2F, 0x83,
151			0xE7, 0xB7, 0x8D, 0x63, 0x06, 0xCA, 0x0E, 0xA0,
152			0x7E, 0x94, 0x1B, 0x7B, 0xE9, 0x13, 0x48, 0xF9,
153			0xFC, 0xB1, 0x70, 0xE2, 0x21, 0x7F, 0xEC, 0xD9,
154			0x7F, 0x9F, 0x68, 0xAD, 0xB1, 0x6E, 0x5D, 0x7D,
155			0x21, 0xE5, 0x69, 0xD2, 0x80, 0xED, 0x77, 0x5C,
156			0xEB, 0xDE, 0x3F, 0x40, 0x93, 0xC5, 0x38, 0x81,
157			0x00
158		},
159		.len = 584
160	},
161	.validAuthLenInBits = {
162		.len = 577
163	},
164	.validAuthOffsetLenInBits = {
165		.len = 128
166	},
167	.digest = {
168		.data = {0xFA, 0xE8, 0xFF, 0x0B},
169		.len  = 4
170	}
171};
172
173struct zuc_hash_test_data zuc_hash_test_case_4 = {
174	.key = {
175		.data = {
176			0xC8, 0xA4, 0x82, 0x62, 0xD0, 0xC2, 0xE2, 0xBA,
177			0xC4, 0xB9, 0x6E, 0xF7, 0x7E, 0x80, 0xCA, 0x59
178		},
179		.len = 16
180	},
181	.aad = {
182		.data = {
183			0x05, 0x09, 0x78, 0x50, 0x80, 0x00, 0x00, 0x00,
184			0x85, 0x09, 0x78, 0x50, 0x80, 0x00, 0x80, 0x00
185		},
186		.len = 16
187	},
188	.plaintext = {
189		.data = {
190			0xB5, 0x46, 0x43, 0x0B, 0xF8, 0x7B, 0x4F, 0x1E,
191			0xE8, 0x34, 0x70, 0x4C, 0xD6, 0x95, 0x1C, 0x36,
192			0xE2, 0x6F, 0x10, 0x8C, 0xF7, 0x31, 0x78, 0x8F,
193			0x48, 0xDC, 0x34, 0xF1, 0x67, 0x8C, 0x05, 0x22,
194			0x1C, 0x8F, 0xA7, 0xFF, 0x2F, 0x39, 0xF4, 0x77,
195			0xE7, 0xE4, 0x9E, 0xF6, 0x0A, 0x4E, 0xC2, 0xC3,
196			0xDE, 0x24, 0x31, 0x2A, 0x96, 0xAA, 0x26, 0xE1,
197			0xCF, 0xBA, 0x57, 0x56, 0x38, 0x38, 0xB2, 0x97,
198			0xF4, 0x7E, 0x85, 0x10, 0xC7, 0x79, 0xFD, 0x66,
199			0x54, 0xB1, 0x43, 0x38, 0x6F, 0xA6, 0x39, 0xD3,
200			0x1E, 0xDB, 0xD6, 0xC0, 0x6E, 0x47, 0xD1, 0x59,
201			0xD9, 0x43, 0x62, 0xF2, 0x6A, 0xEE, 0xED, 0xEE,
202			0x0E, 0x4F, 0x49, 0xD9, 0xBF, 0x84, 0x12, 0x99,
203			0x54, 0x15, 0xBF, 0xAD, 0x56, 0xEE, 0x82, 0xD1,
204			0xCA, 0x74, 0x63, 0xAB, 0xF0, 0x85, 0xB0, 0x82,
205			0xB0, 0x99, 0x04, 0xD6, 0xD9, 0x90, 0xD4, 0x3C,
206			0xF2, 0xE0, 0x62, 0xF4, 0x08, 0x39, 0xD9, 0x32,
207			0x48, 0xB1, 0xEB, 0x92, 0xCD, 0xFE, 0xD5, 0x30,
208			0x0B, 0xC1, 0x48, 0x28, 0x04, 0x30, 0xB6, 0xD0,
209			0xCA, 0xA0, 0x94, 0xB6, 0xEC, 0x89, 0x11, 0xAB,
210			0x7D, 0xC3, 0x68, 0x24, 0xB8, 0x24, 0xDC, 0x0A,
211			0xF6, 0x68, 0x2B, 0x09, 0x35, 0xFD, 0xE7, 0xB4,
212			0x92, 0xA1, 0x4D, 0xC2, 0xF4, 0x36, 0x48, 0x03,
213			0x8D, 0xA2, 0xCF, 0x79, 0x17, 0x0D, 0x2D, 0x50,
214			0x13, 0x3F, 0xD4, 0x94, 0x16, 0xCB, 0x6E, 0x33,
215			0xBE, 0xA9, 0x0B, 0x8B, 0xF4, 0x55, 0x9B, 0x03,
216			0x73, 0x2A, 0x01, 0xEA, 0x29, 0x0E, 0x6D, 0x07,
217			0x4F, 0x79, 0xBB, 0x83, 0xC1, 0x0E, 0x58, 0x00,
218			0x15, 0xCC, 0x1A, 0x85, 0xB3, 0x6B, 0x55, 0x01,
219			0x04, 0x6E, 0x9C, 0x4B, 0xDC, 0xAE, 0x51, 0x35,
220			0x69, 0x0B, 0x86, 0x66, 0xBD, 0x54, 0xB7, 0xA7,
221			0x03, 0xEA, 0x7B, 0x6F, 0x22, 0x0A, 0x54, 0x69,
222			0xA5, 0x68, 0x02, 0x7E
223		},
224		.len = 2080
225	},
226	.validAuthLenInBits = {
227		.len = 2079
228	},
229	.validAuthOffsetLenInBits = {
230		.len = 128
231	},
232	.digest = {
233		.data = {0x00, 0x4A, 0xC4, 0xD6},
234		.len  = 4
235	}
236};
237
238struct zuc_hash_test_data zuc_hash_test_case_5 = {
239	.key = {
240		.data = {
241			0x6B, 0x8B, 0x08, 0xEE, 0x79, 0xE0, 0xB5, 0x98,
242			0x2D, 0x6D, 0x12, 0x8E, 0xA9, 0xF2, 0x20, 0xCB
243		},
244		.len = 16
245	},
246	.aad = {
247		.data = {
248			0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00,
249			0x56, 0x1E, 0xB2, 0xDD, 0xE0, 0x00, 0x00, 0x00
250		},
251		.len = 16
252	},
253	.plaintext = {
254		.data = {
255			0x5B, 0xAD, 0x72, 0x47, 0x10, 0xBA, 0x1C, 0x56,
256			0xD5, 0xA3, 0x15, 0xF8, 0xD4, 0x0F, 0x6E, 0x09,
257			0x37, 0x80, 0xBE, 0x8E, 0x8D, 0xE0, 0x7B, 0x69,
258			0x92, 0x43, 0x20, 0x18, 0xE0, 0x8E, 0xD9, 0x6A,
259			0x57, 0x34, 0xAF, 0x8B, 0xAD, 0x8A, 0x57, 0x5D,
260			0x3A, 0x1F, 0x16, 0x2F, 0x85, 0x04, 0x5C, 0xC7,
261			0x70, 0x92, 0x55, 0x71, 0xD9, 0xF5, 0xB9, 0x4E,
262			0x45, 0x4A, 0x77, 0xC1, 0x6E, 0x72, 0x93, 0x6B,
263			0xF0, 0x16, 0xAE, 0x15, 0x74, 0x99, 0xF0, 0x54,
264			0x3B, 0x5D, 0x52, 0xCA, 0xA6, 0xDB, 0xEA, 0xB6,
265			0x97, 0xD2, 0xBB, 0x73, 0xE4, 0x1B, 0x80, 0x75,
266			0xDC, 0xE7, 0x9B, 0x4B, 0x86, 0x04, 0x4F, 0x66,
267			0x1D, 0x44, 0x85, 0xA5, 0x43, 0xDD, 0x78, 0x60,
268			0x6E, 0x04, 0x19, 0xE8, 0x05, 0x98, 0x59, 0xD3,
269			0xCB, 0x2B, 0x67, 0xCE, 0x09, 0x77, 0x60, 0x3F,
270			0x81, 0xFF, 0x83, 0x9E, 0x33, 0x18, 0x59, 0x54,
271			0x4C, 0xFB, 0xC8, 0xD0, 0x0F, 0xEF, 0x1A, 0x4C,
272			0x85, 0x10, 0xFB, 0x54, 0x7D, 0x6B, 0x06, 0xC6,
273			0x11, 0xEF, 0x44, 0xF1, 0xBC, 0xE1, 0x07, 0xCF,
274			0xA4, 0x5A, 0x06, 0xAA, 0xB3, 0x60, 0x15, 0x2B,
275			0x28, 0xDC, 0x1E, 0xBE, 0x6F, 0x7F, 0xE0, 0x9B,
276			0x05, 0x16, 0xF9, 0xA5, 0xB0, 0x2A, 0x1B, 0xD8,
277			0x4B, 0xB0, 0x18, 0x1E, 0x2E, 0x89, 0xE1, 0x9B,
278			0xD8, 0x12, 0x59, 0x30, 0xD1, 0x78, 0x68, 0x2F,
279			0x38, 0x62, 0xDC, 0x51, 0xB6, 0x36, 0xF0, 0x4E,
280			0x72, 0x0C, 0x47, 0xC3, 0xCE, 0x51, 0xAD, 0x70,
281			0xD9, 0x4B, 0x9B, 0x22, 0x55, 0xFB, 0xAE, 0x90,
282			0x65, 0x49, 0xF4, 0x99, 0xF8, 0xC6, 0xD3, 0x99,
283			0x47, 0xED, 0x5E, 0x5D, 0xF8, 0xE2, 0xDE, 0xF1,
284			0x13, 0x25, 0x3E, 0x7B, 0x08, 0xD0, 0xA7, 0x6B,
285			0x6B, 0xFC, 0x68, 0xC8, 0x12, 0xF3, 0x75, 0xC7,
286			0x9B, 0x8F, 0xE5, 0xFD, 0x85, 0x97, 0x6A, 0xA6,
287			0xD4, 0x6B, 0x4A, 0x23, 0x39, 0xD8, 0xAE, 0x51,
288			0x47, 0xF6, 0x80, 0xFB, 0xE7, 0x0F, 0x97, 0x8B,
289			0x38, 0xEF, 0xFD, 0x7B, 0x2F, 0x78, 0x66, 0xA2,
290			0x25, 0x54, 0xE1, 0x93, 0xA9, 0x4E, 0x98, 0xA6,
291			0x8B, 0x74, 0xBD, 0x25, 0xBB, 0x2B, 0x3F, 0x5F,
292			0xB0, 0xA5, 0xFD, 0x59, 0x88, 0x7F, 0x9A, 0xB6,
293			0x81, 0x59, 0xB7, 0x17, 0x8D, 0x5B, 0x7B, 0x67,
294			0x7C, 0xB5, 0x46, 0xBF, 0x41, 0xEA, 0xDC, 0xA2,
295			0x16, 0xFC, 0x10, 0x85, 0x01, 0x28, 0xF8, 0xBD,
296			0xEF, 0x5C, 0x8D, 0x89, 0xF9, 0x6A, 0xFA, 0x4F,
297			0xA8, 0xB5, 0x48, 0x85, 0x56, 0x5E, 0xD8, 0x38,
298			0xA9, 0x50, 0xFE, 0xE5, 0xF1, 0xC3, 0xB0, 0xA4,
299			0xF6, 0xFB, 0x71, 0xE5, 0x4D, 0xFD, 0x16, 0x9E,
300			0x82, 0xCE, 0xCC, 0x72, 0x66, 0xC8, 0x50, 0xE6,
301			0x7C, 0x5E, 0xF0, 0xBA, 0x96, 0x0F, 0x52, 0x14,
302			0x06, 0x0E, 0x71, 0xEB, 0x17, 0x2A, 0x75, 0xFC,
303			0x14, 0x86, 0x83, 0x5C, 0xBE, 0xA6, 0x53, 0x44,
304			0x65, 0xB0, 0x55, 0xC9, 0x6A, 0x72, 0xE4, 0x10,
305			0x52, 0x24, 0x18, 0x23, 0x25, 0xD8, 0x30, 0x41,
306			0x4B, 0x40, 0x21, 0x4D, 0xAA, 0x80, 0x91, 0xD2,
307			0xE0, 0xFB, 0x01, 0x0A, 0xE1, 0x5C, 0x6D, 0xE9,
308			0x08, 0x50, 0x97, 0x3B, 0xDF, 0x1E, 0x42, 0x3B,
309			0xE1, 0x48, 0xA2, 0x37, 0xB8, 0x7A, 0x0C, 0x9F,
310			0x34, 0xD4, 0xB4, 0x76, 0x05, 0xB8, 0x03, 0xD7,
311			0x43, 0xA8, 0x6A, 0x90, 0x39, 0x9A, 0x4A, 0xF3,
312			0x96, 0xD3, 0xA1, 0x20, 0x0A, 0x62, 0xF3, 0xD9,
313			0x50, 0x79, 0x62, 0xE8, 0xE5, 0xBE, 0xE6, 0xD3,
314			0xDA, 0x2B, 0xB3, 0xF7, 0x23, 0x76, 0x64, 0xAC,
315			0x7A, 0x29, 0x28, 0x23, 0x90, 0x0B, 0xC6, 0x35,
316			0x03, 0xB2, 0x9E, 0x80, 0xD6, 0x3F, 0x60, 0x67,
317			0xBF, 0x8E, 0x17, 0x16, 0xAC, 0x25, 0xBE, 0xBA,
318			0x35, 0x0D, 0xEB, 0x62, 0xA9, 0x9F, 0xE0, 0x31,
319			0x85, 0xEB, 0x4F, 0x69, 0x93, 0x7E, 0xCD, 0x38,
320			0x79, 0x41, 0xFD, 0xA5, 0x44, 0xBA, 0x67, 0xDB,
321			0x09, 0x11, 0x77, 0x49, 0x38, 0xB0, 0x18, 0x27,
322			0xBC, 0xC6, 0x9C, 0x92, 0xB3, 0xF7, 0x72, 0xA9,
323			0xD2, 0x85, 0x9E, 0xF0, 0x03, 0x39, 0x8B, 0x1F,
324			0x6B, 0xBA, 0xD7, 0xB5, 0x74, 0xF7, 0x98, 0x9A,
325			0x1D, 0x10, 0xB2, 0xDF, 0x79, 0x8E, 0x0D, 0xBF,
326			0x30, 0xD6, 0x58, 0x74, 0x64, 0xD2, 0x48, 0x78,
327			0xCD, 0x00, 0xC0, 0xEA, 0xEE, 0x8A, 0x1A, 0x0C,
328			0xC7, 0x53, 0xA2, 0x79, 0x79, 0xE1, 0x1B, 0x41,
329			0xDB, 0x1D, 0xE3, 0xD5, 0x03, 0x8A, 0xFA, 0xF4,
330			0x9F, 0x5C, 0x68, 0x2C, 0x37, 0x48, 0xD8, 0xA3,
331			0xA9, 0xEC, 0x54, 0xE6, 0xA3, 0x71, 0x27, 0x5F,
332			0x16, 0x83, 0x51, 0x0F, 0x8E, 0x4F, 0x90, 0x93,
333			0x8F, 0x9A, 0xB6, 0xE1, 0x34, 0xC2, 0xCF, 0xDF,
334			0x48, 0x41, 0xCB, 0xA8, 0x8E, 0x0C, 0xFF, 0x2B,
335			0x0B, 0xCC, 0x8E, 0x6A, 0xDC, 0xB7, 0x11, 0x09,
336			0xB5, 0x19, 0x8F, 0xEC, 0xF1, 0xBB, 0x7E, 0x5C,
337			0x53, 0x1A, 0xCA, 0x50, 0xA5, 0x6A, 0x8A, 0x3B,
338			0x6D, 0xE5, 0x98, 0x62, 0xD4, 0x1F, 0xA1, 0x13,
339			0xD9, 0xCD, 0x95, 0x78, 0x08, 0xF0, 0x85, 0x71,
340			0xD9, 0xA4, 0xBB, 0x79, 0x2A, 0xF2, 0x71, 0xF6,
341			0xCC, 0x6D, 0xBB, 0x8D, 0xC7, 0xEC, 0x36, 0xE3,
342			0x6B, 0xE1, 0xED, 0x30, 0x81, 0x64, 0xC3, 0x1C,
343			0x7C, 0x0A, 0xFC, 0x54, 0x1C
344		},
345		.len = 5672
346	},
347	.validAuthLenInBits = {
348		.len = 5670
349	},
350	.validAuthOffsetLenInBits = {
351		.len = 128
352	},
353	.digest = {
354		.data = {0x0C, 0xA1, 0x27, 0x92},
355		.len  = 4
356	}
357};
358
359#endif /* TEST_CRYPTODEV_ZUC_HASH_TEST_VECTORS_H_ */
360