00001
00002
00003
00004
00005
00006
00007 #ifndef CRYPTOPP_SHA3_H
00008 #define CRYPTOPP_SHA3_H
00009
00010 #include "cryptlib.h"
00011 #include "secblock.h"
00012
00013 NAMESPACE_BEGIN(CryptoPP)
00014
00015
00016 class SHA3 : public HashTransformation
00017 {
00018 public:
00019 SHA3(unsigned int digestSize) : m_digestSize(digestSize) {Restart();}
00020 unsigned int DigestSize() const {return m_digestSize;}
00021 std::string AlgorithmName() const {return "SHA-3-" + IntToString(m_digestSize*8);}
00022 unsigned int OptimalDataAlignment() const {return GetAlignmentOf<word64>();}
00023
00024 void Update(const byte *input, size_t length);
00025 void Restart();
00026 void TruncatedFinal(byte *hash, size_t size);
00027
00028 protected:
00029 inline unsigned int r() const {return 200 - 2 * m_digestSize;}
00030
00031 FixedSizeSecBlock<word64, 25> m_state;
00032 unsigned int m_digestSize, m_counter;
00033 };
00034
00035 class SHA3_224 : public SHA3
00036 {
00037 public:
00038 CRYPTOPP_CONSTANT(DIGESTSIZE = 28)
00039 SHA3_224() : SHA3(DIGESTSIZE) {}
00040 static const char * StaticAlgorithmName() {return "SHA-3-224";}
00041 };
00042
00043 class SHA3_256 : public SHA3
00044 {
00045 public:
00046 CRYPTOPP_CONSTANT(DIGESTSIZE = 32)
00047 SHA3_256() : SHA3(DIGESTSIZE) {}
00048 static const char * StaticAlgorithmName() {return "SHA-3-256";}
00049 };
00050
00051 class SHA3_384 : public SHA3
00052 {
00053 public:
00054 CRYPTOPP_CONSTANT(DIGESTSIZE = 48)
00055 SHA3_384() : SHA3(DIGESTSIZE) {}
00056 static const char * StaticAlgorithmName() {return "SHA-3-384";}
00057 };
00058
00059 class SHA3_512 : public SHA3
00060 {
00061 public:
00062 CRYPTOPP_CONSTANT(DIGESTSIZE = 64)
00063 SHA3_512() : SHA3(DIGESTSIZE) {}
00064 static const char * StaticAlgorithmName() {return "SHA-3-512";}
00065 };
00066
00067 NAMESPACE_END
00068
00069 #endif