mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-27 02:53:10 +01:00
Add SHA2 algorithm
This commit is contained in:
61
Foundation/include/Poco/SHA2Engine.h
Normal file
61
Foundation/include/Poco/SHA2Engine.h
Normal file
@@ -0,0 +1,61 @@
|
||||
//
|
||||
// SHA2Engine.h
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Crypt
|
||||
// Module: SHA2Engine
|
||||
//
|
||||
// Definition of class SHA2Engine.
|
||||
//
|
||||
// Secure Hash Standard SHA-2 algorithm
|
||||
// (FIPS 180-4, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf)
|
||||
//
|
||||
|
||||
#ifndef Foundation_SHA2Engine_INCLUDED
|
||||
#define Foundation_SHA2Engine_INCLUDED
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/DigestEngine.h"
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API SHA2Engine: public DigestEngine
|
||||
/// This class implements the SHA-2 message digest algorithm.
|
||||
/// (FIPS 180-4, see http://nvlpubs.nist.gov/nistpubs/FIPS/NIST.FIPS.180-4.pdf)
|
||||
{
|
||||
public:
|
||||
enum ALGORITHM
|
||||
{
|
||||
SHA_224 = 224,
|
||||
SHA_256 = 256,
|
||||
SHA_384 = 384,
|
||||
SHA_512 = 512
|
||||
};
|
||||
|
||||
SHA2Engine(ALGORITHM algorithm = SHA_512);
|
||||
~SHA2Engine();
|
||||
|
||||
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;
|
||||
|
||||
SHA2Engine(const SHA2Engine&);
|
||||
SHA2Engine& operator = (const SHA2Engine&);
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_SHA2Engine_INCLUDED
|
||||
Reference in New Issue
Block a user