1 /*
2 * Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
3 *
4 * Licensed under the OpenSSL license (the "License"). You may not use
5 * this file except in compliance with the License. You can obtain a copy
6 * in the file LICENSE in the source distribution or at
7 * https://www.openssl.org/source/license.html
8 */
9
10 /* Internal tests for the poly1305 module */
11
12 #include <stdio.h>
13 #include <string.h>
14
15 #include "testutil.h"
16 #include "crypto/poly1305.h"
17 #include "../crypto/poly1305/poly1305_local.h"
18 #include "internal/nelem.h"
19
20 typedef struct {
21 size_t size;
22 const unsigned char data[1024];
23 } SIZED_DATA;
24
25 typedef struct {
26 SIZED_DATA input;
27 SIZED_DATA key;
28 SIZED_DATA expected;
29 } TESTDATA;
30
31 /**********************************************************************
32 *
33 * Test of poly1305 internal functions
34 *
35 ***/
36
37 static TESTDATA tests[] = {
38 /*
39 * RFC7539
40 */
41 {
42 {
43 34,
44 {
45 0x43, 0x72, 0x79, 0x70, 0x74, 0x6f, 0x67, 0x72,
46 0x61, 0x70, 0x68, 0x69, 0x63, 0x20, 0x46, 0x6f,
47 0x72, 0x75, 0x6d, 0x20, 0x52, 0x65, 0x73, 0x65,
48 0x61, 0x72, 0x63, 0x68, 0x20, 0x47, 0x72, 0x6f,
49
50 0x75, 0x70
51 }
52 },
53 {
54 32,
55 {
56 0x85, 0xd6, 0xbe, 0x78, 0x57, 0x55, 0x6d, 0x33,
57 0x7f, 0x44, 0x52, 0xfe, 0x42, 0xd5, 0x06, 0xa8,
58 0x01, 0x03, 0x80, 0x8a, 0xfb, 0x0d, 0xb2, 0xfd,
59 0x4a, 0xbf, 0xf6, 0xaf, 0x41, 0x49, 0xf5, 0x1b
60 }
61 },
62 {
63 16,
64 {
65 0xa8, 0x06, 0x1d, 0xc1, 0x30, 0x51, 0x36, 0xc6,
66 0xc2, 0x2b, 0x8b, 0xaf, 0x0c, 0x01, 0x27, 0xa9
67 }
68 }
69 },
70 /*
71 * test vectors from "The Poly1305-AES message-authentication code"
72 */
73 {
74 {
75 2,
76 {
77 0xf3, 0xf6
78 }
79 },
80 {
81 32,
82 {
83 0x85, 0x1f, 0xc4, 0x0c, 0x34, 0x67, 0xac, 0x0b,
84 0xe0, 0x5c, 0xc2, 0x04, 0x04, 0xf3, 0xf7, 0x00,
85 0x58, 0x0b, 0x3b, 0x0f, 0x94, 0x47, 0xbb, 0x1e,
86 0x69, 0xd0, 0x95, 0xb5, 0x92, 0x8b, 0x6d, 0xbc
87 }
88 },
89 {
90 16,
91 {
92 0xf4, 0xc6, 0x33, 0xc3, 0x04, 0x4f, 0xc1, 0x45,
93 0xf8, 0x4f, 0x33, 0x5c, 0xb8, 0x19, 0x53, 0xde
94 }
95 }
96 },
97 {
98 {
99 0,
100 {
101 0
102 }
103 },
104 {
105 32,
106 {
107 0xa0, 0xf3, 0x08, 0x00, 0x00, 0xf4, 0x64, 0x00,
108 0xd0, 0xc7, 0xe9, 0x07, 0x6c, 0x83, 0x44, 0x03,
109 0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
110 0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
111 }
112 },
113 {
114 16,
115 {
116 0xdd, 0x3f, 0xab, 0x22, 0x51, 0xf1, 0x1a, 0xc7,
117 0x59, 0xf0, 0x88, 0x71, 0x29, 0xcc, 0x2e, 0xe7
118 }
119 }
120 },
121 {
122 {
123 32,
124 {
125 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
126 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
127 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
128 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
129 }
130 },
131 {
132 32,
133 {
134 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
135 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
136 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
137 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef
138 }
139 },
140 {
141 16,
142 {
143 0x0e, 0xe1, 0xc1, 0x6b, 0xb7, 0x3f, 0x0f, 0x4f,
144 0xd1, 0x98, 0x81, 0x75, 0x3c, 0x01, 0xcd, 0xbe
145 }
146 }
147 },
148 {
149 {
150 63,
151 {
152 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
153 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
154 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
155 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
156
157 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
158 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
159 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
160 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9
161 }
162 },
163 {
164 32,
165 {
166 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
167 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
168 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
169 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
170 }
171 },
172 {
173 16,
174 {
175 0x51, 0x54, 0xad, 0x0d, 0x2c, 0xb2, 0x6e, 0x01,
176 0x27, 0x4f, 0xc5, 0x11, 0x48, 0x49, 0x1f, 0x1b
177 }
178 },
179 },
180 /*
181 * self-generated vectors exercise "significant" lengths, such that
182 * are handled by different code paths
183 */
184 {
185 {
186 64,
187 {
188 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
189 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
190 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
191 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
192
193 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
194 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
195 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
196 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf
197 }
198 },
199 {
200 32,
201 {
202 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
203 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
204 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
205 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
206 }
207 },
208 {
209 16,
210 {
211 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
212 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
213 }
214 },
215 },
216 {
217 {
218 48,
219 {
220 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
221 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
222 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
223 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
224
225 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
226 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67
227 }
228 },
229 {
230 32,
231 {
232 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
233 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
234 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
235 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
236
237 }
238 },
239 {
240 16,
241 {
242 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
243 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
244 }
245 },
246 },
247 {
248 {
249 96,
250 {
251 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
252 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
253 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
254 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
255
256 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
257 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
258 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
259 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
260
261 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
262 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
263 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
264 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
265 }
266 },
267 {
268 32,
269 {
270 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
271 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
272 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
273 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
274 }
275 },
276 {
277 16,
278 {
279 0xbb, 0xb6, 0x13, 0xb2, 0xb6, 0xd7, 0x53, 0xba,
280 0x07, 0x39, 0x5b, 0x91, 0x6a, 0xae, 0xce, 0x15
281 }
282 },
283 },
284 {
285 {
286 112,
287 {
288 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
289 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
290 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
291 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
292
293 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
294 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
295 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
296 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
297
298 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
299 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
300 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
301 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
302
303 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
304 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24
305 }
306 },
307 {
308 32,
309 {
310 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
311 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
312 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
313 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
314 }
315 },
316 {
317 16,
318 {
319 0xc7, 0x94, 0xd7, 0x05, 0x7d, 0x17, 0x78, 0xc4,
320 0xbb, 0xee, 0x0a, 0x39, 0xb3, 0xd9, 0x73, 0x42
321 }
322 },
323 },
324 {
325 {
326 128,
327 {
328 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
329 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
330 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
331 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
332
333 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
334 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
335 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
336 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
337
338 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
339 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
340 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
341 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
342
343 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
344 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
345 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
346 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
347 }
348 },
349 {
350 32,
351 {
352 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
353 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
354 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
355 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
356 }
357 },
358 {
359 16,
360 {
361 0xff, 0xbc, 0xb9, 0xb3, 0x71, 0x42, 0x31, 0x52,
362 0xd7, 0xfc, 0xa5, 0xad, 0x04, 0x2f, 0xba, 0xa9
363 }
364 },
365 },
366 {
367 {
368 144,
369 {
370 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
371 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
372 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
373 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
374
375 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
376 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
377 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
378 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
379
380 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
381 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
382 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
383 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
384
385 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
386 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
387 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
388 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
389
390 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
391 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66
392 }
393 },
394 {
395 32,
396 {
397 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
398 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
399 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
400 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
401 }
402 },
403 {
404 16,
405 {
406 0x06, 0x9e, 0xd6, 0xb8, 0xef, 0x0f, 0x20, 0x7b,
407 0x3e, 0x24, 0x3b, 0xb1, 0x01, 0x9f, 0xe6, 0x32
408 }
409 },
410 },
411 {
412 {
413 160,
414 {
415 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
416 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
417 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
418 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
419
420 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
421 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
422 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
423 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
424
425 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
426 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
427 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
428 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
429
430 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
431 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
432 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
433 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
434
435 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
436 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
437 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
438 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
439 }
440 },
441 {
442 32,
443 {
444 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
445 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
446 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
447 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
448 }
449 },
450 {
451 16,
452 {
453 0xcc, 0xa3, 0x39, 0xd9, 0xa4, 0x5f, 0xa2, 0x36,
454 0x8c, 0x2c, 0x68, 0xb3, 0xa4, 0x17, 0x91, 0x33
455 }
456 },
457 },
458 {
459 {
460 288,
461 {
462 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
463 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
464 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
465 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
466
467 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
468 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
469 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
470 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
471
472 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
473 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
474 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
475 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
476
477 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
478 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
479 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
480 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
481
482 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
483 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
484 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
485 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
486
487 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
488 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
489 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
490 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
491
492 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
493 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
494 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
495 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
496
497 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
498 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
499 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
500 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
501
502 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
503 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
504 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
505 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36
506 }
507 },
508 {
509 32,
510 {
511 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
512 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
513 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
514 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
515 }
516 },
517 {
518 16,
519 {
520 0x53, 0xf6, 0xe8, 0x28, 0xa2, 0xf0, 0xfe, 0x0e,
521 0xe8, 0x15, 0xbf, 0x0b, 0xd5, 0x84, 0x1a, 0x34
522 }
523 },
524 },
525 {
526 {
527 320,
528 {
529 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
530 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
531 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
532 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
533
534 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
535 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
536 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
537 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
538
539 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
540 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
541 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
542 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
543
544 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
545 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
546 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
547 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
548
549 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
550 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
551 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
552 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61,
553
554 0xab, 0x08, 0x12, 0x72, 0x4a, 0x7f, 0x1e, 0x34,
555 0x27, 0x42, 0xcb, 0xed, 0x37, 0x4d, 0x94, 0xd1,
556 0x36, 0xc6, 0xb8, 0x79, 0x5d, 0x45, 0xb3, 0x81,
557 0x98, 0x30, 0xf2, 0xc0, 0x44, 0x91, 0xfa, 0xf0,
558
559 0x99, 0x0c, 0x62, 0xe4, 0x8b, 0x80, 0x18, 0xb2,
560 0xc3, 0xe4, 0xa0, 0xfa, 0x31, 0x34, 0xcb, 0x67,
561 0xfa, 0x83, 0xe1, 0x58, 0xc9, 0x94, 0xd9, 0x61,
562 0xc4, 0xcb, 0x21, 0x09, 0x5c, 0x1b, 0xf9, 0xaf,
563
564 0x48, 0x44, 0x3d, 0x0b, 0xb0, 0xd2, 0x11, 0x09,
565 0xc8, 0x9a, 0x10, 0x0b, 0x5c, 0xe2, 0xc2, 0x08,
566 0x83, 0x14, 0x9c, 0x69, 0xb5, 0x61, 0xdd, 0x88,
567 0x29, 0x8a, 0x17, 0x98, 0xb1, 0x07, 0x16, 0xef,
568
569 0x66, 0x3c, 0xea, 0x19, 0x0f, 0xfb, 0x83, 0xd8,
570 0x95, 0x93, 0xf3, 0xf4, 0x76, 0xb6, 0xbc, 0x24,
571 0xd7, 0xe6, 0x79, 0x10, 0x7e, 0xa2, 0x6a, 0xdb,
572 0x8c, 0xaf, 0x66, 0x52, 0xd0, 0x65, 0x61, 0x36,
573
574 0x81, 0x20, 0x59, 0xa5, 0xda, 0x19, 0x86, 0x37,
575 0xca, 0xc7, 0xc4, 0xa6, 0x31, 0xbe, 0xe4, 0x66,
576 0x5b, 0x88, 0xd7, 0xf6, 0x22, 0x8b, 0x11, 0xe2,
577 0xe2, 0x85, 0x79, 0xa5, 0xc0, 0xc1, 0xf7, 0x61
578 }
579 },
580 {
581 32,
582 {
583 0x12, 0x97, 0x6a, 0x08, 0xc4, 0x42, 0x6d, 0x0c,
584 0xe8, 0xa8, 0x24, 0x07, 0xc4, 0xf4, 0x82, 0x07,
585 0x80, 0xf8, 0xc2, 0x0a, 0xa7, 0x12, 0x02, 0xd1,
586 0xe2, 0x91, 0x79, 0xcb, 0xcb, 0x55, 0x5a, 0x57
587 }
588 },
589 {
590 16,
591 {
592 0xb8, 0x46, 0xd4, 0x4e, 0x9b, 0xbd, 0x53, 0xce,
593 0xdf, 0xfb, 0xfb, 0xb6, 0xb7, 0xfa, 0x49, 0x33
594 }
595 },
596 },
597 /*
598 * 4th power of the key spills to 131th bit in SIMD key setup
599 */
600 {
601 {
602 256,
603 {
604 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
605 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
606 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
607 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
608
609 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
610 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
611 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
612 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
613
614 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
615 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
616 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
617 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
618
619 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
620 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
621 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
622 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
623
624 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
625 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
626 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
627 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
628
629 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
630 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
631 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
632 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
633
634 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
635 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
636 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
637 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
638
639 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
640 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
641 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
642 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
643 }
644 },
645 {
646 32,
647 {
648 0xad, 0x62, 0x81, 0x07, 0xe8, 0x35, 0x1d, 0x0f,
649 0x2c, 0x23, 0x1a, 0x05, 0xdc, 0x4a, 0x41, 0x06,
650 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
651 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
652 }
653 },
654 {
655 16,
656 {
657 0x07, 0x14, 0x5a, 0x4c, 0x02, 0xfe, 0x5f, 0xa3,
658 0x20, 0x36, 0xde, 0x68, 0xfa, 0xbe, 0x90, 0x66
659 }
660 },
661 },
662 /*
663 * poly1305_ieee754.c failed this in final stage
664 */
665 {
666 {
667 252,
668 {
669 0x84, 0x23, 0x64, 0xe1, 0x56, 0x33, 0x6c, 0x09,
670 0x98, 0xb9, 0x33, 0xa6, 0x23, 0x77, 0x26, 0x18,
671 0x0d, 0x9e, 0x3f, 0xdc, 0xbd, 0xe4, 0xcd, 0x5d,
672 0x17, 0x08, 0x0f, 0xc3, 0xbe, 0xb4, 0x96, 0x14,
673
674 0xd7, 0x12, 0x2c, 0x03, 0x74, 0x63, 0xff, 0x10,
675 0x4d, 0x73, 0xf1, 0x9c, 0x12, 0x70, 0x46, 0x28,
676 0xd4, 0x17, 0xc4, 0xc5, 0x4a, 0x3f, 0xe3, 0x0d,
677 0x3c, 0x3d, 0x77, 0x14, 0x38, 0x2d, 0x43, 0xb0,
678
679 0x38, 0x2a, 0x50, 0xa5, 0xde, 0xe5, 0x4b, 0xe8,
680 0x44, 0xb0, 0x76, 0xe8, 0xdf, 0x88, 0x20, 0x1a,
681 0x1c, 0xd4, 0x3b, 0x90, 0xeb, 0x21, 0x64, 0x3f,
682 0xa9, 0x6f, 0x39, 0xb5, 0x18, 0xaa, 0x83, 0x40,
683
684 0xc9, 0x42, 0xff, 0x3c, 0x31, 0xba, 0xf7, 0xc9,
685 0xbd, 0xbf, 0x0f, 0x31, 0xae, 0x3f, 0xa0, 0x96,
686 0xbf, 0x8c, 0x63, 0x03, 0x06, 0x09, 0x82, 0x9f,
687 0xe7, 0x2e, 0x17, 0x98, 0x24, 0x89, 0x0b, 0xc8,
688
689 0xe0, 0x8c, 0x31, 0x5c, 0x1c, 0xce, 0x2a, 0x83,
690 0x14, 0x4d, 0xbb, 0xff, 0x09, 0xf7, 0x4e, 0x3e,
691 0xfc, 0x77, 0x0b, 0x54, 0xd0, 0x98, 0x4a, 0x8f,
692 0x19, 0xb1, 0x47, 0x19, 0xe6, 0x36, 0x35, 0x64,
693
694 0x1d, 0x6b, 0x1e, 0xed, 0xf6, 0x3e, 0xfb, 0xf0,
695 0x80, 0xe1, 0x78, 0x3d, 0x32, 0x44, 0x54, 0x12,
696 0x11, 0x4c, 0x20, 0xde, 0x0b, 0x83, 0x7a, 0x0d,
697 0xfa, 0x33, 0xd6, 0xb8, 0x28, 0x25, 0xff, 0xf4,
698
699 0x4c, 0x9a, 0x70, 0xea, 0x54, 0xce, 0x47, 0xf0,
700 0x7d, 0xf6, 0x98, 0xe6, 0xb0, 0x33, 0x23, 0xb5,
701 0x30, 0x79, 0x36, 0x4a, 0x5f, 0xc3, 0xe9, 0xdd,
702 0x03, 0x43, 0x92, 0xbd, 0xde, 0x86, 0xdc, 0xcd,
703
704 0xda, 0x94, 0x32, 0x1c, 0x5e, 0x44, 0x06, 0x04,
705 0x89, 0x33, 0x6c, 0xb6, 0x5b, 0xf3, 0x98, 0x9c,
706 0x36, 0xf7, 0x28, 0x2c, 0x2f, 0x5d, 0x2b, 0x88,
707 0x2c, 0x17, 0x1e, 0x74
708 }
709 },
710 {
711 32,
712 {
713 0x95, 0xd5, 0xc0, 0x05, 0x50, 0x3e, 0x51, 0x0d,
714 0x8c, 0xd0, 0xaa, 0x07, 0x2c, 0x4a, 0x4d, 0x06,
715 0x6e, 0xab, 0xc5, 0x2d, 0x11, 0x65, 0x3d, 0xf4,
716 0x7f, 0xbf, 0x63, 0xab, 0x19, 0x8b, 0xcc, 0x26
717 }
718 },
719 {
720 16,
721 {
722 0xf2, 0x48, 0x31, 0x2e, 0x57, 0x8d, 0x9d, 0x58,
723 0xf8, 0xb7, 0xbb, 0x4d, 0x19, 0x10, 0x54, 0x31
724 }
725 },
726 },
727 /*
728 * AVX2 in poly1305-x86.pl failed this with 176+32 split
729 */
730 {
731 {
732 208,
733 {
734 0x24, 0x8a, 0xc3, 0x10, 0x85, 0xb6, 0xc2, 0xad,
735 0xaa, 0xa3, 0x82, 0x59, 0xa0, 0xd7, 0x19, 0x2c,
736 0x5c, 0x35, 0xd1, 0xbb, 0x4e, 0xf3, 0x9a, 0xd9,
737 0x4c, 0x38, 0xd1, 0xc8, 0x24, 0x79, 0xe2, 0xdd,
738
739 0x21, 0x59, 0xa0, 0x77, 0x02, 0x4b, 0x05, 0x89,
740 0xbc, 0x8a, 0x20, 0x10, 0x1b, 0x50, 0x6f, 0x0a,
741 0x1a, 0xd0, 0xbb, 0xab, 0x76, 0xe8, 0x3a, 0x83,
742 0xf1, 0xb9, 0x4b, 0xe6, 0xbe, 0xae, 0x74, 0xe8,
743
744 0x74, 0xca, 0xb6, 0x92, 0xc5, 0x96, 0x3a, 0x75,
745 0x43, 0x6b, 0x77, 0x61, 0x21, 0xec, 0x9f, 0x62,
746 0x39, 0x9a, 0x3e, 0x66, 0xb2, 0xd2, 0x27, 0x07,
747 0xda, 0xe8, 0x19, 0x33, 0xb6, 0x27, 0x7f, 0x3c,
748
749 0x85, 0x16, 0xbc, 0xbe, 0x26, 0xdb, 0xbd, 0x86,
750 0xf3, 0x73, 0x10, 0x3d, 0x7c, 0xf4, 0xca, 0xd1,
751 0x88, 0x8c, 0x95, 0x21, 0x18, 0xfb, 0xfb, 0xd0,
752 0xd7, 0xb4, 0xbe, 0xdc, 0x4a, 0xe4, 0x93, 0x6a,
753
754 0xff, 0x91, 0x15, 0x7e, 0x7a, 0xa4, 0x7c, 0x54,
755 0x44, 0x2e, 0xa7, 0x8d, 0x6a, 0xc2, 0x51, 0xd3,
756 0x24, 0xa0, 0xfb, 0xe4, 0x9d, 0x89, 0xcc, 0x35,
757 0x21, 0xb6, 0x6d, 0x16, 0xe9, 0xc6, 0x6a, 0x37,
758
759 0x09, 0x89, 0x4e, 0x4e, 0xb0, 0xa4, 0xee, 0xdc,
760 0x4a, 0xe1, 0x94, 0x68, 0xe6, 0x6b, 0x81, 0xf2,
761
762 0x71, 0x35, 0x1b, 0x1d, 0x92, 0x1e, 0xa5, 0x51,
763 0x04, 0x7a, 0xbc, 0xc6, 0xb8, 0x7a, 0x90, 0x1f,
764 0xde, 0x7d, 0xb7, 0x9f, 0xa1, 0x81, 0x8c, 0x11,
765 0x33, 0x6d, 0xbc, 0x07, 0x24, 0x4a, 0x40, 0xeb
766 }
767 },
768 {
769 32,
770 {
771 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
772 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
773 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
774 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
775 }
776 },
777 {
778 16,
779 {
780 0xbc, 0x93, 0x9b, 0xc5, 0x28, 0x14, 0x80, 0xfa,
781 0x99, 0xc6, 0xd6, 0x8c, 0x25, 0x8e, 0xc4, 0x2f
782 }
783 },
784 },
785 /*
786 * test vectors from Google
787 */
788 {
789 {
790 0,
791 {
792 0x00,
793 }
794 },
795 {
796 32,
797 {
798 0xc8, 0xaf, 0xaa, 0xc3, 0x31, 0xee, 0x37, 0x2c,
799 0xd6, 0x08, 0x2d, 0xe1, 0x34, 0x94, 0x3b, 0x17,
800 0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
801 0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
802 }
803 },
804 {
805 16,
806 {
807 0x47, 0x10, 0x13, 0x0e, 0x9f, 0x6f, 0xea, 0x8d,
808 0x72, 0x29, 0x38, 0x50, 0xa6, 0x67, 0xd8, 0x6c
809 }
810 },
811 },
812 {
813 {
814 12,
815 {
816 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x77, 0x6f,
817 0x72, 0x6c, 0x64, 0x21
818 }
819 },
820 {
821 32,
822 {
823 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
824 0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
825 0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
826 0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
827 }
828 },
829 {
830 16,
831 {
832 0xa6, 0xf7, 0x45, 0x00, 0x8f, 0x81, 0xc9, 0x16,
833 0xa2, 0x0d, 0xcc, 0x74, 0xee, 0xf2, 0xb2, 0xf0
834 }
835 },
836 },
837 {
838 {
839 32,
840 {
841 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
842 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
843 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
844 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
845 }
846 },
847 {
848 32,
849 {
850 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20,
851 0x33, 0x32, 0x2d, 0x62, 0x79, 0x74, 0x65, 0x20,
852 0x6b, 0x65, 0x79, 0x20, 0x66, 0x6f, 0x72, 0x20,
853 0x50, 0x6f, 0x6c, 0x79, 0x31, 0x33, 0x30, 0x35
854 }
855 },
856 {
857 16,
858 {
859 0x49, 0xec, 0x78, 0x09, 0x0e, 0x48, 0x1e, 0xc6,
860 0xc2, 0x6b, 0x33, 0xb9, 0x1c, 0xcc, 0x03, 0x07
861 }
862 },
863 },
864 {
865 {
866 128,
867 {
868 0x89, 0xda, 0xb8, 0x0b, 0x77, 0x17, 0xc1, 0xdb,
869 0x5d, 0xb4, 0x37, 0x86, 0x0a, 0x3f, 0x70, 0x21,
870 0x8e, 0x93, 0xe1, 0xb8, 0xf4, 0x61, 0xfb, 0x67,
871 0x7f, 0x16, 0xf3, 0x5f, 0x6f, 0x87, 0xe2, 0xa9,
872
873 0x1c, 0x99, 0xbc, 0x3a, 0x47, 0xac, 0xe4, 0x76,
874 0x40, 0xcc, 0x95, 0xc3, 0x45, 0xbe, 0x5e, 0xcc,
875 0xa5, 0xa3, 0x52, 0x3c, 0x35, 0xcc, 0x01, 0x89,
876 0x3a, 0xf0, 0xb6, 0x4a, 0x62, 0x03, 0x34, 0x27,
877
878 0x03, 0x72, 0xec, 0x12, 0x48, 0x2d, 0x1b, 0x1e,
879 0x36, 0x35, 0x61, 0x69, 0x8a, 0x57, 0x8b, 0x35,
880 0x98, 0x03, 0x49, 0x5b, 0xb4, 0xe2, 0xef, 0x19,
881 0x30, 0xb1, 0x7a, 0x51, 0x90, 0xb5, 0x80, 0xf1,
882
883 0x41, 0x30, 0x0d, 0xf3, 0x0a, 0xdb, 0xec, 0xa2,
884 0x8f, 0x64, 0x27, 0xa8, 0xbc, 0x1a, 0x99, 0x9f,
885 0xd5, 0x1c, 0x55, 0x4a, 0x01, 0x7d, 0x09, 0x5d,
886 0x8c, 0x3e, 0x31, 0x27, 0xda, 0xf9, 0xf5, 0x95
887 }
888 },
889 {
890 32,
891 {
892 0x2d, 0x77, 0x3b, 0xe3, 0x7a, 0xdb, 0x1e, 0x4d,
893 0x68, 0x3b, 0xf0, 0x07, 0x5e, 0x79, 0xc4, 0xee,
894 0x03, 0x79, 0x18, 0x53, 0x5a, 0x7f, 0x99, 0xcc,
895 0xb7, 0x04, 0x0f, 0xb5, 0xf5, 0xf4, 0x3a, 0xea
896 }
897 },
898 {
899 16,
900 {
901 0xc8, 0x5d, 0x15, 0xed, 0x44, 0xc3, 0x78, 0xd6,
902 0xb0, 0x0e, 0x23, 0x06, 0x4c, 0x7b, 0xcd, 0x51
903 }
904 },
905 },
906 {
907 {
908 528,
909 {
910 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b,
911 0x17, 0x03, 0x03, 0x02, 0x00, 0x00, 0x00, 0x00,
912
913 0x06, 0xdb, 0x1f, 0x1f, 0x36, 0x8d, 0x69, 0x6a,
914 0x81, 0x0a, 0x34, 0x9c, 0x0c, 0x71, 0x4c, 0x9a,
915 0x5e, 0x78, 0x50, 0xc2, 0x40, 0x7d, 0x72, 0x1a,
916 0xcd, 0xed, 0x95, 0xe0, 0x18, 0xd7, 0xa8, 0x52,
917
918 0x66, 0xa6, 0xe1, 0x28, 0x9c, 0xdb, 0x4a, 0xeb,
919 0x18, 0xda, 0x5a, 0xc8, 0xa2, 0xb0, 0x02, 0x6d,
920 0x24, 0xa5, 0x9a, 0xd4, 0x85, 0x22, 0x7f, 0x3e,
921 0xae, 0xdb, 0xb2, 0xe7, 0xe3, 0x5e, 0x1c, 0x66,
922
923 0xcd, 0x60, 0xf9, 0xab, 0xf7, 0x16, 0xdc, 0xc9,
924 0xac, 0x42, 0x68, 0x2d, 0xd7, 0xda, 0xb2, 0x87,
925 0xa7, 0x02, 0x4c, 0x4e, 0xef, 0xc3, 0x21, 0xcc,
926 0x05, 0x74, 0xe1, 0x67, 0x93, 0xe3, 0x7c, 0xec,
927
928 0x03, 0xc5, 0xbd, 0xa4, 0x2b, 0x54, 0xc1, 0x14,
929 0xa8, 0x0b, 0x57, 0xaf, 0x26, 0x41, 0x6c, 0x7b,
930 0xe7, 0x42, 0x00, 0x5e, 0x20, 0x85, 0x5c, 0x73,
931 0xe2, 0x1d, 0xc8, 0xe2, 0xed, 0xc9, 0xd4, 0x35,
932
933 0xcb, 0x6f, 0x60, 0x59, 0x28, 0x00, 0x11, 0xc2,
934 0x70, 0xb7, 0x15, 0x70, 0x05, 0x1c, 0x1c, 0x9b,
935 0x30, 0x52, 0x12, 0x66, 0x20, 0xbc, 0x1e, 0x27,
936 0x30, 0xfa, 0x06, 0x6c, 0x7a, 0x50, 0x9d, 0x53,
937
938 0xc6, 0x0e, 0x5a, 0xe1, 0xb4, 0x0a, 0xa6, 0xe3,
939 0x9e, 0x49, 0x66, 0x92, 0x28, 0xc9, 0x0e, 0xec,
940 0xb4, 0xa5, 0x0d, 0xb3, 0x2a, 0x50, 0xbc, 0x49,
941 0xe9, 0x0b, 0x4f, 0x4b, 0x35, 0x9a, 0x1d, 0xfd,
942
943 0x11, 0x74, 0x9c, 0xd3, 0x86, 0x7f, 0xcf, 0x2f,
944 0xb7, 0xbb, 0x6c, 0xd4, 0x73, 0x8f, 0x6a, 0x4a,
945 0xd6, 0xf7, 0xca, 0x50, 0x58, 0xf7, 0x61, 0x88,
946 0x45, 0xaf, 0x9f, 0x02, 0x0f, 0x6c, 0x3b, 0x96,
947
948 0x7b, 0x8f, 0x4c, 0xd4, 0xa9, 0x1e, 0x28, 0x13,
949 0xb5, 0x07, 0xae, 0x66, 0xf2, 0xd3, 0x5c, 0x18,
950 0x28, 0x4f, 0x72, 0x92, 0x18, 0x60, 0x62, 0xe1,
951 0x0f, 0xd5, 0x51, 0x0d, 0x18, 0x77, 0x53, 0x51,
952
953 0xef, 0x33, 0x4e, 0x76, 0x34, 0xab, 0x47, 0x43,
954 0xf5, 0xb6, 0x8f, 0x49, 0xad, 0xca, 0xb3, 0x84,
955 0xd3, 0xfd, 0x75, 0xf7, 0x39, 0x0f, 0x40, 0x06,
956 0xef, 0x2a, 0x29, 0x5c, 0x8c, 0x7a, 0x07, 0x6a,
957
958 0xd5, 0x45, 0x46, 0xcd, 0x25, 0xd2, 0x10, 0x7f,
959 0xbe, 0x14, 0x36, 0xc8, 0x40, 0x92, 0x4a, 0xae,
960 0xbe, 0x5b, 0x37, 0x08, 0x93, 0xcd, 0x63, 0xd1,
961 0x32, 0x5b, 0x86, 0x16, 0xfc, 0x48, 0x10, 0x88,
962
963 0x6b, 0xc1, 0x52, 0xc5, 0x32, 0x21, 0xb6, 0xdf,
964 0x37, 0x31, 0x19, 0x39, 0x32, 0x55, 0xee, 0x72,
965 0xbc, 0xaa, 0x88, 0x01, 0x74, 0xf1, 0x71, 0x7f,
966 0x91, 0x84, 0xfa, 0x91, 0x64, 0x6f, 0x17, 0xa2,
967
968 0x4a, 0xc5, 0x5d, 0x16, 0xbf, 0xdd, 0xca, 0x95,
969 0x81, 0xa9, 0x2e, 0xda, 0x47, 0x92, 0x01, 0xf0,
970 0xed, 0xbf, 0x63, 0x36, 0x00, 0xd6, 0x06, 0x6d,
971 0x1a, 0xb3, 0x6d, 0x5d, 0x24, 0x15, 0xd7, 0x13,
972
973 0x51, 0xbb, 0xcd, 0x60, 0x8a, 0x25, 0x10, 0x8d,
974 0x25, 0x64, 0x19, 0x92, 0xc1, 0xf2, 0x6c, 0x53,
975 0x1c, 0xf9, 0xf9, 0x02, 0x03, 0xbc, 0x4c, 0xc1,
976 0x9f, 0x59, 0x27, 0xd8, 0x34, 0xb0, 0xa4, 0x71,
977
978 0x16, 0xd3, 0x88, 0x4b, 0xbb, 0x16, 0x4b, 0x8e,
979 0xc8, 0x83, 0xd1, 0xac, 0x83, 0x2e, 0x56, 0xb3,
980 0x91, 0x8a, 0x98, 0x60, 0x1a, 0x08, 0xd1, 0x71,
981 0x88, 0x15, 0x41, 0xd5, 0x94, 0xdb, 0x39, 0x9c,
982
983 0x6a, 0xe6, 0x15, 0x12, 0x21, 0x74, 0x5a, 0xec,
984 0x81, 0x4c, 0x45, 0xb0, 0xb0, 0x5b, 0x56, 0x54,
985 0x36, 0xfd, 0x6f, 0x13, 0x7a, 0xa1, 0x0a, 0x0c,
986 0x0b, 0x64, 0x37, 0x61, 0xdb, 0xd6, 0xf9, 0xa9,
987
988 0xdc, 0xb9, 0x9b, 0x1a, 0x6e, 0x69, 0x08, 0x54,
989 0xce, 0x07, 0x69, 0xcd, 0xe3, 0x97, 0x61, 0xd8,
990 0x2f, 0xcd, 0xec, 0x15, 0xf0, 0xd9, 0x2d, 0x7d,
991 0x8e, 0x94, 0xad, 0xe8, 0xeb, 0x83, 0xfb, 0xe0
992 }
993 },
994 {
995 32,
996 {
997 0x99, 0xe5, 0x82, 0x2d, 0xd4, 0x17, 0x3c, 0x99,
998 0x5e, 0x3d, 0xae, 0x0d, 0xde, 0xfb, 0x97, 0x74,
999 0x3f, 0xde, 0x3b, 0x08, 0x01, 0x34, 0xb3, 0x9f,
1000 0x76, 0xe9, 0xbf, 0x8d, 0x0e, 0x88, 0xd5, 0x46
1001 }
1002 },
1003 {
1004 16,
1005 {
1006 0x26, 0x37, 0x40, 0x8f, 0xe1, 0x30, 0x86, 0xea,
1007 0x73, 0xf9, 0x71, 0xe3, 0x42, 0x5e, 0x28, 0x20
1008 }
1009 },
1010 },
1011 /*
1012 * test vectors from Hanno Böck
1013 */
1014 {
1015 {
1016 257,
1017 {
1018 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1019 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1020 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1021 0xcc, 0x80, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1022
1023 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1024 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1025 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1026 0xcc, 0xcc, 0xcc, 0xcc, 0xce, 0xcc, 0xcc, 0xcc,
1027
1028 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1029 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xc5,
1030 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1031 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1032
1033 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe3, 0xcc, 0xcc,
1034 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1035 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1036 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1037
1038 0xcc, 0xcc, 0xcc, 0xcc, 0xac, 0xcc, 0xcc, 0xcc,
1039 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xe6,
1040 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0x00, 0x00, 0x00,
1041 0xaf, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc,
1042
1043 0xcc, 0xcc, 0xff, 0xff, 0xff, 0xf5, 0x00, 0x00,
1044 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1045 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1046 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1047
1048 0x00, 0xff, 0xff, 0xff, 0xe7, 0x00, 0x00, 0x00,
1049 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1050 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1051 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1052
1053 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1054 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1055 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1056 0x00, 0x00, 0x71, 0x92, 0x05, 0xa8, 0x52, 0x1d,
1057
1058 0xfc
1059 }
1060 },
1061 {
1062 32,
1063 {
1064 0x7f, 0x1b, 0x02, 0x64, 0x00, 0x00, 0x00, 0x00,
1065 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1066 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1067 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc, 0xcc
1068 }
1069 },
1070 {
1071 16,
1072 {
1073 0x85, 0x59, 0xb8, 0x76, 0xec, 0xee, 0xd6, 0x6e,
1074 0xb3, 0x77, 0x98, 0xc0, 0x45, 0x7b, 0xaf, 0xf9
1075 }
1076 },
1077 },
1078 {
1079 {
1080 39,
1081 {
1082 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1083 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1084 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1085 0xaa, 0xaa, 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00,
1086
1087 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0x64
1088 }
1089 },
1090 {
1091 32,
1092 {
1093 0xe0, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00,
1094 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1095 0x00, 0x00, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
1096 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa
1097 }
1098 },
1099 {
1100 16,
1101 {
1102 0x00, 0xbd, 0x12, 0x58, 0x97, 0x8e, 0x20, 0x54,
1103 0x44, 0xc9, 0xaa, 0xaa, 0x82, 0x00, 0x6f, 0xed
1104 }
1105 },
1106 },
1107 {
1108 {
1109 2,
1110 {
1111 0x02, 0xfc
1112 }
1113 },
1114 {
1115 32,
1116 {
1117 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
1118 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
1119 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
1120 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
1121 }
1122 },
1123 {
1124 16,
1125 {
1126 0x06, 0x12, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
1127 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
1128 }
1129 },
1130 },
1131 {
1132 {
1133 415,
1134 {
1135 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1136 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1137 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1138 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1139
1140 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7a, 0x7b,
1141 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1142 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1143 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1144
1145 0x7b, 0x7b, 0x5c, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1146 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1147 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1148 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1149
1150 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1151 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1152 0x7b, 0x7b, 0x7b, 0x7b, 0x6e, 0x7b, 0x00, 0x7b,
1153 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1154
1155 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1156 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1157 0x7b, 0x7b, 0x7b, 0x7a, 0x7b, 0x7b, 0x7b, 0x7b,
1158 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1159
1160 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1161 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x5c,
1162 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1163 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1164
1165 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1166 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1167 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1168 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b, 0x7b,
1169
1170 0x7b, 0x6e, 0x7b, 0x00, 0x13, 0x00, 0x00, 0x00,
1171 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1172 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1173 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1174
1175 0xf2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1176 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1177 0x00, 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00,
1178 0x09, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1179
1180 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00,
1181 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00,
1182 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1183 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00,
1184
1185 0xb3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1186 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1187 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf2,
1188 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1189
1190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1191 0x00, 0x00, 0x20, 0x00, 0xef, 0xff, 0x00, 0x09,
1192 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1193 0x00, 0x7a, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00,
1194
1195 0x00, 0x09, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00,
1196 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1197 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1198 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc
1199 }
1200 },
1201 {
1202 32,
1203 {
1204 0x00, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1205 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1206 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00,
1207 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0x7b
1208 }
1209 },
1210 {
1211 16,
1212 {
1213 0x33, 0x20, 0x5b, 0xbf, 0x9e, 0x9f, 0x8f, 0x72,
1214 0x12, 0xab, 0x9e, 0x2a, 0xb9, 0xb7, 0xe4, 0xa5
1215 }
1216 },
1217 },
1218 {
1219 {
1220 118,
1221 {
1222 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1223 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1224 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1225 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1226
1227 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1228 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1229 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1230 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1231
1232 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77,
1233 0x77, 0x77, 0x77, 0x77, 0xff, 0xff, 0xff, 0xe9,
1234 0xe9, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
1235 0xac, 0xac, 0xac, 0xac, 0x00, 0x00, 0xac, 0xac,
1236
1237 0xec, 0x01, 0x00, 0xac, 0xac, 0xac, 0x2c, 0xac,
1238 0xa2, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac, 0xac,
1239 0xac, 0xac, 0xac, 0xac, 0x64, 0xf2
1240 }
1241 },
1242 {
1243 32,
1244 {
1245 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f,
1246 0x01, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00,
1247 0x00, 0x00, 0xcf, 0x77, 0x77, 0x77, 0x77, 0x77,
1248 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77
1249 }
1250 },
1251 {
1252 16,
1253 {
1254 0x02, 0xee, 0x7c, 0x8c, 0x54, 0x6d, 0xde, 0xb1,
1255 0xa4, 0x67, 0xe4, 0xc3, 0x98, 0x11, 0x58, 0xb9
1256 }
1257 },
1258 },
1259 /*
1260 * test vectors from Andrew Moon
1261 */
1262 { /* nacl */
1263 {
1264 131,
1265 {
1266 0x8e, 0x99, 0x3b, 0x9f, 0x48, 0x68, 0x12, 0x73,
1267 0xc2, 0x96, 0x50, 0xba, 0x32, 0xfc, 0x76, 0xce,
1268 0x48, 0x33, 0x2e, 0xa7, 0x16, 0x4d, 0x96, 0xa4,
1269 0x47, 0x6f, 0xb8, 0xc5, 0x31, 0xa1, 0x18, 0x6a,
1270
1271 0xc0, 0xdf, 0xc1, 0x7c, 0x98, 0xdc, 0xe8, 0x7b,
1272 0x4d, 0xa7, 0xf0, 0x11, 0xec, 0x48, 0xc9, 0x72,
1273 0x71, 0xd2, 0xc2, 0x0f, 0x9b, 0x92, 0x8f, 0xe2,
1274 0x27, 0x0d, 0x6f, 0xb8, 0x63, 0xd5, 0x17, 0x38,
1275
1276 0xb4, 0x8e, 0xee, 0xe3, 0x14, 0xa7, 0xcc, 0x8a,
1277 0xb9, 0x32, 0x16, 0x45, 0x48, 0xe5, 0x26, 0xae,
1278 0x90, 0x22, 0x43, 0x68, 0x51, 0x7a, 0xcf, 0xea,
1279 0xbd, 0x6b, 0xb3, 0x73, 0x2b, 0xc0, 0xe9, 0xda,
1280
1281 0x99, 0x83, 0x2b, 0x61, 0xca, 0x01, 0xb6, 0xde,
1282 0x56, 0x24, 0x4a, 0x9e, 0x88, 0xd5, 0xf9, 0xb3,
1283 0x79, 0x73, 0xf6, 0x22, 0xa4, 0x3d, 0x14, 0xa6,
1284 0x59, 0x9b, 0x1f, 0x65, 0x4c, 0xb4, 0x5a, 0x74,
1285
1286 0xe3, 0x55, 0xa5
1287 }
1288 },
1289 {
1290 32,
1291 {
1292 0xee, 0xa6, 0xa7, 0x25, 0x1c, 0x1e, 0x72, 0x91,
1293 0x6d, 0x11, 0xc2, 0xcb, 0x21, 0x4d, 0x3c, 0x25,
1294 0x25, 0x39, 0x12, 0x1d, 0x8e, 0x23, 0x4e, 0x65,
1295 0x2d, 0x65, 0x1f, 0xa4, 0xc8, 0xcf, 0xf8, 0x80
1296 }
1297 },
1298 {
1299 16,
1300 {
1301 0xf3, 0xff, 0xc7, 0x70, 0x3f, 0x94, 0x00, 0xe5,
1302 0x2a, 0x7d, 0xfb, 0x4b, 0x3d, 0x33, 0x05, 0xd9
1303 }
1304 },
1305 },
1306 { /* wrap 2^130-5 */
1307 {
1308 16,
1309 {
1310 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1311 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
1312 }
1313 },
1314 {
1315 32,
1316 {
1317 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1318 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1319 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1320 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1321 }
1322 },
1323 {
1324 16,
1325 {
1326 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1327 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1328 }
1329 },
1330 },
1331 { /* wrap 2^128 */
1332 {
1333 16,
1334 {
1335 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1336 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1337 }
1338 },
1339 {
1340 32,
1341 {
1342 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1343 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1344 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1345 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
1346 }
1347 },
1348 {
1349 16,
1350 {
1351 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1352 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1353 }
1354 },
1355 },
1356 { /* limb carry */
1357 {
1358 48,
1359 {
1360 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1361 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1362 0xf0, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1363 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1364
1365 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1366 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1367 }
1368 },
1369 {
1370 32,
1371 {
1372 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1373 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1374 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1375 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1376 }
1377 },
1378 {
1379 16,
1380 {
1381 0x05, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1382 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1383 }
1384 },
1385 },
1386 { /* 2^130-5 */
1387 {
1388 48,
1389 {
1390 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1391 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1392 0xfb, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
1393 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe, 0xfe,
1394
1395 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
1396 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01
1397 }
1398 },
1399 {
1400 32,
1401 {
1402 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1403 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1404 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1405 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1406 }
1407 },
1408 {
1409 16,
1410 {
1411 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1412 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1413
1414 }
1415 },
1416 },
1417 { /* 2^130-6 */
1418 {
1419 16,
1420 {
1421 0xfd, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1422 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
1423 }
1424 },
1425 {
1426 32,
1427 {
1428 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1429 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1430 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1431 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1432 }
1433 },
1434 {
1435 16,
1436 {
1437 0xfa, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
1438 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
1439 }
1440 },
1441 },
1442 { /* 5*H+L reduction intermediate */
1443 {
1444 64,
1445 {
1446 0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
1447 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1448 0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
1449 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1450
1451 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1452 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1453 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1454 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1455 }
1456 },
1457 {
1458 32,
1459 {
1460 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1461 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1462 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1463 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1464 }
1465 },
1466 {
1467 16,
1468 {
1469 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1470 0x55, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1471 }
1472 },
1473 },
1474 { /* 5*H+L reduction final */
1475 {
1476 48,
1477 {
1478 0xe3, 0x35, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0xb9,
1479 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1480 0x33, 0x94, 0xd7, 0x50, 0x5e, 0x43, 0x79, 0xcd,
1481 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1482
1483 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1484 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1485
1486 }
1487 },
1488 {
1489 32,
1490 {
1491 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1492 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1493 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1494 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1495 }
1496 },
1497 {
1498 16,
1499 {
1500 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1501 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
1502 }
1503 }
1504 }
1505 };
1506
test_poly1305(int idx)1507 static int test_poly1305(int idx)
1508 {
1509 POLY1305 poly1305;
1510 const TESTDATA test = tests[idx];
1511 const unsigned char *in = test.input.data;
1512 size_t inlen = test.input.size;
1513 const unsigned char *key = test.key.data;
1514 const unsigned char *expected = test.expected.data;
1515 size_t expectedlen = test.expected.size;
1516 unsigned char out[16];
1517
1518 if (!TEST_size_t_eq(expectedlen, sizeof(out)))
1519 return 0;
1520
1521 Poly1305_Init(&poly1305, key);
1522 Poly1305_Update(&poly1305, in, inlen);
1523 Poly1305_Final(&poly1305, out);
1524
1525 if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
1526 TEST_info("Poly1305 test #%d failed.", idx);
1527 return 0;
1528 }
1529
1530 if (inlen > 16) {
1531 Poly1305_Init(&poly1305, key);
1532 Poly1305_Update(&poly1305, in, 1);
1533 Poly1305_Update(&poly1305, in+1, inlen-1);
1534 Poly1305_Final(&poly1305, out);
1535
1536 if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
1537 TEST_info("Poly1305 test #%d/1+(N-1) failed.", idx);
1538 return 0;
1539 }
1540 }
1541
1542 if (inlen > 32) {
1543 size_t half = inlen / 2;
1544
1545 Poly1305_Init(&poly1305, key);
1546 Poly1305_Update(&poly1305, in, half);
1547 Poly1305_Update(&poly1305, in+half, inlen-half);
1548 Poly1305_Final(&poly1305, out);
1549
1550 if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
1551 TEST_info("Poly1305 test #%d/2 failed.", idx);
1552 return 0;
1553 }
1554
1555 for (half = 16; half < inlen; half += 16) {
1556 Poly1305_Init(&poly1305, key);
1557 Poly1305_Update(&poly1305, in, half);
1558 Poly1305_Update(&poly1305, in+half, inlen-half);
1559 Poly1305_Final(&poly1305, out);
1560
1561 if (!TEST_mem_eq(out, expectedlen, expected, expectedlen)) {
1562 TEST_info("Poly1305 test #%d/%zu+%zu failed.",
1563 idx, half, inlen-half);
1564 return 0;
1565 }
1566 }
1567 }
1568
1569 return 1;
1570 }
1571
setup_tests(void)1572 int setup_tests(void)
1573 {
1574 ADD_ALL_TESTS(test_poly1305, OSSL_NELEM(tests));
1575 return 1;
1576 }
1577