1 | // |
---|---|
2 | // MD4EngineTest.cpp |
3 | // |
4 | // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. |
5 | // and Contributors. |
6 | // |
7 | // SPDX-License-Identifier: BSL-1.0 |
8 | // |
9 | |
10 | |
11 | #include "MD4EngineTest.h" |
12 | #include "Poco/CppUnit/TestCaller.h" |
13 | #include "Poco/CppUnit/TestSuite.h" |
14 | #include "Poco/MD4Engine.h" |
15 | |
16 | |
17 | using Poco::MD4Engine; |
18 | using Poco::DigestEngine; |
19 | |
20 | |
21 | MD4EngineTest::MD4EngineTest(const std::string& rName): CppUnit::TestCase(rName) |
22 | { |
23 | } |
24 | |
25 | |
26 | MD4EngineTest::~MD4EngineTest() |
27 | { |
28 | } |
29 | |
30 | |
31 | void MD4EngineTest::testMD4() |
32 | { |
33 | MD4Engine engine; |
34 | |
35 | // test vectors from RFC 1320 |
36 | |
37 | engine.update(""); |
38 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "31d6cfe0d16ae931b73c59d7e0c089c0"); |
39 | |
40 | engine.update("a"); |
41 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "bde52cb31de33e46245e05fbdbd6fb24"); |
42 | |
43 | engine.update("abc"); |
44 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "a448017aaf21d8525fc10ae87aa6729d"); |
45 | |
46 | engine.update("message digest"); |
47 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "d9130a8164549fe818874806e1c7014b"); |
48 | |
49 | engine.update("abcdefghijklmnopqrstuvwxyz"); |
50 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "d79e1c308aa5bbcdeea8ed63df412da9"); |
51 | |
52 | engine.update("ABCDEFGHIJKLMNOPQRSTUVWXYZ"); |
53 | engine.update("abcdefghijklmnopqrstuvwxyz0123456789"); |
54 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "043f8582f241db351ce627e153e7f0e4"); |
55 | |
56 | engine.update("12345678901234567890123456789012345678901234567890123456789012345678901234567890"); |
57 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "e33b4ddc9c38f2199c3e7b164fcc0536"); |
58 | } |
59 | |
60 | |
61 | void MD4EngineTest::setUp() |
62 | { |
63 | } |
64 | |
65 | |
66 | void MD4EngineTest::tearDown() |
67 | { |
68 | } |
69 | |
70 | |
71 | CppUnit::Test* MD4EngineTest::suite() |
72 | { |
73 | CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MD4EngineTest"); |
74 | |
75 | CppUnit_addTest(pSuite, MD4EngineTest, testMD4); |
76 | |
77 | return pSuite; |
78 | } |
79 |