1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright(c) 2016-2017 Intel Corporation 3 */ 4 5 #ifndef TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ 6 #define TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ 7 8 #ifdef RTE_CRYPTO_AESNI_MB 9 #if defined(RTE_ARCH_ARM) 10 #include <ipsec-mb.h> 11 #else 12 #include <intel-ipsec-mb.h> 13 #endif 14 #endif 15 16 static const uint8_t plaintext_hash[] = { 17 "What a lousy earth! He wondered how many people " 18 "were destitute that same night even in his own " 19 "prosperous country, how many homes were " 20 "shanties, how many husbands were drunk and " 21 "wives socked, and how many children were " 22 "bullied, abused, or abandoned. How many " 23 "families hungered for food they could not " 24 "afford to buy? How many hearts were broken? How " 25 "many suicides would take place that same night, " 26 "how many people would go insane? How many " 27 "cockroaches and landlords would triumph? How " 28 "many winners were losers, successes failures, " 29 "and rich men poor men? How many wise guys were " 30 "stupid? How many happy endings were unhappy " 31 "endings? How many honest men were liars, brave " 32 "men cowards, loyal men traitors, how many " 33 "sainted men were corrupt, how many people in " 34 "positions of trust had sold their souls to " 35 "bodyguards, how many had never had souls? How " 36 "many straight-and-narrow paths were crooked " 37 "paths? How many best families were worst " 38 "families and how many good people were bad " 39 "people? When you added them all up and then " 40 "subtracted, you might be left with only the " 41 "children, and perhaps with Albert Einstein and " 42 "an old violinist or sculptor somewhere." 43 }; 44 45 static const struct blockcipher_test_data 46 md5_test_vector = { 47 .auth_algo = RTE_CRYPTO_AUTH_MD5, 48 .ciphertext = { 49 .data = plaintext_hash, 50 .len = 512 51 }, 52 .digest = { 53 .data = { 54 0xB3, 0xE6, 0xBB, 0x50, 0x41, 0x35, 0x3C, 0x6B, 55 0x7A, 0xFF, 0xD2, 0x64, 0xAF, 0xD5, 0x1C, 0xB2 56 }, 57 .len = 16 58 } 59 }; 60 61 static const struct blockcipher_test_data 62 hmac_md5_test_vector = { 63 .auth_algo = RTE_CRYPTO_AUTH_MD5_HMAC, 64 .ciphertext = { 65 .data = plaintext_hash, 66 .len = 512 67 }, 68 .auth_key = { 69 .data = { 70 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 71 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD 72 }, 73 .len = 16 74 }, 75 .digest = { 76 .data = { 77 0x50, 0xE8, 0xDE, 0xC5, 0xC1, 0x76, 0xAC, 0xAE, 78 0x15, 0x4A, 0xF1, 0x7F, 0x7E, 0x04, 0x42, 0x9B 79 }, 80 .len = 16, 81 .truncated_len = 12 82 } 83 }; 84 85 static const struct blockcipher_test_data 86 sha1_test_vector = { 87 .auth_algo = RTE_CRYPTO_AUTH_SHA1, 88 .ciphertext = { 89 .data = plaintext_hash, 90 .len = 512 91 }, 92 .digest = { 93 .data = { 94 0xA2, 0x8D, 0x40, 0x78, 0xDD, 0x9F, 0xBB, 0xD5, 95 0x35, 0x62, 0xFB, 0xFA, 0x93, 0xFD, 0x7D, 0x70, 96 0xA6, 0x7D, 0x45, 0xCA 97 }, 98 .len = 20, 99 .truncated_len = 20 100 } 101 }; 102 103 static const struct blockcipher_test_data 104 hmac_sha1_test_vector = { 105 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC, 106 .ciphertext = { 107 .data = plaintext_hash, 108 .len = 512 109 }, 110 .auth_key = { 111 .data = { 112 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 113 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 114 0xDE, 0xF4, 0xDE, 0xAD 115 }, 116 .len = 20 117 }, 118 .digest = { 119 .data = { 120 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77, 121 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17, 122 0x3F, 0x91, 0x64, 0x59 123 }, 124 .len = 20, 125 .truncated_len = 12 126 } 127 }; 128 129 static const struct blockcipher_test_data 130 sha224_test_vector = { 131 .auth_algo = RTE_CRYPTO_AUTH_SHA224, 132 .ciphertext = { 133 .data = plaintext_hash, 134 .len = 512 135 }, 136 .digest = { 137 .data = { 138 0x91, 0xE7, 0xCD, 0x75, 0x14, 0x9C, 0xA9, 0xE9, 139 0x2E, 0x46, 0x12, 0x20, 0x22, 0xF9, 0x68, 0x28, 140 0x39, 0x26, 0xDF, 0xB5, 0x78, 0x62, 0xB2, 0x6E, 141 0x5E, 0x8F, 0x25, 0x84 142 }, 143 .len = 28, 144 .truncated_len = 28 145 } 146 }; 147 148 static const struct blockcipher_test_data 149 hmac_sha224_test_vector = { 150 .auth_algo = RTE_CRYPTO_AUTH_SHA224_HMAC, 151 .ciphertext = { 152 .data = plaintext_hash, 153 .len = 512 154 }, 155 .auth_key = { 156 .data = { 157 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 158 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 159 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 160 0xFB, 0xBF, 0xB0, 0x8C 161 }, 162 .len = 28 163 }, 164 .digest = { 165 .data = { 166 0x70, 0x0F, 0x04, 0x4D, 0x22, 0x02, 0x7D, 0x31, 167 0x36, 0xDA, 0x77, 0x19, 0xB9, 0x66, 0x37, 0x7B, 168 0xF1, 0x8A, 0x63, 0xBB, 0x5D, 0x1D, 0xE3, 0x9F, 169 0x92, 0xF6, 0xAA, 0x19 170 }, 171 .len = 28, 172 .truncated_len = 14 173 } 174 }; 175 176 static const struct blockcipher_test_data 177 sha256_test_vector = { 178 .auth_algo = RTE_CRYPTO_AUTH_SHA256, 179 .ciphertext = { 180 .data = plaintext_hash, 181 .len = 512 182 }, 183 .digest = { 184 .data = { 185 0x7F, 0xF1, 0x0C, 0xF5, 0x90, 0x97, 0x19, 0x0F, 186 0x00, 0xE4, 0x83, 0x01, 0xCA, 0x59, 0x00, 0x2E, 187 0x1F, 0xC7, 0x84, 0xEE, 0x76, 0xA6, 0x39, 0x15, 188 0x76, 0x2F, 0x87, 0xF9, 0x01, 0x06, 0xF3, 0xB7 189 }, 190 .len = 32, 191 .truncated_len = 32 192 } 193 }; 194 195 static const struct blockcipher_test_data 196 hmac_sha256_test_vector = { 197 .auth_algo = RTE_CRYPTO_AUTH_SHA256_HMAC, 198 .ciphertext = { 199 .data = plaintext_hash, 200 .len = 512 201 }, 202 .auth_key = { 203 .data = { 204 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 205 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 206 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 207 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC 208 }, 209 .len = 32 210 }, 211 .digest = { 212 .data = { 213 0xAF, 0x8F, 0x70, 0x1B, 0x4B, 0xAF, 0x34, 0xCB, 214 0x02, 0x24, 0x48, 0x45, 0x83, 0x52, 0x8F, 0x22, 215 0x06, 0x4D, 0x64, 0x09, 0x0A, 0xCC, 0x02, 0x77, 216 0x71, 0x83, 0x48, 0x71, 0x07, 0x02, 0x25, 0x17 217 }, 218 .len = 32, 219 .truncated_len = 16 220 } 221 }; 222 223 static const struct blockcipher_test_data 224 sha384_test_vector = { 225 .auth_algo = RTE_CRYPTO_AUTH_SHA384, 226 .ciphertext = { 227 .data = plaintext_hash, 228 .len = 512 229 }, 230 .digest = { 231 .data = { 232 0x1D, 0xE7, 0x3F, 0x55, 0x86, 0xFE, 0x48, 0x9F, 233 0xAC, 0xC6, 0x85, 0x32, 0xFA, 0x8E, 0xA6, 0x77, 234 0x25, 0x84, 0xA5, 0x98, 0x8D, 0x0B, 0x80, 0xF4, 235 0xEB, 0x2C, 0xFB, 0x6C, 0xEA, 0x7B, 0xFD, 0xD5, 236 0xAD, 0x41, 0xAB, 0x15, 0xB0, 0x03, 0x15, 0xEC, 237 0x9E, 0x3D, 0xED, 0xCB, 0x80, 0x7B, 0xF4, 0xB6 238 }, 239 .len = 48, 240 .truncated_len = 48 241 } 242 }; 243 244 static const struct blockcipher_test_data 245 hmac_sha384_test_vector = { 246 .auth_algo = RTE_CRYPTO_AUTH_SHA384_HMAC, 247 .ciphertext = { 248 .data = plaintext_hash, 249 .len = 512 250 }, 251 .auth_key = { 252 .data = { 253 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 254 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 255 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 256 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 257 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 258 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89 259 }, 260 .len = 48 261 }, 262 .digest = { 263 .data = { 264 0xE2, 0x83, 0x18, 0x55, 0xB5, 0x8D, 0x94, 0x9B, 265 0x01, 0xB6, 0xE2, 0x57, 0x7A, 0x62, 0xF5, 0xF4, 266 0xAB, 0x39, 0xF3, 0x3C, 0x28, 0xA0, 0x0F, 0xCC, 267 0xEE, 0x1C, 0xF1, 0xF8, 0x69, 0xF1, 0x24, 0x3B, 268 0x10, 0x90, 0x0A, 0xE3, 0xF0, 0x59, 0xDD, 0xC0, 269 0x6F, 0xE6, 0x8C, 0x84, 0xD5, 0x03, 0xF8, 0x9E 270 }, 271 .len = 48, 272 .truncated_len = 24 273 } 274 }; 275 276 static const struct blockcipher_test_data 277 sha512_test_vector = { 278 .auth_algo = RTE_CRYPTO_AUTH_SHA512, 279 .ciphertext = { 280 .data = plaintext_hash, 281 .len = 512 282 }, 283 .digest = { 284 .data = { 285 0xB9, 0xBA, 0x28, 0x48, 0x3C, 0xC2, 0xD3, 0x65, 286 0x4A, 0xD6, 0x00, 0x1D, 0xCE, 0x61, 0x64, 0x54, 287 0x45, 0x8C, 0x64, 0x0E, 0xED, 0x0E, 0xD8, 0x1C, 288 0x72, 0xCE, 0xD2, 0x44, 0x91, 0xC8, 0xEB, 0xC7, 289 0x99, 0xC5, 0xCA, 0x89, 0x72, 0x64, 0x96, 0x41, 290 0xC8, 0xEA, 0xB2, 0x4E, 0xD1, 0x21, 0x13, 0x49, 291 0x64, 0x4E, 0x15, 0x68, 0x12, 0x67, 0x26, 0x0F, 292 0x2C, 0x3C, 0x83, 0x25, 0x27, 0x86, 0xF0, 0xDB 293 }, 294 .len = 64, 295 .truncated_len = 64 296 } 297 }; 298 299 static const struct blockcipher_test_data 300 hmac_sha512_test_vector = { 301 .auth_algo = RTE_CRYPTO_AUTH_SHA512_HMAC, 302 .ciphertext = { 303 .data = plaintext_hash, 304 .len = 512 305 }, 306 .auth_key = { 307 .data = { 308 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 309 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 310 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 311 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 312 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 313 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89, 314 0xDE, 0xAA, 0x36, 0x44, 0x98, 0x93, 0x97, 0x1E, 315 0x6D, 0x53, 0x83, 0x87, 0xB3, 0xB7, 0x56, 0x41 316 }, 317 .len = 64 318 }, 319 .digest = { 320 .data = { 321 0xB8, 0x0B, 0x35, 0x97, 0x3F, 0x24, 0x3F, 0x05, 322 0x2A, 0x7F, 0x2F, 0xD8, 0xD7, 0x56, 0x58, 0xAD, 323 0x6F, 0x8D, 0x1F, 0x4C, 0x30, 0xF9, 0xA8, 0x29, 324 0x7A, 0xE0, 0x8D, 0x88, 0xF5, 0x2E, 0x94, 0xF5, 325 0x06, 0xF7, 0x5D, 0x57, 0x32, 0xA8, 0x49, 0x29, 326 0xEA, 0x6B, 0x6D, 0x95, 0xBD, 0x76, 0xF5, 0x79, 327 0x97, 0x37, 0x0F, 0xBE, 0xC2, 0x45, 0xA0, 0x87, 328 0xAF, 0x24, 0x27, 0x0C, 0x78, 0xBA, 0xBE, 0x20 329 }, 330 .len = 64, 331 .truncated_len = 32 332 } 333 }; 334 335 static const struct blockcipher_test_data 336 sha3_224_test_vector = { 337 .auth_algo = RTE_CRYPTO_AUTH_SHA3_224, 338 .ciphertext = { 339 .data = plaintext_hash, 340 .len = 512 341 }, 342 .digest = { 343 .data = { 344 0xFF, 0x7D, 0xAB, 0xC4, 0xB8, 0xF8, 0x0D, 0x5C, 345 0x3A, 0xD3, 0xCD, 0x71, 0x58, 0x62, 0x24, 0x0F, 346 0xCC, 0x58, 0xE4, 0x42, 0x1B, 0xA3, 0x6F, 0xE8, 347 0x9A, 0x44, 0xBF, 0x45 348 }, 349 .len = 28, 350 .truncated_len = 28 351 } 352 }; 353 354 static const struct blockcipher_test_data 355 hmac_sha3_224_test_vector = { 356 .auth_algo = RTE_CRYPTO_AUTH_SHA3_224_HMAC, 357 .ciphertext = { 358 .data = plaintext_hash, 359 .len = 512 360 }, 361 .auth_key = { 362 .data = { 363 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 364 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 365 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 366 0xFB, 0xBF, 0xB0, 0x8C 367 }, 368 .len = 28 369 }, 370 .digest = { 371 .data = { 372 0x86, 0xDB, 0x99, 0x80, 0xFC, 0x13, 0x75, 0x4E, 373 0xB5, 0x30, 0x7A, 0x58, 0xC1, 0x0D, 0xE4, 0x00, 374 0x7F, 0xE3, 0xD8, 0xC2, 0x0E, 0x0C, 0xC1, 0xFD, 375 0xF9, 0x33, 0x05, 0x40 376 }, 377 .len = 28, 378 .truncated_len = 14 379 } 380 }; 381 382 static const struct blockcipher_test_data 383 sha3_256_test_vector = { 384 .auth_algo = RTE_CRYPTO_AUTH_SHA3_256, 385 .ciphertext = { 386 .data = plaintext_hash, 387 .len = 512 388 }, 389 .digest = { 390 .data = { 391 0xC3, 0x6B, 0x73, 0xF4, 0x97, 0x7F, 0xFA, 0xD9, 392 0x35, 0xF1, 0x1F, 0x54, 0x35, 0xC2, 0x19, 0x6C, 393 0xA2, 0x24, 0xC7, 0x01, 0xAD, 0xCC, 0xD4, 0x35, 394 0x88, 0xB9, 0x0C, 0x15, 0xAE, 0x3F, 0x92, 0x47 395 }, 396 .len = 32, 397 .truncated_len = 32 398 } 399 }; 400 401 static const struct blockcipher_test_data 402 hmac_sha3_256_test_vector = { 403 .auth_algo = RTE_CRYPTO_AUTH_SHA3_256_HMAC, 404 .ciphertext = { 405 .data = plaintext_hash, 406 .len = 512 407 }, 408 .auth_key = { 409 .data = { 410 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 411 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 412 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 413 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC 414 }, 415 .len = 32 416 }, 417 .digest = { 418 .data = { 419 0x8E, 0xB1, 0xBD, 0xEE, 0xEF, 0x26, 0xDD, 0xE7, 420 0x66, 0xBD, 0x9C, 0x2B, 0xBC, 0x5D, 0x6E, 0xC8, 421 0x8C, 0x4A, 0x9C, 0x79, 0xD7, 0x05, 0xDE, 0xFC, 422 0x21, 0x48, 0xD5, 0x95, 0x6D, 0x37, 0x0E, 0x00 423 }, 424 .len = 32, 425 .truncated_len = 16 426 } 427 }; 428 429 static const struct blockcipher_test_data 430 sha3_384_test_vector = { 431 .auth_algo = RTE_CRYPTO_AUTH_SHA3_384, 432 .ciphertext = { 433 .data = plaintext_hash, 434 .len = 512 435 }, 436 .digest = { 437 .data = { 438 0x56, 0x18, 0x64, 0x95, 0x70, 0x64, 0x32, 0x80, 439 0xB3, 0x67, 0x7B, 0xE3, 0x09, 0x75, 0x92, 0x2B, 440 0x56, 0x40, 0xA9, 0xC5, 0x19, 0x47, 0x50, 0x33, 441 0xA7, 0xA2, 0x2B, 0x45, 0x46, 0xFD, 0x69, 0xE5, 442 0xDE, 0x2B, 0x35, 0xE6, 0x06, 0xC7, 0x0D, 0x28, 443 0x5A, 0xFB, 0x37, 0x4A, 0xE5, 0x8F, 0x9F, 0x4A 444 }, 445 .len = 48, 446 .truncated_len = 48 447 } 448 }; 449 450 static const struct blockcipher_test_data 451 hmac_sha3_384_test_vector = { 452 .auth_algo = RTE_CRYPTO_AUTH_SHA3_384_HMAC, 453 .ciphertext = { 454 .data = plaintext_hash, 455 .len = 512 456 }, 457 .auth_key = { 458 .data = { 459 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 460 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 461 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 462 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 463 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 464 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89 465 }, 466 .len = 48 467 }, 468 .digest = { 469 .data = { 470 0x91, 0xCF, 0x69, 0xE5, 0x5A, 0x1A, 0x54, 0x0C, 471 0xE2, 0xA9, 0xE7, 0x06, 0xF2, 0x44, 0xA7, 0x8A, 472 0x0B, 0x5C, 0xD6, 0x34, 0x8F, 0xF7, 0x08, 0x90, 473 0x0D, 0xF1, 0x60, 0xC6, 0xD3, 0x90, 0xA9, 0x10, 474 0xAF, 0xA1, 0xEA, 0x83, 0x2E, 0xB8, 0x35, 0xD9, 475 0x7B, 0x70, 0xB1, 0x13, 0x08, 0xA8, 0x90, 0x07 476 }, 477 .len = 48, 478 .truncated_len = 24 479 } 480 }; 481 482 static const struct blockcipher_test_data 483 sha3_512_test_vector = { 484 .auth_algo = RTE_CRYPTO_AUTH_SHA3_512, 485 .ciphertext = { 486 .data = plaintext_hash, 487 .len = 512 488 }, 489 .digest = { 490 .data = { 491 0x0B, 0xFF, 0x02, 0x45, 0xC5, 0xE7, 0x72, 0xD6, 492 0x1B, 0xD6, 0x7A, 0xB1, 0xFB, 0x34, 0x0E, 0xAA, 493 0xAE, 0x85, 0xCD, 0x04, 0xC8, 0x77, 0x97, 0xC7, 494 0x99, 0x6A, 0xF8, 0xC1, 0x6A, 0x2A, 0x17, 0xE2, 495 0xE2, 0xBC, 0x32, 0x53, 0x69, 0x9C, 0xCF, 0x02, 496 0x83, 0x3D, 0x89, 0xEE, 0xC9, 0xDF, 0xBC, 0xEC, 497 0xE6, 0xD9, 0x3B, 0x8E, 0xA4, 0xF9, 0x5E, 0x6A, 498 0xBB, 0x32, 0x7C, 0x04, 0x5E, 0xEB, 0x18, 0xC7 499 }, 500 .len = 64, 501 .truncated_len = 64 502 } 503 }; 504 505 static const struct blockcipher_test_data 506 hmac_sha3_512_test_vector = { 507 .auth_algo = RTE_CRYPTO_AUTH_SHA3_512_HMAC, 508 .ciphertext = { 509 .data = plaintext_hash, 510 .len = 512 511 }, 512 .auth_key = { 513 .data = { 514 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA, 515 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD, 516 0xDE, 0xF4, 0xDE, 0xAD, 0x26, 0xEB, 0xAB, 0x92, 517 0xFB, 0xBF, 0xB0, 0x8C, 0x29, 0x87, 0x90, 0xAC, 518 0x39, 0x8B, 0x5C, 0x49, 0x68, 0x1E, 0x3A, 0x05, 519 0xCC, 0x68, 0x5C, 0x76, 0xCB, 0x3C, 0x71, 0x89, 520 0xDE, 0xAA, 0x36, 0x44, 0x98, 0x93, 0x97, 0x1E, 521 0x6D, 0x53, 0x83, 0x87, 0xB3, 0xB7, 0x56, 0x41 522 }, 523 .len = 64 524 }, 525 .digest = { 526 .data = { 527 0x1C, 0x46, 0xD2, 0x95, 0xDC, 0xB4, 0x5F, 0xF8, 528 0xB7, 0x63, 0xA7, 0xCD, 0x27, 0x79, 0x04, 0x9B, 529 0x19, 0x97, 0xBF, 0x41, 0x5C, 0xCC, 0x02, 0xD3, 530 0x19, 0xCB, 0x65, 0x59, 0x43, 0xD8, 0xB7, 0x3B, 531 0xF6, 0xAF, 0xAA, 0xA5, 0x6E, 0x24, 0xA4, 0xFA, 532 0xC6, 0xE0, 0xC1, 0x1B, 0x61, 0xFD, 0xB6, 0xA2, 533 0x3E, 0xF0, 0xD1, 0x64, 0x3B, 0x30, 0x40, 0x67, 534 0xE5, 0x41, 0x82, 0xE8, 0xC8, 0x41, 0x42, 0x3D 535 }, 536 .len = 64, 537 .truncated_len = 32 538 } 539 }; 540 541 static const struct blockcipher_test_data 542 shake_128_test_vector = { 543 .auth_algo = RTE_CRYPTO_AUTH_SHAKE_128, 544 .ciphertext = { 545 .data = plaintext_hash, 546 .len = 512 547 }, 548 .digest = { 549 .data = { 550 0x69, 0xBD, 0xD5, 0x14, 0x85, 0xE0, 0x44, 0xA4, 551 0x25, 0xE6, 0x9F, 0x81, 0xC8, 0x18, 0x58, 0x3E, 552 0xFE, 0xC9, 0x0B, 0xAD, 0x27, 0x98, 0x14, 0x3F, 553 0xB9, 0x7D, 0x68, 0x4D, 0x60, 0x77, 0x82, 0x64, 554 0x6D, 0x64, 0x66, 0x67, 0xFA, 0xBC, 0x4F, 0xAC, 555 0x9C, 0x75, 0x8D, 0x63, 0xBA, 0xBD, 0x2B, 0x03, 556 0x0F, 0x2F, 0x46, 0x15, 0x88, 0xF0, 0x8C, 0x09, 557 0xAC, 0x87, 0x84, 0x5B, 0xCA, 0x65, 0xA1, 0x14 558 }, 559 .len = 64, 560 .truncated_len = 64 561 } 562 }; 563 564 static const struct blockcipher_test_data 565 shake_256_test_vector = { 566 .auth_algo = RTE_CRYPTO_AUTH_SHAKE_256, 567 .ciphertext = { 568 .data = plaintext_hash, 569 .len = 512 570 }, 571 .digest = { 572 .data = { 573 0x9E, 0xA2, 0x1B, 0x84, 0x15, 0x0E, 0xF0, 0x46, 574 0xD9, 0xA9, 0x11, 0x02, 0x11, 0x67, 0x9A, 0xDC, 575 0x62, 0x95, 0x8C, 0xD6, 0xEF, 0x89, 0x35, 0x8C, 576 0xBF, 0x41, 0x5F, 0x23, 0x16, 0xBD, 0x0C, 0xDE, 577 0xEC, 0x1D, 0x47, 0x90, 0xA4, 0xD9, 0x18, 0x63, 578 0xE1, 0x60, 0xF8, 0xAF, 0x0F, 0x57, 0xBA, 0xCA, 579 0x5D, 0x97, 0x58, 0xF5, 0xFF, 0xE4, 0x85, 0x40, 580 0xCA, 0x7D, 0xB8, 0x35, 0x3B, 0x89, 0xCA, 0x34 581 }, 582 .len = 64, 583 .truncated_len = 64 584 } 585 }; 586 587 static const struct blockcipher_test_data 588 cmac_test_vector = { 589 .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC, 590 .ciphertext = { 591 .data = plaintext_hash, 592 .len = 512 593 }, 594 .auth_key = { 595 .data = { 596 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 597 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C 598 }, 599 .len = 16 600 }, 601 .digest = { 602 .data = { 603 0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96, 604 0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27 605 }, 606 .len = 16, 607 .truncated_len = 16 608 } 609 }; 610 611 static const struct blockcipher_test_data 612 aes_xcbc_mac_test_vector = { 613 .auth_algo = RTE_CRYPTO_AUTH_AES_XCBC_MAC, 614 .ciphertext = { 615 .data = plaintext_hash, 616 .len = 512 617 }, 618 .auth_key = { 619 .data = { 620 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 621 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f 622 }, 623 .len = 16 624 }, 625 .digest = { 626 .data = { 627 0x07, 0xf1, 0xf5, 0x80, 0x5a, 0xbc, 0x1d, 0x1c, 628 0x58, 0x43, 0x99, 0xbe 629 630 }, 631 .len = 12, 632 .truncated_len = 12 633 } 634 }; 635 636 static const struct blockcipher_test_data 637 null_auth_test_vector = { 638 .auth_algo = RTE_CRYPTO_AUTH_NULL, 639 .ciphertext = { /* arbitrary data - shouldn't be used */ 640 .data = plaintext_hash, 641 .len = 512 642 }, 643 .auth_key = { 644 .data = { 0x0 }, 645 .len = 0 646 }, 647 .digest = { 648 .data = { 0x0 }, 649 .len = 0, 650 .truncated_len = 0 651 } 652 }; 653 654 static const struct blockcipher_test_data 655 cmac_test_vector_12 = { 656 .auth_algo = RTE_CRYPTO_AUTH_AES_CMAC, 657 .ciphertext = { 658 .data = plaintext_hash, 659 .len = 512 660 }, 661 .auth_key = { 662 .data = { 663 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 664 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C 665 }, 666 .len = 16 667 }, 668 .digest = { 669 .data = { 670 0x4C, 0x77, 0x87, 0xA0, 0x78, 0x8E, 0xEA, 0x96, 671 0xC1, 0xEB, 0x1E, 0x4E, 0x95, 0x8F, 0xED, 0x27 672 }, 673 .len = 12, 674 .truncated_len = 12 675 } 676 }; 677 678 static const struct blockcipher_test_data 679 sm3_test_vector = { 680 .auth_algo = RTE_CRYPTO_AUTH_SM3, 681 .ciphertext = { 682 .data = plaintext_hash, 683 .len = 512 684 }, 685 .digest = { 686 .data = { 687 0x9E, 0x86, 0xAB, 0x68, 0xD7, 0x8F, 0xD6, 0xFF, 688 0x1C, 0x57, 0x12, 0x48, 0xC4, 0xA8, 0x26, 0xDE, 689 0x9E, 0x53, 0xE9, 0xC4, 0xA6, 0xBB, 0xE7, 0x52, 690 0x53, 0x9C, 0xDE, 0xC1, 0xD5, 0x7C, 0x43, 0xAB 691 }, 692 .len = 32 693 } 694 }; 695 696 static const struct blockcipher_test_data 697 hmac_sm3_test_vector = { 698 .auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC, 699 .ciphertext = { 700 .data = plaintext_hash, 701 .len = 512 702 }, 703 .auth_key = { 704 .data = { 705 0x12, 0x70, 0x87, 0xd9, 0x76, 0x9e, 0xe0, 0xf0, 706 0x14, 0xfb, 0xca, 0x5a, 0xb6, 0xcb, 0x8f, 0x9d, 707 0x42, 0xd3, 0x1e, 0x09, 0x9a, 0x25, 0x9a, 0x3c, 708 0x87, 0xee, 0x55, 0x63, 0x56, 0x33, 0x75, 0x69, 709 0xa3, 0xfc, 0x42, 0x19, 0x9a, 0x22, 0x09, 0xae, 710 0x1d, 0xd3, 0x09, 0xd3, 0x9e, 0x98, 0x71, 0xe1, 711 0x6b, 0x8f, 0xea, 0x05, 0xb4, 0x85, 0x41, 0x3b, 712 0x73, 0x97, 0x9e, 0xc9, 0xca, 0x13, 0x32, 0x6d 713 }, 714 .len = 64 715 }, 716 .digest = { 717 .data = { 718 0xBC, 0x71, 0xF5, 0x3B, 0x43, 0x28, 0x11, 0x7A, 719 0x32, 0xD2, 0xC9, 0x2D, 0x3B, 0xFA, 0xE0, 0x47, 720 0xA4, 0xD5, 0xEC, 0x81, 0xFB, 0x86, 0x6A, 0x11, 721 0x64, 0xF3, 0xF5, 0x82, 0x3B, 0x8E, 0x0A, 0xBB 722 }, 723 .len = 32, 724 .truncated_len = 16 725 } 726 }; 727 728 static const struct blockcipher_test_case hash_test_cases[] = { 729 { 730 .test_descr = "MD5 Digest", 731 .test_data = &md5_test_vector, 732 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 733 }, 734 { 735 .test_descr = "MD5 Digest Verify", 736 .test_data = &md5_test_vector, 737 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 738 }, 739 { 740 .test_descr = "HMAC-MD5 Digest", 741 .test_data = &hmac_md5_test_vector, 742 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 743 }, 744 { 745 .test_descr = "HMAC-MD5 Digest Verify", 746 .test_data = &hmac_md5_test_vector, 747 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 748 }, 749 { 750 .test_descr = "SHA1 Digest", 751 .test_data = &sha1_test_vector, 752 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 753 }, 754 { 755 .test_descr = "SHA1 Digest Verify", 756 .test_data = &sha1_test_vector, 757 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 758 }, 759 { 760 .test_descr = "HMAC-SHA1 Digest", 761 .test_data = &hmac_sha1_test_vector, 762 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 763 }, 764 { 765 .test_descr = "HMAC-SHA1 Digest Scatter Gather (Inplace)", 766 .test_data = &hmac_sha1_test_vector, 767 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 768 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG, 769 .sgl_flag = RTE_CRYPTODEV_FF_IN_PLACE_SGL, 770 .sgl_segs = 3 771 }, 772 { 773 .test_descr = "HMAC-SHA1 Digest Verify", 774 .test_data = &hmac_sha1_test_vector, 775 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 776 }, 777 { 778 .test_descr = "HMAC-SHA1 Digest Verify Scatter Gather (Inplace)", 779 .test_data = &hmac_sha1_test_vector, 780 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 781 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG, 782 .sgl_flag = RTE_CRYPTODEV_FF_IN_PLACE_SGL, 783 .sgl_segs = 3 784 }, 785 { 786 .test_descr = "SHA224 Digest", 787 .test_data = &sha224_test_vector, 788 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 789 }, 790 { 791 .test_descr = "SHA224 Digest Verify", 792 .test_data = &sha224_test_vector, 793 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 794 }, 795 { 796 .test_descr = "HMAC-SHA224 Digest", 797 .test_data = &hmac_sha224_test_vector, 798 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 799 }, 800 { 801 .test_descr = "HMAC-SHA224 Digest Verify", 802 .test_data = &hmac_sha224_test_vector, 803 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 804 }, 805 { 806 .test_descr = "SHA256 Digest", 807 .test_data = &sha256_test_vector, 808 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 809 }, 810 { 811 .test_descr = "SHA256 Digest Verify", 812 .test_data = &sha256_test_vector, 813 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 814 }, 815 { 816 .test_descr = "HMAC-SHA256 Digest", 817 .test_data = &hmac_sha256_test_vector, 818 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 819 }, 820 { 821 .test_descr = "HMAC-SHA256 Digest Verify", 822 .test_data = &hmac_sha256_test_vector, 823 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 824 }, 825 { 826 .test_descr = "SHA384 Digest", 827 .test_data = &sha384_test_vector, 828 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 829 }, 830 { 831 .test_descr = "SHA384 Digest Verify", 832 .test_data = &sha384_test_vector, 833 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 834 }, 835 { 836 .test_descr = "HMAC-SHA384 Digest", 837 .test_data = &hmac_sha384_test_vector, 838 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 839 }, 840 { 841 .test_descr = "HMAC-SHA384 Digest Verify", 842 .test_data = &hmac_sha384_test_vector, 843 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 844 }, 845 { 846 .test_descr = "SHA512 Digest", 847 .test_data = &sha512_test_vector, 848 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 849 }, 850 { 851 .test_descr = "SHA512 Digest Verify", 852 .test_data = &sha512_test_vector, 853 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 854 }, 855 { 856 .test_descr = "HMAC-SHA512 Digest", 857 .test_data = &hmac_sha512_test_vector, 858 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 859 }, 860 { 861 .test_descr = "HMAC-SHA512 Digest Verify", 862 .test_data = &hmac_sha512_test_vector, 863 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 864 }, 865 { 866 .test_descr = "SHA3_224 Digest", 867 .test_data = &sha3_224_test_vector, 868 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 869 }, 870 { 871 .test_descr = "SHA3_224 Digest Verify", 872 .test_data = &sha3_224_test_vector, 873 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 874 }, 875 { 876 .test_descr = "HMAC-SHA3_224 Digest", 877 .test_data = &hmac_sha3_224_test_vector, 878 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 879 }, 880 { 881 .test_descr = "HMAC-SHA3_224 Digest Verify", 882 .test_data = &hmac_sha3_224_test_vector, 883 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 884 }, 885 { 886 .test_descr = "SHA3_256 Digest", 887 .test_data = &sha3_256_test_vector, 888 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 889 }, 890 { 891 .test_descr = "SHA3_256 Digest Verify", 892 .test_data = &sha3_256_test_vector, 893 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 894 }, 895 { 896 .test_descr = "HMAC-SHA3_256 Digest", 897 .test_data = &hmac_sha3_256_test_vector, 898 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 899 }, 900 { 901 .test_descr = "HMAC-SHA3_256 Digest Verify", 902 .test_data = &hmac_sha3_256_test_vector, 903 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 904 }, 905 { 906 .test_descr = "SHA3_384 Digest", 907 .test_data = &sha3_384_test_vector, 908 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 909 }, 910 { 911 .test_descr = "SHA3_384 Digest Verify", 912 .test_data = &sha3_384_test_vector, 913 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 914 }, 915 { 916 .test_descr = "HMAC-SHA3_384 Digest", 917 .test_data = &hmac_sha3_384_test_vector, 918 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 919 }, 920 { 921 .test_descr = "HMAC-SHA3_384 Digest Verify", 922 .test_data = &hmac_sha3_384_test_vector, 923 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 924 }, 925 { 926 .test_descr = "SHA3_512 Digest", 927 .test_data = &sha3_512_test_vector, 928 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 929 }, 930 { 931 .test_descr = "SHA3_512 Digest Verify", 932 .test_data = &sha3_512_test_vector, 933 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 934 }, 935 { 936 .test_descr = "HMAC-SHA3_512 Digest", 937 .test_data = &hmac_sha3_512_test_vector, 938 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 939 }, 940 { 941 .test_descr = "HMAC-SHA3_512 Digest Verify", 942 .test_data = &hmac_sha3_512_test_vector, 943 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 944 }, 945 { 946 .test_descr = "SHAKE_128 Digest", 947 .test_data = &shake_128_test_vector, 948 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 949 }, 950 { 951 .test_descr = "SHAKE_128 Digest Verify", 952 .test_data = &shake_128_test_vector, 953 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 954 }, 955 { 956 .test_descr = "SHAKE_256 Digest", 957 .test_data = &shake_256_test_vector, 958 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 959 }, 960 { 961 .test_descr = "SHAKE_256 Digest Verify", 962 .test_data = &shake_256_test_vector, 963 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 964 }, 965 { 966 .test_descr = "CMAC Digest 12B", 967 .test_data = &cmac_test_vector_12, 968 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 969 }, 970 { 971 .test_descr = "CMAC Digest Verify 12B", 972 .test_data = &cmac_test_vector_12, 973 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 974 }, 975 { 976 .test_descr = "CMAC Digest 16B", 977 .test_data = &cmac_test_vector, 978 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 979 }, 980 { 981 .test_descr = "CMAC Digest Verify 16B", 982 .test_data = &cmac_test_vector, 983 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 984 }, 985 { 986 .test_descr = "NULL algo - auth generate", 987 .test_data = &null_auth_test_vector, 988 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 989 }, 990 { 991 .test_descr = "NULL algo - auth verify", 992 .test_data = &null_auth_test_vector, 993 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 994 }, 995 { 996 .test_descr = "NULL algo - auth generate - OOP", 997 .test_data = &null_auth_test_vector, 998 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 999 .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, 1000 }, 1001 { 1002 .test_descr = "NULL algo - auth verify - OOP", 1003 .test_data = &null_auth_test_vector, 1004 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 1005 .feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP, 1006 }, 1007 { 1008 .test_descr = "AES-XCBC-MAC Digest 16B", 1009 .test_data = &aes_xcbc_mac_test_vector, 1010 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 1011 }, 1012 { 1013 .test_descr = "AES-XCBC-MAC Digest Verify 16B", 1014 .test_data = &aes_xcbc_mac_test_vector, 1015 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 1016 }, 1017 { 1018 .test_descr = "SM3 Digest", 1019 .test_data = &sm3_test_vector, 1020 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 1021 }, 1022 { 1023 .test_descr = "SM3 Digest Verify", 1024 .test_data = &sm3_test_vector, 1025 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 1026 }, 1027 { 1028 .test_descr = "HMAC-SM3 Digest", 1029 .test_data = &hmac_sm3_test_vector, 1030 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 1031 }, 1032 { 1033 .test_descr = "HMAC-SM3 Digest Scatter Gather", 1034 .test_data = &hmac_sm3_test_vector, 1035 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN, 1036 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG, 1037 }, 1038 { 1039 .test_descr = "HMAC-SM3 Digest Verify", 1040 .test_data = &hmac_sm3_test_vector, 1041 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 1042 }, 1043 { 1044 .test_descr = "HMAC-SM3 Digest Verify Scatter Gather", 1045 .test_data = &hmac_sm3_test_vector, 1046 .op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY, 1047 .feature_mask = BLOCKCIPHER_TEST_FEATURE_SG, 1048 }, 1049 1050 }; 1051 1052 #endif /* TEST_CRYPTODEV_HASH_TEST_VECTORS_H_ */ 1053