Add SHA3 and BLAKE2 hashing algorithm

This commit is contained in:
Transporter
2017-04-01 12:41:14 +02:00
parent 452fbbc757
commit ecaa7887a1
67 changed files with 1930 additions and 44 deletions

View File

@@ -0,0 +1,68 @@
//
// BLAKE2Engine.h
//
// Library: Foundation
// Package: Crypt
// Module: BLAKE2Engine
//
// Definition of class BLAKE2Engine.
//
// This class implements the BLAKE2 hashing algorithm.
// (RFC 7693, see https://tools.ietf.org/html/rfc7693)
//
// Based on the BLAKE2 reference implementation (CC0, OpenSSL or Apache 2.0)
// http://creativecommons.org/publicdomain/zero/1.0
// https://www.openssl.org/source/license.html
// http://www.apache.org/licenses/LICENSE-2.0
//
// Copyright (c) 2017, Applied Informatics Software Engineering GmbH
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_BLAKE2Engine_INCLUDED
#define Foundation_BLAKE2Engine_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/DigestEngine.h"
namespace Poco {
class Foundation_API BLAKE2Engine: public DigestEngine
/// This class implements the BLAKE2 hashing algorithm.
/// (RFC 7693, see https://tools.ietf.org/html/rfc7693)
{
public:
enum ALGORITHM
{
BLAKE2b_224 = 224,
BLAKE2b_256 = 256,
BLAKE2b_384 = 384,
BLAKE2b_512 = 512
};
BLAKE2Engine(ALGORITHM algorithm = BLAKE2b_512);
~BLAKE2Engine();
std::size_t digestLength() const;
void reset();
const DigestEngine::Digest& digest();
protected:
void updateImpl(const void* data, std::size_t length);
private:
void transform();
void* _context;
ALGORITHM _algorithm;
DigestEngine::Digest _digest;
BLAKE2Engine(const BLAKE2Engine&);
BLAKE2Engine& operator = (const BLAKE2Engine&);
};
} // namespace Poco
#endif // Foundation_BLAKE2Engine_INCLUDED

View File

@@ -0,0 +1,66 @@
//
// SHA3Engine.h
//
// Library: Foundation
// Package: Crypt
// Module: SHA3Engine
//
// Definition of class SHA3Engine.
//
/// This class implements the SHA-3 message digest algorithm.
/// (FIPS 202, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf)
//
// Based on the Keccak Code Package (public domain)
// https://github.com/gvanas/KeccakCodePackage
//
// Copyright (c) 2017, Applied Informatics Software Engineering GmbH
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#ifndef Foundation_SHA3Engine_INCLUDED
#define Foundation_SHA3Engine_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/DigestEngine.h"
namespace Poco {
class Foundation_API SHA3Engine: public DigestEngine
/// This class implements the SHA-3 message digest algorithm.
/// (FIPS 202, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.202.pdf)
{
public:
enum ALGORITHM
{
SHA3_224 = 224,
SHA3_256 = 256,
SHA3_384 = 384,
SHA3_512 = 512,
};
SHA3Engine(ALGORITHM algorithm = SHA3_512);
~SHA3Engine();
std::size_t digestLength() const;
void reset();
const DigestEngine::Digest& digest();
protected:
void updateImpl(const void* data, std::size_t length);
private:
void transform();
void* _context;
ALGORITHM _algorithm;
DigestEngine::Digest _digest;
SHA3Engine(const SHA3Engine&);
SHA3Engine& operator = (const SHA3Engine&);
};
} // namespace Poco
#endif // Foundation_SHA3Engine_INCLUDED