| 657 | |
| 658 | |
| 659 | int ripemd_test() |
| 660 | { |
| 661 | RIPEMD160 ripe160; |
| 662 | byte hash[RIPEMD160::DIGEST_SIZE]; |
| 663 | |
| 664 | testVector test_ripemd[] = |
| 665 | { |
| 666 | testVector("", |
| 667 | "\x9c\x11\x85\xa5\xc5\xe9\xfc\x54\x61\x28\x08\x97\x7e\xe8" |
| 668 | "\xf5\x48\xb2\x25\x8d\x31"), |
| 669 | testVector("a", |
| 670 | "\x0b\xdc\x9d\x2d\x25\x6b\x3e\xe9\xda\xae\x34\x7b\xe6\xf4" |
| 671 | "\xdc\x83\x5a\x46\x7f\xfe"), |
| 672 | testVector("abc", |
| 673 | "\x8e\xb2\x08\xf7\xe0\x5d\x98\x7a\x9b\x04\x4a\x8e\x98\xc6" |
| 674 | "\xb0\x87\xf1\x5a\x0b\xfc"), |
| 675 | testVector("message digest", |
| 676 | "\x5d\x06\x89\xef\x49\xd2\xfa\xe5\x72\xb8\x81\xb1\x23\xa8" |
| 677 | "\x5f\xfa\x21\x59\x5f\x36"), |
| 678 | testVector("abcdefghijklmnopqrstuvwxyz", |
| 679 | "\xf7\x1c\x27\x10\x9c\x69\x2c\x1b\x56\xbb\xdc\xeb\x5b\x9d" |
| 680 | "\x28\x65\xb3\x70\x8d\xbc"), |
| 681 | testVector("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", |
| 682 | "\x12\xa0\x53\x38\x4a\x9c\x0c\x88\xe4\x05\xa0\x6c\x27\xdc" |
| 683 | "\xf4\x9a\xda\x62\xeb\x2b"), |
| 684 | testVector("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123" |
| 685 | "456789", |
| 686 | "\xb0\xe2\x0b\x6e\x31\x16\x64\x02\x86\xed\x3a\x87\xa5\x71" |
| 687 | "\x30\x79\xb2\x1f\x51\x89"), |
| 688 | testVector("12345678901234567890123456789012345678901234567890123456" |
| 689 | "789012345678901234567890", |
| 690 | "\x9b\x75\x2e\x45\x57\x3d\x4b\x39\xf4\xdb\xd3\x32\x3c\xab" |
| 691 | "\x82\xbf\x63\x32\x6b\xfb"), |
| 692 | }; |
| 693 | |
| 694 | int times( sizeof(test_ripemd) / sizeof(testVector) ); |
| 695 | for (int i = 0; i < times; ++i) { |
| 696 | ripe160.Update(test_ripemd[i].input_, test_ripemd[i].inLen_); |
| 697 | ripe160.Final(hash); |
| 698 | |
| 699 | if (memcmp(hash, test_ripemd[i].output_, RIPEMD160::DIGEST_SIZE) != 0) |
| 700 | return -100 - i; |
| 701 | } |
| 702 | |
| 703 | return 0; |
| 704 | } |
| 705 | |
| 706 | |
| 707 | int hmac_test() |
no test coverage detected