1//
2// BLAKE2Engine.h
3//
4// Library: Foundation
5// Package: Crypt
6// Module: BLAKE2Engine
7//
8// Definition of class BLAKE2Engine.
9//
10// This class implements the BLAKE2 hashing algorithm.
11// (RFC 7693, see https://tools.ietf.org/html/rfc7693)
12//
13// Based on the BLAKE2 reference implementation (CC0, OpenSSL or Apache 2.0)
14// http://creativecommons.org/publicdomain/zero/1.0
15// https://www.openssl.org/source/license.html
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Copyright (c) 2017, Applied Informatics Software Engineering GmbH
19// and Contributors.
20//
21// SPDX-License-Identifier: BSL-1.0
22//
23
24#ifndef Foundation_BLAKE2Engine_INCLUDED
25#define Foundation_BLAKE2Engine_INCLUDED
26
27#include "Poco/Foundation.h"
28#include "Poco/DigestEngine.h"
29
30namespace Poco {
31
32class Foundation_API BLAKE2Engine: public DigestEngine
33 /// This class implements the BLAKE2 hashing algorithm.
34 /// (RFC 7693, see https://tools.ietf.org/html/rfc7693)
35{
36public:
37 enum ALGORITHM
38 {
39 BLAKE2b_224 = 224,
40 BLAKE2b_256 = 256,
41 BLAKE2b_384 = 384,
42 BLAKE2b_512 = 512
43 };
44
45 BLAKE2Engine(ALGORITHM algorithm = BLAKE2b_512);
46 ~BLAKE2Engine();
47
48 std::size_t digestLength() const;
49 void reset();
50 const DigestEngine::Digest& digest();
51
52protected:
53 void updateImpl(const void* data, std::size_t length);
54
55private:
56 void transform();
57
58 void* _context;
59 ALGORITHM _algorithm;
60 DigestEngine::Digest _digest;
61
62 BLAKE2Engine(const BLAKE2Engine&);
63 BLAKE2Engine& operator = (const BLAKE2Engine&);
64};
65
66} // namespace Poco
67
68#endif // Foundation_BLAKE2Engine_INCLUDED
69