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