1 | // |
---|---|
2 | // BLAKE2EngineTest.cpp |
3 | // |
4 | // Code of the BLAKE2EngineTest class. |
5 | // |
6 | // test vectors from RFC 7693 |
7 | // |
8 | // Copyright (c) 2017, Applied Informatics Software Engineering GmbH |
9 | // and Contributors. |
10 | // |
11 | // SPDX-License-Identifier: BSL-1.0 |
12 | // |
13 | |
14 | #include "BLAKE2EngineTest.h" |
15 | #include "Poco/CppUnit/TestCaller.h" |
16 | #include "Poco/CppUnit/TestSuite.h" |
17 | #include "Poco/BLAKE2Engine.h" |
18 | |
19 | using Poco::BLAKE2Engine; |
20 | using Poco::DigestEngine; |
21 | |
22 | BLAKE2EngineTest::BLAKE2EngineTest(const std::string& rName): CppUnit::TestCase(rName) |
23 | { |
24 | } |
25 | |
26 | BLAKE2EngineTest::~BLAKE2EngineTest() |
27 | { |
28 | } |
29 | |
30 | void BLAKE2EngineTest::testBLAKE2_224() |
31 | { |
32 | BLAKE2Engine engine(BLAKE2Engine::BLAKE2b_224); |
33 | |
34 | engine.update("abc"); |
35 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "9bd237b02a29e43bdd6738afa5b53ff0eee178d6210b618e4511aec8"); |
36 | } |
37 | |
38 | void BLAKE2EngineTest::testBLAKE2_256() |
39 | { |
40 | BLAKE2Engine engine(BLAKE2Engine::BLAKE2b_256); |
41 | |
42 | engine.update("abc"); |
43 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "bddd813c634239723171ef3fee98579b94964e3bb1cb3e427262c8c068d52319"); |
44 | } |
45 | |
46 | void BLAKE2EngineTest::testBLAKE2_384() |
47 | { |
48 | BLAKE2Engine engine(BLAKE2Engine::BLAKE2b_384); |
49 | |
50 | engine.update("abc"); |
51 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "6f56a82c8e7ef526dfe182eb5212f7db9df1317e57815dbda46083fc30f54ee6c66ba83be64b302d7cba6ce15bb556f4"); |
52 | } |
53 | |
54 | void BLAKE2EngineTest::testBLAKE2_512() |
55 | { |
56 | BLAKE2Engine engine(BLAKE2Engine::BLAKE2b_512); |
57 | |
58 | engine.update("abc"); |
59 | assertTrue (DigestEngine::digestToHex(engine.digest()) == "ba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923"); |
60 | } |
61 | |
62 | void BLAKE2EngineTest::setUp() |
63 | { |
64 | } |
65 | |
66 | void BLAKE2EngineTest::tearDown() |
67 | { |
68 | } |
69 | |
70 | CppUnit::Test* BLAKE2EngineTest::suite() |
71 | { |
72 | CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("BLAKE2EngineTest"); |
73 | |
74 | CppUnit_addTest(pSuite, BLAKE2EngineTest, testBLAKE2_224); |
75 | CppUnit_addTest(pSuite, BLAKE2EngineTest, testBLAKE2_256); |
76 | CppUnit_addTest(pSuite, BLAKE2EngineTest, testBLAKE2_384); |
77 | CppUnit_addTest(pSuite, BLAKE2EngineTest, testBLAKE2_512); |
78 | |
79 | return pSuite; |
80 | } |
81 |