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