1 | // |
---|---|
2 | // SHA3Engine.h |
3 | // |
4 | // Library: Foundation |
5 | // Package: Crypt |
6 | // Module: SHA3Engine |
7 | // |
8 | // Definition of class SHA3Engine. |
9 | // |
10 | /// This class implements the SHA-3 message digest algorithm. |
11 | /// (FIPS 202, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) |
12 | // |
13 | // Based on the Keccak Code Package (public domain) |
14 | // https://github.com/gvanas/KeccakCodePackage |
15 | // |
16 | // Copyright (c) 2017, Applied Informatics Software Engineering GmbH |
17 | // and Contributors. |
18 | // |
19 | // SPDX-License-Identifier: BSL-1.0 |
20 | // |
21 | |
22 | #ifndef Foundation_SHA3Engine_INCLUDED |
23 | #define Foundation_SHA3Engine_INCLUDED |
24 | |
25 | #include "Poco/Foundation.h" |
26 | #include "Poco/DigestEngine.h" |
27 | |
28 | namespace Poco { |
29 | |
30 | class Foundation_API SHA3Engine: public DigestEngine |
31 | /// This class implements the SHA-3 message digest algorithm. |
32 | /// (FIPS 202, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf) |
33 | { |
34 | public: |
35 | enum ALGORITHM |
36 | { |
37 | SHA3_224 = 224, |
38 | SHA3_256 = 256, |
39 | SHA3_384 = 384, |
40 | SHA3_512 = 512, |
41 | }; |
42 | |
43 | SHA3Engine(ALGORITHM algorithm = SHA3_512); |
44 | ~SHA3Engine(); |
45 | |
46 | std::size_t digestLength() const; |
47 | void reset(); |
48 | const DigestEngine::Digest& digest(); |
49 | |
50 | protected: |
51 | void updateImpl(const void* data, std::size_t length); |
52 | |
53 | private: |
54 | void transform(); |
55 | |
56 | void* _context; |
57 | ALGORITHM _algorithm; |
58 | DigestEngine::Digest _digest; |
59 | |
60 | SHA3Engine(const SHA3Engine&); |
61 | SHA3Engine& operator = (const SHA3Engine&); |
62 | }; |
63 | |
64 | } // namespace Poco |
65 | |
66 | #endif // Foundation_SHA3Engine_INCLUDED |
67 |