1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2016-2017 Intel Corporation
5 #ifndef TEST_CRYPTODEV_HASH_TEST_VECTORS_H_
6 #define TEST_CRYPTODEV_HASH_TEST_VECTORS_H_
8 #ifdef RTE_LIBRTE_PMD_AESNI_MB
9 #include <intel-ipsec-mb.h>
12 static const uint8_t plaintext_hash[] = {
13 "What a lousy earth! He wondered how many people "
14 "were destitute that same night even in his own "
15 "prosperous country, how many homes were "
16 "shanties, how many husbands were drunk and "
17 "wives socked, and how many children were "
18 "bullied, abused, or abandoned. How many "
19 "families hungered for food they could not "
20 "afford to buy? How many hearts were broken? How "
21 "many suicides would take place that same night, "
22 "how many people would go insane? How many "
23 "cockroaches and landlords would triumph? How "
24 "many winners were losers, successes failures, "
25 "and rich men poor men? How many wise guys were "
26 "stupid? How many happy endings were unhappy "
27 "endings? How many honest men were liars, brave "
28 "men cowards, loyal men traitors, how many "
29 "sainted men were corrupt, how many people in "
30 "positions of trust had sold their souls to "
31 "bodyguards, how many had never had souls? How "
32 "many straight-and-narrow paths were crooked "
33 "paths? How many best families were worst "
34 "families and how many good people were bad "
35 "people? When you added them all up and then "
36 "subtracted, you might be left with only the "
37 "children, and perhaps with Albert Einstein and "
38 "an old violinist or sculptor somewhere."
41 static const struct blockcipher_test_data
43 .auth_algo = RTE_CRYPTO_AUTH_MD5,
45 .data = plaintext_hash,
50 0xB3, 0xE6, 0xBB, 0x50, 0x41, 0x35, 0x3C, 0x6B,
51 0x7A, 0xFF, 0xD2, 0x64, 0xAF, 0xD5, 0x1C, 0xB2
57 static const struct blockcipher_test_data
58 hmac_md5_test_vector = {
59 .auth_algo = RTE_CRYPTO_AUTH_MD5_HMAC,
61 .data = plaintext_hash,
66 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
67 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD
73 0x50, 0xE8, 0xDE, 0xC5, 0xC1, 0x76, 0xAC, 0xAE,
74 0x15, 0x4A, 0xF1, 0x7F, 0x7E, 0x04, 0x42, 0x9B
81 static const struct blockcipher_test_data
83 .auth_algo = RTE_CRYPTO_AUTH_SHA1,
85 .data = plaintext_hash,
90 0xA2, 0x8D, 0x40, 0x78, 0xDD, 0x9F, 0xBB, 0xD5,
91 0x35, 0x62, 0xFB, 0xFA, 0x93, 0xFD, 0x7D, 0x70,
92 0xA6, 0x7D, 0x45, 0xCA
99 static const struct blockcipher_test_data
100 hmac_sha1_test_vector = {
101 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
103 .data = plaintext_hash,
108 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
109 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
110 0xDE, 0xF4, 0xDE, 0xAD
116 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
117 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
118 0x3F, 0x91, 0x64, 0x59
125 static const struct blockcipher_test_data
126 sha224_test_vector = {
127 .auth_algo = RTE_CRYPTO_AUTH_SHA224,
129 .data = plaintext_hash,
134 0x91, 0xE7, 0xCD, 0x75, 0x14, 0x9C, 0xA9, 0xE9,
135 0x2E, 0x46, 0x12, 0x20, 0x22, 0xF9, 0x68, 0x28,
136 0x39, 0x26, 0xDF, 0xB5, 0x78, 0x62, 0xB2, 0x6E,
137 0x5E, 0x8F, 0x25, 0x84
144 static const struct blockcipher_test_data
145 hmac_sha224_test_vector = {
146 .auth_algo = RTE_CRYPTO_AUTH_SHA224_HMAC,
148 .data = plaintext_hash,
153 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
154 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
155 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
156 0xFB, 0xBF, 0xB0, 0x8C
162 0x70, 0x0F, 0x04, 0x4D, 0x22, 0x02, 0x7D, 0x31,
163 0x36, 0xDA, 0x77, 0x19, 0xB9, 0x66, 0x37, 0x7B,
164 0xF1, 0x8A, 0x63, 0xBB, 0x5D, 0x1D, 0xE3, 0x9F,
165 0x92, 0xF6, 0xAA, 0x19
172 static const struct blockcipher_test_data
173 sha256_test_vector = {
174 .auth_algo = RTE_CRYPTO_AUTH_SHA256,
176 .data = plaintext_hash,
181 0x7F, 0xF1, 0x0C, 0xF5, 0x90, 0x97, 0x19, 0x0F,
182 0x00, 0xE4, 0x83, 0x01, 0xCA, 0x59, 0x00, 0x2E,
183 0x1F, 0xC7, 0x84, 0xEE, 0x76, 0xA6, 0x39, 0x15,
184 0x76, 0x2F, 0x87, 0xF9, 0x01, 0x06, 0xF3, 0xB7
191 static const struct blockcipher_test_data
192 hmac_sha256_test_vector = {
193 .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC,
195 .data = plaintext_hash,
200 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
201 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
202 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
203 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC
209 0xAF, 0x8F, 0x70, 0x1B, 0x4B, 0xAF, 0x34, 0xCB,
210 0x02, 0x24, 0x48, 0x45, 0x83, 0x52, 0x8F, 0x22,
211 0x06, 0x4D, 0x64, 0x09, 0x0A, 0xCC, 0x02, 0x77,
212 0x71, 0x83, 0x48, 0x71, 0x07, 0x02, 0x25, 0x17
219 static const struct blockcipher_test_data
220 sha384_test_vector = {
221 .auth_algo = RTE_CRYPTO_AUTH_SHA384,
223 .data = plaintext_hash,
228 0x1D, 0xE7, 0x3F, 0x55, 0x86, 0xFE, 0x48, 0x9F,
229 0xAC, 0xC6, 0x85, 0x32, 0xFA, 0x8E, 0xA6, 0x77,
230 0x25, 0x84, 0xA5, 0x98, 0x8D, 0x0B, 0x80, 0xF4,
231 0xEB, 0x2C, 0xFB, 0x6C, 0xEA, 0x7B, 0xFD, 0xD5,
232 0xAD, 0x41, 0xAB, 0x15, 0xB0, 0x03, 0x15, 0xEC,
233 0x9E, 0x3D, 0xED, 0xCB, 0x80, 0x7B, 0xF4, 0xB6
240 static const struct blockcipher_test_data
241 hmac_sha384_test_vector = {
242 .auth_algo = RTE_CRYPTO_AUTH_SHA384_HMAC,
244 .data = plaintext_hash,
249 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
250 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
251 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
252 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC,
253 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05,
254 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89
260 0xE2, 0x83, 0x18, 0x55, 0xB5, 0x8D, 0x94, 0x9B,
261 0x01, 0xB6, 0xE2, 0x57, 0x7A, 0x62, 0xF5, 0xF4,
262 0xAB, 0x39, 0xF3, 0x3C, 0x28, 0xA0, 0x0F, 0xCC,
263 0xEE, 0x1C, 0xF1, 0xF8, 0x69, 0xF1, 0x24, 0x3B,
264 0x10, 0x90, 0x0A, 0xE3, 0xF0, 0x59, 0xDD, 0xC0,
265 0x6F, 0xE6, 0x8C, 0x84, 0xD5, 0x03, 0xF8, 0x9E
272 static const struct blockcipher_test_data
273 sha512_test_vector = {
274 .auth_algo = RTE_CRYPTO_AUTH_SHA512,
276 .data = plaintext_hash,
281 0xB9, 0xBA, 0x28, 0x48, 0x3C, 0xC2, 0xD3, 0x65,
282 0x4A, 0xD6, 0x00, 0x1D, 0xCE, 0x61, 0x64, 0x54,
283 0x45, 0x8C, 0x64, 0x0E, 0xED, 0x0E, 0xD8, 0x1C,
284 0x72, 0xCE, 0xD2, 0x44, 0x91, 0xC8, 0xEB, 0xC7,
285 0x99, 0xC5, 0xCA, 0x89, 0x72, 0x64, 0x96, 0x41,
286 0xC8, 0xEA, 0xB2, 0x4E, 0xD1, 0x21, 0x13, 0x49,
287 0x64, 0x4E, 0x15, 0x68, 0x12, 0x67, 0x26, 0x0F,
288 0x2C, 0x3C, 0x83, 0x25, 0x27, 0x86, 0xF0, 0xDB
295 static const struct blockcipher_test_data
296 hmac_sha512_test_vector = {
297 .auth_algo = RTE_CRYPTO_AUTH_SHA512_HMAC,
299 .data = plaintext_hash,
304 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
305 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
306 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92,
307 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC,
308 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05,
309 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89,
310 0xDE, 0xAA, 0x36, 0x44, 0x98, 0x93, 0x97, 0x1E,
311 0x6D, 0x53, 0x83, 0x87, 0xB3, 0xB7, 0x56, 0x41
317 0xB8, 0x0B, 0x35, 0x97, 0x3F, 0x24, 0x3F, 0x05,
318 0x2A, 0x7F, 0x2F, 0xD8, 0xD7, 0x56, 0x58, 0xAD,
319 0x6F, 0x8D, 0x1F, 0x4C, 0x30, 0xF9, 0xA8, 0x29,
320 0x7A, 0xE0, 0x8D, 0x88, 0xF5, 0x2E, 0x94, 0xF5,
321 0x06, 0xF7, 0x5D, 0x57, 0x32, 0xA8, 0x49, 0x29,
322 0xEA, 0x6B, 0x6D, 0x95, 0xBD, 0x76, 0xF5, 0x79,
323 0x97, 0x37, 0x0F, 0xBE, 0xC2, 0x45, 0xA0, 0x87,
324 0xAF, 0x24, 0x27, 0x0C, 0x78, 0xBA, 0xBE, 0x20
331 static const struct blockcipher_test_data
333 .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC,
335 .data = plaintext_hash,
340 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
341 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
347 0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96,
348 0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27
355 static const struct blockcipher_test_data
356 null_auth_test_vector = {
357 .auth_algo = RTE_CRYPTO_AUTH_NULL,
358 .ciphertext = { /* arbitrary data - shouldn't be used */
359 .data = plaintext_hash,
362 .auth_key = { /* arbitrary data - shouldn't be used */
364 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
365 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
371 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
372 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
373 0x00, 0x00, 0x00, 0x00
380 static const struct blockcipher_test_data
381 cmac_test_vector_12 = {
382 .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC,
384 .data = plaintext_hash,
389 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
390 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
396 0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96,
397 0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27
404 static const struct blockcipher_test_case hash_test_cases[] = {
406 .test_descr = "MD5 Digest",
407 .test_data = &md5_test_vector,
408 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
411 .test_descr = "MD5 Digest Verify",
412 .test_data = &md5_test_vector,
413 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
416 .test_descr = "HMAC-MD5 Digest",
417 .test_data = &hmac_md5_test_vector,
418 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
421 .test_descr = "HMAC-MD5 Digest Verify",
422 .test_data = &hmac_md5_test_vector,
423 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
426 .test_descr = "SHA1 Digest",
427 .test_data = &sha1_test_vector,
428 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
431 .test_descr = "SHA1 Digest Verify",
432 .test_data = &sha1_test_vector,
433 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
436 .test_descr = "HMAC-SHA1 Digest",
437 .test_data = &hmac_sha1_test_vector,
438 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
441 .test_descr = "HMAC-SHA1 Digest Scatter Gather",
442 .test_data = &hmac_sha1_test_vector,
443 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
444 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
447 .test_descr = "HMAC-SHA1 Digest Verify",
448 .test_data = &hmac_sha1_test_vector,
449 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
452 .test_descr = "HMAC-SHA1 Digest Verify Scatter Gather",
453 .test_data = &hmac_sha1_test_vector,
454 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
455 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
458 .test_descr = "SHA224 Digest",
459 .test_data = &sha224_test_vector,
460 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
463 .test_descr = "SHA224 Digest Verify",
464 .test_data = &sha224_test_vector,
465 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
468 .test_descr = "HMAC-SHA224 Digest",
469 .test_data = &hmac_sha224_test_vector,
470 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
473 .test_descr = "HMAC-SHA224 Digest Verify",
474 .test_data = &hmac_sha224_test_vector,
475 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
478 .test_descr = "SHA256 Digest",
479 .test_data = &sha256_test_vector,
480 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
483 .test_descr = "SHA256 Digest Verify",
484 .test_data = &sha256_test_vector,
485 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
488 .test_descr = "HMAC-SHA256 Digest",
489 .test_data = &hmac_sha256_test_vector,
490 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
493 .test_descr = "HMAC-SHA256 Digest Verify",
494 .test_data = &hmac_sha256_test_vector,
495 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
498 .test_descr = "SHA384 Digest",
499 .test_data = &sha384_test_vector,
500 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
503 .test_descr = "SHA384 Digest Verify",
504 .test_data = &sha384_test_vector,
505 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
508 .test_descr = "HMAC-SHA384 Digest",
509 .test_data = &hmac_sha384_test_vector,
510 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
513 .test_descr = "HMAC-SHA384 Digest Verify",
514 .test_data = &hmac_sha384_test_vector,
515 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
518 .test_descr = "SHA512 Digest",
519 .test_data = &sha512_test_vector,
520 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
523 .test_descr = "SHA512 Digest Verify",
524 .test_data = &sha512_test_vector,
525 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
528 .test_descr = "HMAC-SHA512 Digest",
529 .test_data = &hmac_sha512_test_vector,
530 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
533 .test_descr = "HMAC-SHA512 Digest Verify",
534 .test_data = &hmac_sha512_test_vector,
535 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
538 .test_descr = "CMAC Digest 12B",
539 .test_data = &cmac_test_vector_12,
540 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
543 .test_descr = "CMAC Digest Verify 12B",
544 .test_data = &cmac_test_vector_12,
545 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
548 .test_descr = "CMAC Digest 16B",
549 .test_data = &cmac_test_vector,
550 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
553 .test_descr = "CMAC Digest Verify 16B",
554 .test_data = &cmac_test_vector,
555 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
558 .test_descr = "NULL algo - auth generate",
559 .test_data = &null_auth_test_vector,
560 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
563 .test_descr = "NULL algo - auth verify",
564 .test_data = &null_auth_test_vector,
565 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
568 .test_descr = "NULL algo - auth generate - OOP",
569 .test_data = &null_auth_test_vector,
570 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
571 .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
574 .test_descr = "NULL algo - auth verify - OOP",
575 .test_data = &null_auth_test_vector,
576 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
577 .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
582 #endif /* TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ */