| 528 | |
| 529 | |
| 530 | int md5_test() |
| 531 | { |
| 532 | MD5 md5; |
| 533 | byte hash[MD5::DIGEST_SIZE]; |
| 534 | |
| 535 | testVector test_md5[] = |
| 536 | { |
| 537 | testVector("abc", |
| 538 | "\x90\x01\x50\x98\x3c\xd2\x4f\xb0\xd6\x96\x3f\x7d\x28\xe1\x7f" |
| 539 | "\x72"), |
| 540 | testVector("message digest", |
| 541 | "\xf9\x6b\x69\x7d\x7c\xb7\x93\x8d\x52\x5a\x2f\x31\xaa\xf1\x61" |
| 542 | "\xd0"), |
| 543 | testVector("abcdefghijklmnopqrstuvwxyz", |
| 544 | "\xc3\xfc\xd3\xd7\x61\x92\xe4\x00\x7d\xfb\x49\x6c\xca\x67\xe1" |
| 545 | "\x3b"), |
| 546 | testVector("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz012345" |
| 547 | "6789", |
| 548 | "\xd1\x74\xab\x98\xd2\x77\xd9\xf5\xa5\x61\x1c\x2c\x9f\x41\x9d" |
| 549 | "\x9f"), |
| 550 | testVector("1234567890123456789012345678901234567890123456789012345678" |
| 551 | "9012345678901234567890", |
| 552 | "\x57\xed\xf4\xa2\x2b\xe3\xc9\x55\xac\x49\xda\x2e\x21\x07\xb6" |
| 553 | "\x7a") |
| 554 | }; |
| 555 | |
| 556 | int times( sizeof(test_md5) / sizeof(testVector) ); |
| 557 | for (int i = 0; i < times; ++i) { |
| 558 | md5.Update(test_md5[i].input_, test_md5[i].inLen_); |
| 559 | md5.Final(hash); |
| 560 | |
| 561 | if (memcmp(hash, test_md5[i].output_, MD5::DIGEST_SIZE) != 0) |
| 562 | return -5 - i; |
| 563 | } |
| 564 | |
| 565 | return 0; |
| 566 | } |
| 567 | |
| 568 | |
| 569 | int md4_test() |
no test coverage detected