mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-12 18:20:26 +01:00
Add SHA1 test for Poco::Crypto::DigestEngine
This commit is contained in:
parent
1950377a8e
commit
850148f775
@ -78,6 +78,22 @@ void DigestEngineTest::testMD5()
|
||||
assert (DigestEngine::digestToHex(engine.digest()) == "57edf4a22be3c955ac49da2e2107b67a");
|
||||
}
|
||||
|
||||
void DigestEngineTest::testSHA1()
|
||||
{
|
||||
DigestEngine engine("SHA1");
|
||||
|
||||
// test vectors from FIPS 180-1
|
||||
|
||||
engine.update("abc");
|
||||
assert (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
|
||||
|
||||
engine.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
|
||||
assert (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
|
||||
|
||||
for (int i = 0; i < 1000000; ++i)
|
||||
engine.update('a');
|
||||
assert (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
|
||||
}
|
||||
|
||||
void DigestEngineTest::setUp()
|
||||
{
|
||||
@ -94,6 +110,7 @@ CppUnit::Test* DigestEngineTest::suite()
|
||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("DigestEngineTest");
|
||||
|
||||
CppUnit_addTest(pSuite, DigestEngineTest, testMD5);
|
||||
CppUnit_addTest(pSuite, DigestEngineTest, testSHA1);
|
||||
|
||||
return pSuite;
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public:
|
||||
~DigestEngineTest();
|
||||
|
||||
void testMD5();
|
||||
void testSHA1();
|
||||
|
||||
void setUp();
|
||||
void tearDown();
|
||||
|
Loading…
Reference in New Issue
Block a user