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_HASH_TEST_VECTORS_H_ 34 #define TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ 35 36 static const uint8_t plaintext_hash[] = { 37 "What a lousy earth! He wondered how many people " 38 "were destitute that same night even in his own " 39 "prosperous country, how many homes were " 40 "shanties, how many husbands were drunk and " 41 "wives socked, and how many children were " 42 "bullied, abused, or abandoned. How many " 43 "families hungered for food they could not " 44 "afford to buy? How many hearts were broken? How " 45 "many suicides would take place that same night, " 46 "how many people would go insane? How many " 47 "cockroaches and landlords would triumph? How " 48 "many winners were losers, successes failures, " 49 "and rich men poor men? How many wise guys were " 50 "stupid? How many happy endings were unhappy " 51 "endings? How many honest men were liars, brave " 52 "men cowards, loyal men traitors, how many " 53 "sainted men were corrupt, how many people in " 54 "positions of trust had sold their souls to " 55 "bodyguards, how many had never had souls? How " 56 "many straight-and-narrow paths were crooked " 57 "paths? How many best families were worst " 58 "families and how many good people were bad " 59 "people? When you added them all up and then " 60 "subtracted, you might be left with only the " 61 "children, and perhaps with Albert Einstein and " 62 "an old violinist or sculptor somewhere." 63 }; 64 65 static const struct blockcipher_test_data 66 md5_test_vector = { 67 .auth_algo = RTE_CRYPTO_AUTH_MD5, 68 .ciphertext = { 69 .data = plaintext_hash, 70 .len = 512 71 }, 72 .digest = { 73 .data = { 74 0xB3, 0xE6, 0xBB, 0x50, 0x41, 0x35, 0x3C, 0x6B, 75 0x7A, 0xFF, 0xD2, 0x64, 0xAF, 0xD5, 0x1C, 0xB2 76 }, 77 .len = 16 78 } 79 }; 80 81 static const struct blockcipher_test_data 82 hmac_md5_test_vector = { 83 .auth_algo = RTE_CRYPTO_AUTH_MD5_HMAC, 84 .ciphertext = { 85 .data = plaintext_hash, 86 .len = 512 87 }, 88 .auth_key = { 89 .data = { 90 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 91 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD 92 }, 93 .len = 16 94 }, 95 .digest = { 96 .data = { 97 0x50, 0xE8, 0xDE, 0xC5, 0xC1, 0x76, 0xAC, 0xAE, 98 0x15, 0x4A, 0xF1, 0x7F, 0x7E, 0x04, 0x42, 0x9B 99 }, 100 .len = 16 101 } 102 }; 103 104 static const struct blockcipher_test_data 105 sha1_test_vector = { 106 .auth_algo = RTE_CRYPTO_AUTH_SHA1, 107 .ciphertext = { 108 .data = plaintext_hash, 109 .len = 512 110 }, 111 .digest = { 112 .data = { 113 0xA2, 0x8D, 0x40, 0x78, 0xDD, 0x9F, 0xBB, 0xD5, 114 0x35, 0x62, 0xFB, 0xFA, 0x93, 0xFD, 0x7D, 0x70, 115 0xA6, 0x7D, 0x45, 0xCA 116 }, 117 .len = 20 118 } 119 }; 120 121 static const struct blockcipher_test_data 122 hmac_sha1_test_vector = { 123 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 124 .ciphertext = { 125 .data = plaintext_hash, 126 .len = 512 127 }, 128 .auth_key = { 129 .data = { 130 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 131 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 132 0xDE, 0xF4, 0xDE, 0xAD 133 }, 134 .len = 20 135 }, 136 .digest = { 137 .data = { 138 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77, 139 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17, 140 0x3F, 0x91, 0x64, 0x59 141 }, 142 .len = 20 143 } 144 }; 145 146 static const struct blockcipher_test_data 147 sha224_test_vector = { 148 .auth_algo = RTE_CRYPTO_AUTH_SHA224, 149 .ciphertext = { 150 .data = plaintext_hash, 151 .len = 512 152 }, 153 .digest = { 154 .data = { 155 0x91, 0xE7, 0xCD, 0x75, 0x14, 0x9C, 0xA9, 0xE9, 156 0x2E, 0x46, 0x12, 0x20, 0x22, 0xF9, 0x68, 0x28, 157 0x39, 0x26, 0xDF, 0xB5, 0x78, 0x62, 0xB2, 0x6E, 158 0x5E, 0x8F, 0x25, 0x84 159 }, 160 .len = 28 161 } 162 }; 163 164 static const struct blockcipher_test_data 165 hmac_sha224_test_vector = { 166 .auth_algo = RTE_CRYPTO_AUTH_SHA224_HMAC, 167 .ciphertext = { 168 .data = plaintext_hash, 169 .len = 512 170 }, 171 .auth_key = { 172 .data = { 173 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 174 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 175 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 176 0xFB, 0xBF, 0xB0, 0x8C 177 }, 178 .len = 28 179 }, 180 .digest = { 181 .data = { 182 0x70, 0x0F, 0x04, 0x4D, 0x22, 0x02, 0x7D, 0x31, 183 0x36, 0xDA, 0x77, 0x19, 0xB9, 0x66, 0x37, 0x7B, 184 0xF1, 0x8A, 0x63, 0xBB, 0x5D, 0x1D, 0xE3, 0x9F, 185 0x92, 0xF6, 0xAA, 0x19 186 }, 187 .len = 28 188 } 189 }; 190 191 static const struct blockcipher_test_data 192 sha256_test_vector = { 193 .auth_algo = RTE_CRYPTO_AUTH_SHA256, 194 .ciphertext = { 195 .data = plaintext_hash, 196 .len = 512 197 }, 198 .digest = { 199 .data = { 200 0x7F, 0xF1, 0x0C, 0xF5, 0x90, 0x97, 0x19, 0x0F, 201 0x00, 0xE4, 0x83, 0x01, 0xCA, 0x59, 0x00, 0x2E, 202 0x1F, 0xC7, 0x84, 0xEE, 0x76, 0xA6, 0x39, 0x15, 203 0x76, 0x2F, 0x87, 0xF9, 0x01, 0x06, 0xF3, 0xB7 204 }, 205 .len = 32 206 } 207 }; 208 209 static const struct blockcipher_test_data 210 hmac_sha256_test_vector = { 211 .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC, 212 .ciphertext = { 213 .data = plaintext_hash, 214 .len = 512 215 }, 216 .auth_key = { 217 .data = { 218 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 219 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 220 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 221 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC 222 }, 223 .len = 32 224 }, 225 .digest = { 226 .data = { 227 0xAF, 0x8F, 0x70, 0x1B, 0x4B, 0xAF, 0x34, 0xCB, 228 0x02, 0x24, 0x48, 0x45, 0x83, 0x52, 0x8F, 0x22, 229 0x06, 0x4D, 0x64, 0x09, 0x0A, 0xCC, 0x02, 0x77, 230 0x71, 0x83, 0x48, 0x71, 0x07, 0x02, 0x25, 0x17 231 }, 232 .len = 32 233 } 234 }; 235 236 static const struct blockcipher_test_data 237 sha384_test_vector = { 238 .auth_algo = RTE_CRYPTO_AUTH_SHA384, 239 .ciphertext = { 240 .data = plaintext_hash, 241 .len = 512 242 }, 243 .digest = { 244 .data = { 245 0x1D, 0xE7, 0x3F, 0x55, 0x86, 0xFE, 0x48, 0x9F, 246 0xAC, 0xC6, 0x85, 0x32, 0xFA, 0x8E, 0xA6, 0x77, 247 0x25, 0x84, 0xA5, 0x98, 0x8D, 0x0B, 0x80, 0xF4, 248 0xEB, 0x2C, 0xFB, 0x6C, 0xEA, 0x7B, 0xFD, 0xD5, 249 0xAD, 0x41, 0xAB, 0x15, 0xB0, 0x03, 0x15, 0xEC, 250 0x9E, 0x3D, 0xED, 0xCB, 0x80, 0x7B, 0xF4, 0xB6 251 }, 252 .len = 48 253 } 254 }; 255 256 static const struct blockcipher_test_data 257 hmac_sha384_test_vector = { 258 .auth_algo = RTE_CRYPTO_AUTH_SHA384_HMAC, 259 .ciphertext = { 260 .data = plaintext_hash, 261 .len = 512 262 }, 263 .auth_key = { 264 .data = { 265 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 266 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 267 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 268 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 269 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 270 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89 271 }, 272 .len = 48 273 }, 274 .digest = { 275 .data = { 276 0xE2, 0x83, 0x18, 0x55, 0xB5, 0x8D, 0x94, 0x9B, 277 0x01, 0xB6, 0xE2, 0x57, 0x7A, 0x62, 0xF5, 0xF4, 278 0xAB, 0x39, 0xF3, 0x3C, 0x28, 0xA0, 0x0F, 0xCC, 279 0xEE, 0x1C, 0xF1, 0xF8, 0x69, 0xF1, 0x24, 0x3B, 280 0x10, 0x90, 0x0A, 0xE3, 0xF0, 0x59, 0xDD, 0xC0, 281 0x6F, 0xE6, 0x8C, 0x84, 0xD5, 0x03, 0xF8, 0x9E 282 }, 283 .len = 48 284 } 285 }; 286 287 static const struct blockcipher_test_data 288 sha512_test_vector = { 289 .auth_algo = RTE_CRYPTO_AUTH_SHA512, 290 .ciphertext = { 291 .data = plaintext_hash, 292 .len = 512 293 }, 294 .digest = { 295 .data = { 296 0xB9, 0xBA, 0x28, 0x48, 0x3C, 0xC2, 0xD3, 0x65, 297 0x4A, 0xD6, 0x00, 0x1D, 0xCE, 0x61, 0x64, 0x54, 298 0x45, 0x8C, 0x64, 0x0E, 0xED, 0x0E, 0xD8, 0x1C, 299 0x72, 0xCE, 0xD2, 0x44, 0x91, 0xC8, 0xEB, 0xC7, 300 0x99, 0xC5, 0xCA, 0x89, 0x72, 0x64, 0x96, 0x41, 301 0xC8, 0xEA, 0xB2, 0x4E, 0xD1, 0x21, 0x13, 0x49, 302 0x64, 0x4E, 0x15, 0x68, 0x12, 0x67, 0x26, 0x0F, 303 0x2C, 0x3C, 0x83, 0x25, 0x27, 0x86, 0xF0, 0xDB 304 }, 305 .len = 64 306 } 307 }; 308 309 static const struct blockcipher_test_data 310 hmac_sha512_test_vector = { 311 .auth_algo = RTE_CRYPTO_AUTH_SHA512_HMAC, 312 .ciphertext = { 313 .data = plaintext_hash, 314 .len = 512 315 }, 316 .auth_key = { 317 .data = { 318 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 319 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 320 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 321 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 322 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 323 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89, 324 0xDE, 0xAA, 0x36, 0x44, 0x98, 0x93, 0x97, 0x1E, 325 0x6D, 0x53, 0x83, 0x87, 0xB3, 0xB7, 0x56, 0x41 326 }, 327 .len = 64 328 }, 329 .digest = { 330 .data = { 331 0xB8, 0x0B, 0x35, 0x97, 0x3F, 0x24, 0x3F, 0x05, 332 0x2A, 0x7F, 0x2F, 0xD8, 0xD7, 0x56, 0x58, 0xAD, 333 0x6F, 0x8D, 0x1F, 0x4C, 0x30, 0xF9, 0xA8, 0x29, 334 0x7A, 0xE0, 0x8D, 0x88, 0xF5, 0x2E, 0x94, 0xF5, 335 0x06, 0xF7, 0x5D, 0x57, 0x32, 0xA8, 0x49, 0x29, 336 0xEA, 0x6B, 0x6D, 0x95, 0xBD, 0x76, 0xF5, 0x79, 337 0x97, 0x37, 0x0F, 0xBE, 0xC2, 0x45, 0xA0, 0x87, 338 0xAF, 0x24, 0x27, 0x0C, 0x78, 0xBA, 0xBE, 0x20 339 }, 340 .len = 64 341 } 342 }; 343 344 static const struct blockcipher_test_case hash_test_cases[] = { 345 { 346 .test_descr = "MD5 Digest", 347 .test_data = &md5_test_vector, 348 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 349 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 350 }, 351 { 352 .test_descr = "MD5 Digest Verify", 353 .test_data = &md5_test_vector, 354 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 355 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 356 }, 357 { 358 .test_descr = "HMAC-MD5 Digest", 359 .test_data = &hmac_md5_test_vector, 360 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 361 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 362 }, 363 { 364 .test_descr = "HMAC-MD5 Digest Verify", 365 .test_data = &hmac_md5_test_vector, 366 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 367 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 368 }, 369 { 370 .test_descr = "SHA1 Digest", 371 .test_data = &sha1_test_vector, 372 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 373 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 374 }, 375 { 376 .test_descr = "SHA1 Digest Verify", 377 .test_data = &sha1_test_vector, 378 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 379 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 380 }, 381 { 382 .test_descr = "HMAC-SHA1 Digest", 383 .test_data = &hmac_sha1_test_vector, 384 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 385 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 386 }, 387 { 388 .test_descr = "HMAC-SHA1 Digest Verify", 389 .test_data = &hmac_sha1_test_vector, 390 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 391 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 392 }, 393 { 394 .test_descr = "SHA224 Digest", 395 .test_data = &sha224_test_vector, 396 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 397 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 398 }, 399 { 400 .test_descr = "SHA224 Digest Verify", 401 .test_data = &sha224_test_vector, 402 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 403 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 404 }, 405 { 406 .test_descr = "HMAC-SHA224 Digest", 407 .test_data = &hmac_sha224_test_vector, 408 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 409 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 410 }, 411 { 412 .test_descr = "HMAC-SHA224 Digest Verify", 413 .test_data = &hmac_sha224_test_vector, 414 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 415 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 416 }, 417 { 418 .test_descr = "SHA256 Digest", 419 .test_data = &sha256_test_vector, 420 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 421 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 422 }, 423 { 424 .test_descr = "SHA256 Digest Verify", 425 .test_data = &sha256_test_vector, 426 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 427 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 428 }, 429 { 430 .test_descr = "HMAC-SHA256 Digest", 431 .test_data = &hmac_sha256_test_vector, 432 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 433 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 434 }, 435 { 436 .test_descr = "HMAC-SHA256 Digest Verify", 437 .test_data = &hmac_sha256_test_vector, 438 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 439 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 440 }, 441 { 442 .test_descr = "SHA384 Digest", 443 .test_data = &sha384_test_vector, 444 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 445 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 446 }, 447 { 448 .test_descr = "SHA384 Digest Verify", 449 .test_data = &sha384_test_vector, 450 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 451 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 452 }, 453 { 454 .test_descr = "HMAC-SHA384 Digest", 455 .test_data = &hmac_sha384_test_vector, 456 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 457 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 458 }, 459 { 460 .test_descr = "HMAC-SHA384 Digest Verify", 461 .test_data = &hmac_sha384_test_vector, 462 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 463 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 464 }, 465 { 466 .test_descr = "SHA512 Digest", 467 .test_data = &sha512_test_vector, 468 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 469 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 470 }, 471 { 472 .test_descr = "SHA512 Digest Verify", 473 .test_data = &sha512_test_vector, 474 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 475 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 476 }, 477 { 478 .test_descr = "HMAC-SHA512 Digest", 479 .test_data = &hmac_sha512_test_vector, 480 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 481 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 482 }, 483 { 484 .test_descr = "HMAC-SHA512 Digest Verify", 485 .test_data = &hmac_sha512_test_vector, 486 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 487 .pmd_mask = BLOCKCIPHER_TEST_TARGET_PMD_LIBCRYPTO 488 }, 489 }; 490 491 #endif /* TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ */ 492