diff options
| author | Adrian-Ken Rueegsegger <rueegsegger@swiss-it.ch> | 2008-05-09 09:29:35 -0400 |
|---|---|---|
| committer | Herbert Xu <herbert@gondor.apana.org.au> | 2008-07-10 08:35:13 -0400 |
| commit | 2998db37b5c62890ff1a0d48abd76ada13ebc554 (patch) | |
| tree | 46cc2af8c275949e7e0ea9b093658354b79672b2 | |
| parent | c555c28d9da517579085a00fc80e725b0b5d9fce (diff) | |
[CRYPTO] tcrypt: Add test vectors for RIPEMD-256 and RIPEMD-320
This patch adds test vectors for RIPEMD-256 and
RIPEMD-320 hash algorithms.
The test vectors are taken from
<http://homes.esat.kuleuven.be/~bosselae/ripemd160.html>
Signed-off-by: Adrian-Ken Rueegsegger <rueegsegger@swiss-it.ch>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
| -rw-r--r-- | crypto/tcrypt.c | 21 | ||||
| -rw-r--r-- | crypto/tcrypt.h | 136 |
2 files changed, 155 insertions, 2 deletions
diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c index 69eb29e1a53b..e0ea4d53f25e 100644 --- a/crypto/tcrypt.c +++ b/crypto/tcrypt.c | |||
| @@ -76,7 +76,8 @@ static char *check[] = { | |||
| 76 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", | 76 | "blowfish", "twofish", "serpent", "sha384", "sha512", "md4", "aes", |
| 77 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", | 77 | "cast6", "arc4", "michael_mic", "deflate", "crc32c", "tea", "xtea", |
| 78 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", | 78 | "khazad", "wp512", "wp384", "wp256", "tnepres", "xeta", "fcrypt", |
| 79 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "lzo", "cts", NULL | 79 | "camellia", "seed", "salsa20", "rmd128", "rmd160", "rmd256", "rmd320", |
| 80 | "lzo", "cts", NULL | ||
| 80 | }; | 81 | }; |
| 81 | 82 | ||
| 82 | static void hexdump(unsigned char *buf, unsigned int len) | 83 | static void hexdump(unsigned char *buf, unsigned int len) |
| @@ -1559,7 +1560,7 @@ static void do_test(void) | |||
| 1559 | case 29: | 1560 | case 29: |
| 1560 | test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS); | 1561 | test_hash("tgr128", tgr128_tv_template, TGR128_TEST_VECTORS); |
| 1561 | break; | 1562 | break; |
| 1562 | 1563 | ||
| 1563 | case 30: | 1564 | case 30: |
| 1564 | test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template, | 1565 | test_cipher("ecb(xeta)", ENCRYPT, xeta_enc_tv_template, |
| 1565 | XETA_ENC_TEST_VECTORS); | 1566 | XETA_ENC_TEST_VECTORS); |
| @@ -1632,6 +1633,14 @@ static void do_test(void) | |||
| 1632 | test_hash("rmd160", rmd160_tv_template, RMD160_TEST_VECTORS); | 1633 | test_hash("rmd160", rmd160_tv_template, RMD160_TEST_VECTORS); |
| 1633 | break; | 1634 | break; |
| 1634 | 1635 | ||
| 1636 | case 41: | ||
| 1637 | test_hash("rmd256", rmd256_tv_template, RMD256_TEST_VECTORS); | ||
| 1638 | break; | ||
| 1639 | |||
| 1640 | case 42: | ||
| 1641 | test_hash("rmd320", rmd320_tv_template, RMD320_TEST_VECTORS); | ||
| 1642 | break; | ||
| 1643 | |||
| 1635 | case 100: | 1644 | case 100: |
| 1636 | test_hash("hmac(md5)", hmac_md5_tv_template, | 1645 | test_hash("hmac(md5)", hmac_md5_tv_template, |
| 1637 | HMAC_MD5_TEST_VECTORS); | 1646 | HMAC_MD5_TEST_VECTORS); |
| @@ -1823,6 +1832,14 @@ static void do_test(void) | |||
| 1823 | test_hash_speed("rmd160", sec, generic_hash_speed_template); | 1832 | test_hash_speed("rmd160", sec, generic_hash_speed_template); |
| 1824 | if (mode > 300 && mode < 400) break; | 1833 | if (mode > 300 && mode < 400) break; |
| 1825 | 1834 | ||
| 1835 | case 316: | ||
| 1836 | test_hash_speed("rmd256", sec, generic_hash_speed_template); | ||
| 1837 | if (mode > 300 && mode < 400) break; | ||
| 1838 | |||
| 1839 | case 317: | ||
| 1840 | test_hash_speed("rmd320", sec, generic_hash_speed_template); | ||
| 1841 | if (mode > 300 && mode < 400) break; | ||
| 1842 | |||
| 1826 | case 399: | 1843 | case 399: |
| 1827 | break; | 1844 | break; |
| 1828 | 1845 | ||
diff --git a/crypto/tcrypt.h b/crypto/tcrypt.h index af91f0cd15a5..20bd5fef0c08 100644 --- a/crypto/tcrypt.h +++ b/crypto/tcrypt.h | |||
| @@ -294,6 +294,142 @@ static struct hash_testvec rmd160_tv_template[] = { | |||
| 294 | }; | 294 | }; |
| 295 | 295 | ||
| 296 | /* | 296 | /* |
| 297 | * RIPEMD-256 test vectors | ||
| 298 | */ | ||
| 299 | #define RMD256_TEST_VECTORS 8 | ||
| 300 | |||
| 301 | static struct hash_testvec rmd256_tv_template[] = { | ||
| 302 | { | ||
| 303 | .digest = "\x02\xba\x4c\x4e\x5f\x8e\xcd\x18" | ||
| 304 | "\x77\xfc\x52\xd6\x4d\x30\xe3\x7a" | ||
| 305 | "\x2d\x97\x74\xfb\x1e\x5d\x02\x63" | ||
| 306 | "\x80\xae\x01\x68\xe3\xc5\x52\x2d", | ||
| 307 | }, { | ||
| 308 | .plaintext = "a", | ||
| 309 | .psize = 1, | ||
| 310 | .digest = "\xf9\x33\x3e\x45\xd8\x57\xf5\xd9" | ||
| 311 | "\x0a\x91\xba\xb7\x0a\x1e\xba\x0c" | ||
| 312 | "\xfb\x1b\xe4\xb0\x78\x3c\x9a\xcf" | ||
| 313 | "\xcd\x88\x3a\x91\x34\x69\x29\x25", | ||
| 314 | }, { | ||
| 315 | .plaintext = "abc", | ||
| 316 | .psize = 3, | ||
| 317 | .digest = "\xaf\xbd\x6e\x22\x8b\x9d\x8c\xbb" | ||
| 318 | "\xce\xf5\xca\x2d\x03\xe6\xdb\xa1" | ||
| 319 | "\x0a\xc0\xbc\x7d\xcb\xe4\x68\x0e" | ||
| 320 | "\x1e\x42\xd2\xe9\x75\x45\x9b\x65", | ||
| 321 | }, { | ||
| 322 | .plaintext = "message digest", | ||
| 323 | .psize = 14, | ||
| 324 | .digest = "\x87\xe9\x71\x75\x9a\x1c\xe4\x7a" | ||
| 325 | "\x51\x4d\x5c\x91\x4c\x39\x2c\x90" | ||
| 326 | "\x18\xc7\xc4\x6b\xc1\x44\x65\x55" | ||
| 327 | "\x4a\xfc\xdf\x54\xa5\x07\x0c\x0e", | ||
| 328 | }, { | ||
| 329 | .plaintext = "abcdefghijklmnopqrstuvwxyz", | ||
| 330 | .psize = 26, | ||
| 331 | .digest = "\x64\x9d\x30\x34\x75\x1e\xa2\x16" | ||
| 332 | "\x77\x6b\xf9\xa1\x8a\xcc\x81\xbc" | ||
| 333 | "\x78\x96\x11\x8a\x51\x97\x96\x87" | ||
| 334 | "\x82\xdd\x1f\xd9\x7d\x8d\x51\x33", | ||
| 335 | }, { | ||
| 336 | .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde" | ||
| 337 | "fghijklmnopqrstuvwxyz0123456789", | ||
| 338 | .psize = 62, | ||
| 339 | .digest = "\x57\x40\xa4\x08\xac\x16\xb7\x20" | ||
| 340 | "\xb8\x44\x24\xae\x93\x1c\xbb\x1f" | ||
| 341 | "\xe3\x63\xd1\xd0\xbf\x40\x17\xf1" | ||
| 342 | "\xa8\x9f\x7e\xa6\xde\x77\xa0\xb8", | ||
| 343 | }, { | ||
| 344 | .plaintext = "1234567890123456789012345678901234567890" | ||
| 345 | "1234567890123456789012345678901234567890", | ||
| 346 | .psize = 80, | ||
| 347 | .digest = "\x06\xfd\xcc\x7a\x40\x95\x48\xaa" | ||
| 348 | "\xf9\x13\x68\xc0\x6a\x62\x75\xb5" | ||
| 349 | "\x53\xe3\xf0\x99\xbf\x0e\xa4\xed" | ||
| 350 | "\xfd\x67\x78\xdf\x89\xa8\x90\xdd", | ||
| 351 | }, { | ||
| 352 | .plaintext = "abcdbcdecdefdefgefghfghighij" | ||
| 353 | "hijkijkljklmklmnlmnomnopnopq", | ||
| 354 | .psize = 56, | ||
| 355 | .digest = "\x38\x43\x04\x55\x83\xaa\xc6\xc8" | ||
| 356 | "\xc8\xd9\x12\x85\x73\xe7\xa9\x80" | ||
| 357 | "\x9a\xfb\x2a\x0f\x34\xcc\xc3\x6e" | ||
| 358 | "\xa9\xe7\x2f\x16\xf6\x36\x8e\x3f", | ||
| 359 | .np = 2, | ||
| 360 | .tap = { 28, 28 }, | ||
| 361 | } | ||
| 362 | }; | ||
| 363 | |||
| 364 | /* | ||
| 365 | * RIPEMD-320 test vectors | ||
| 366 | */ | ||
| 367 | #define RMD320_TEST_VECTORS 8 | ||
| 368 | |||
| 369 | static struct hash_testvec rmd320_tv_template[] = { | ||
| 370 | { | ||
| 371 | .digest = "\x22\xd6\x5d\x56\x61\x53\x6c\xdc\x75\xc1" | ||
| 372 | "\xfd\xf5\xc6\xde\x7b\x41\xb9\xf2\x73\x25" | ||
| 373 | "\xeb\xc6\x1e\x85\x57\x17\x7d\x70\x5a\x0e" | ||
| 374 | "\xc8\x80\x15\x1c\x3a\x32\xa0\x08\x99\xb8", | ||
| 375 | }, { | ||
| 376 | .plaintext = "a", | ||
| 377 | .psize = 1, | ||
| 378 | .digest = "\xce\x78\x85\x06\x38\xf9\x26\x58\xa5\xa5" | ||
| 379 | "\x85\x09\x75\x79\x92\x6d\xda\x66\x7a\x57" | ||
| 380 | "\x16\x56\x2c\xfc\xf6\xfb\xe7\x7f\x63\x54" | ||
| 381 | "\x2f\x99\xb0\x47\x05\xd6\x97\x0d\xff\x5d", | ||
| 382 | }, { | ||
| 383 | .plaintext = "abc", | ||
| 384 | .psize = 3, | ||
| 385 | .digest = "\xde\x4c\x01\xb3\x05\x4f\x89\x30\xa7\x9d" | ||
| 386 | "\x09\xae\x73\x8e\x92\x30\x1e\x5a\x17\x08" | ||
| 387 | "\x5b\xef\xfd\xc1\xb8\xd1\x16\x71\x3e\x74" | ||
| 388 | "\xf8\x2f\xa9\x42\xd6\x4c\xdb\xc4\x68\x2d", | ||
| 389 | }, { | ||
| 390 | .plaintext = "message digest", | ||
| 391 | .psize = 14, | ||
| 392 | .digest = "\x3a\x8e\x28\x50\x2e\xd4\x5d\x42\x2f\x68" | ||
| 393 | "\x84\x4f\x9d\xd3\x16\xe7\xb9\x85\x33\xfa" | ||
| 394 | "\x3f\x2a\x91\xd2\x9f\x84\xd4\x25\xc8\x8d" | ||
| 395 | "\x6b\x4e\xff\x72\x7d\xf6\x6a\x7c\x01\x97", | ||
| 396 | }, { | ||
| 397 | .plaintext = "abcdefghijklmnopqrstuvwxyz", | ||
| 398 | .psize = 26, | ||
| 399 | .digest = "\xca\xbd\xb1\x81\x0b\x92\x47\x0a\x20\x93" | ||
| 400 | "\xaa\x6b\xce\x05\x95\x2c\x28\x34\x8c\xf4" | ||
| 401 | "\x3f\xf6\x08\x41\x97\x51\x66\xbb\x40\xed" | ||
| 402 | "\x23\x40\x04\xb8\x82\x44\x63\xe6\xb0\x09", | ||
| 403 | }, { | ||
| 404 | .plaintext = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcde" | ||
| 405 | "fghijklmnopqrstuvwxyz0123456789", | ||
| 406 | .psize = 62, | ||
| 407 | .digest = "\xed\x54\x49\x40\xc8\x6d\x67\xf2\x50\xd2" | ||
| 408 | "\x32\xc3\x0b\x7b\x3e\x57\x70\xe0\xc6\x0c" | ||
| 409 | "\x8c\xb9\xa4\xca\xfe\x3b\x11\x38\x8a\xf9" | ||
| 410 | "\x92\x0e\x1b\x99\x23\x0b\x84\x3c\x86\xa4", | ||
| 411 | }, { | ||
| 412 | .plaintext = "1234567890123456789012345678901234567890" | ||
| 413 | "1234567890123456789012345678901234567890", | ||
| 414 | .psize = 80, | ||
| 415 | .digest = "\x55\x78\x88\xaf\x5f\x6d\x8e\xd6\x2a\xb6" | ||
| 416 | "\x69\x45\xc6\xd2\xa0\xa4\x7e\xcd\x53\x41" | ||
| 417 | "\xe9\x15\xeb\x8f\xea\x1d\x05\x24\x95\x5f" | ||
| 418 | "\x82\x5d\xc7\x17\xe4\xa0\x08\xab\x2d\x42", | ||
| 419 | }, { | ||
| 420 | .plaintext = "abcdbcdecdefdefgefghfghighij" | ||
| 421 | "hijkijkljklmklmnlmnomnopnopq", | ||
| 422 | .psize = 56, | ||
| 423 | .digest = "\xd0\x34\xa7\x95\x0c\xf7\x22\x02\x1b\xa4" | ||
| 424 | "\xb8\x4d\xf7\x69\xa5\xde\x20\x60\xe2\x59" | ||
| 425 | "\xdf\x4c\x9b\xb4\xa4\x26\x8c\x0e\x93\x5b" | ||
| 426 | "\xbc\x74\x70\xa9\x69\xc9\xd0\x72\xa1\xac", | ||
| 427 | .np = 2, | ||
| 428 | .tap = { 28, 28 }, | ||
| 429 | } | ||
| 430 | }; | ||
| 431 | |||
| 432 | /* | ||
| 297 | * SHA1 test vectors from from FIPS PUB 180-1 | 433 | * SHA1 test vectors from from FIPS PUB 180-1 |
| 298 | */ | 434 | */ |
| 299 | #define SHA1_TEST_VECTORS 2 | 435 | #define SHA1_TEST_VECTORS 2 |
