mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2025-01-19 12:07:13 +01:00
4a6bfc086c
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
67 lines
1.3 KiB
C++
67 lines
1.3 KiB
C++
//
|
|
// SHA1EngineTest.cpp
|
|
//
|
|
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
|
// and Contributors.
|
|
//
|
|
// SPDX-License-Identifier: BSL-1.0
|
|
//
|
|
|
|
|
|
#include "SHA1EngineTest.h"
|
|
#include "CppUnit/TestCaller.h"
|
|
#include "CppUnit/TestSuite.h"
|
|
#include "Poco/SHA1Engine.h"
|
|
|
|
|
|
using Poco::SHA1Engine;
|
|
using Poco::DigestEngine;
|
|
|
|
|
|
SHA1EngineTest::SHA1EngineTest(const std::string& name): CppUnit::TestCase(name)
|
|
{
|
|
}
|
|
|
|
|
|
SHA1EngineTest::~SHA1EngineTest()
|
|
{
|
|
}
|
|
|
|
|
|
void SHA1EngineTest::testSHA1()
|
|
{
|
|
SHA1Engine engine;
|
|
|
|
// test vectors from FIPS 180-1
|
|
|
|
engine.update("abc");
|
|
assertTrue (DigestEngine::digestToHex(engine.digest()) == "a9993e364706816aba3e25717850c26c9cd0d89d");
|
|
|
|
engine.update("abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq");
|
|
assertTrue (DigestEngine::digestToHex(engine.digest()) == "84983e441c3bd26ebaae4aa1f95129e5e54670f1");
|
|
|
|
for (int i = 0; i < 1000000; ++i)
|
|
engine.update('a');
|
|
assertTrue (DigestEngine::digestToHex(engine.digest()) == "34aa973cd4c4daa4f61eeb2bdbad27316534016f");
|
|
}
|
|
|
|
|
|
void SHA1EngineTest::setUp()
|
|
{
|
|
}
|
|
|
|
|
|
void SHA1EngineTest::tearDown()
|
|
{
|
|
}
|
|
|
|
|
|
CppUnit::Test* SHA1EngineTest::suite()
|
|
{
|
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SHA1EngineTest");
|
|
|
|
CppUnit_addTest(pSuite, SHA1EngineTest, testSHA1);
|
|
|
|
return pSuite;
|
|
}
|