| 64 | }; |
| 65 | |
| 66 | bool HashModuleTest(HashTransformation &md, const HashTestTuple *testSet, unsigned int testSetSize) |
| 67 | { |
| 68 | bool pass=true, fail; |
| 69 | SecByteBlock digest(md.DigestSize()); |
| 70 | |
| 71 | // Coverity finding, also see http://stackoverflow.com/a/34509163/608639. |
| 72 | StreamState ss(cout); |
| 73 | for (unsigned int i=0; i<testSetSize; i++) |
| 74 | { |
| 75 | unsigned j; |
| 76 | |
| 77 | for (j=0; j<testSet[i].repeatTimes; j++) |
| 78 | md.Update(testSet[i].input, testSet[i].inputLen); |
| 79 | md.Final(digest); |
| 80 | fail = !!memcmp(digest, testSet[i].output, md.DigestSize()) != 0; |
| 81 | pass = pass && !fail; |
| 82 | |
| 83 | cout << (fail ? "FAILED " : "passed "); |
| 84 | for (j=0; j<md.DigestSize(); j++) |
| 85 | cout << setw(2) << setfill('0') << hex << (int)digest[j]; |
| 86 | cout << " \"" << (char *)testSet[i].input << '\"'; |
| 87 | if (testSet[i].repeatTimes != 1) |
| 88 | cout << " repeated " << dec << testSet[i].repeatTimes << " times"; |
| 89 | cout << endl; |
| 90 | } |
| 91 | |
| 92 | return pass; |
| 93 | } |
| 94 | |
| 95 | bool ValidateCRC32() |
| 96 | { |
no test coverage detected