Fabcoin Core  0.16.2
P2P Digital Currency
trunhash.h
Go to the documentation of this file.
1 #ifndef CRYPTOPP_TRUNHASH_H
2 #define CRYPTOPP_TRUNHASH_H
3 
4 #include "cryptlib.h"
5 
7 
9 {
10 public:
11  void Update(const byte *input, size_t length)
12  {CRYPTOPP_UNUSED(input);CRYPTOPP_UNUSED(length);}
13  unsigned int DigestSize() const
14  {return 0;}
15  void TruncatedFinal(byte *digest, size_t digestSize)
16  {CRYPTOPP_UNUSED(digest);CRYPTOPP_UNUSED(digestSize);}
17  bool TruncatedVerify(const byte *digest, size_t digestLength)
18  {CRYPTOPP_UNUSED(digest);CRYPTOPP_UNUSED(digestLength);return true;}
19 };
20 
22 template <class T>
24 {
25 public:
26  TruncatedHashTemplate(T hm, unsigned int digestSize)
27  : m_hm(hm), m_digestSize(digestSize) {}
28  TruncatedHashTemplate(const byte *key, size_t keyLength, unsigned int digestSize)
29  : m_hm(key, keyLength), m_digestSize(digestSize) {}
30  TruncatedHashTemplate(size_t digestSize)
31  : m_digestSize(digestSize) {}
32 
33  void Restart()
34  {m_hm.Restart();}
35  void Update(const byte *input, size_t length)
36  {m_hm.Update(input, length);}
37  unsigned int DigestSize() const {return m_digestSize;}
38  void TruncatedFinal(byte *digest, size_t digestSize)
39  {m_hm.TruncatedFinal(digest, digestSize);}
40  bool TruncatedVerify(const byte *digest, size_t digestLength)
41  {return m_hm.TruncatedVerify(digest, digestLength);}
42 
43 private:
45  unsigned int m_digestSize;
46 };
47 
49 
51 
52 #endif
construct new HashModule with smaller DigestSize() from existing one
Definition: trunhash.h:23
uint8_t byte
Definition: Common.h:57
#define T(i, x)
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: trunhash.h:37
TruncatedHashTemplate(size_t digestSize)
Definition: trunhash.h:30
bool TruncatedVerify(const byte *digest, size_t digestLength)
Verifies the hash of the current message.
Definition: trunhash.h:17
Abstract base classes that provide a uniform interface to this library.
void TruncatedFinal(byte *digest, size_t digestSize)
Computes the hash of the current message.
Definition: trunhash.h:38
bool TruncatedVerify(const byte *digest, size_t digestLength)
Verifies the hash of the current message.
Definition: trunhash.h:40
TruncatedHashTemplate(const byte *key, size_t keyLength, unsigned int digestSize)
Definition: trunhash.h:28
void Restart()
Restart the hash.
Definition: trunhash.h:33
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: trunhash.h:13
unsigned int m_digestSize
Definition: trunhash.h:45
TruncatedHashTemplate(T hm, unsigned int digestSize)
Definition: trunhash.h:26
TruncatedHashTemplate< HashTransformation & > TruncatedHashModule
Definition: trunhash.h:48
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Definition: trunhash.h:11
#define CRYPTOPP_UNUSED(x)
Definition: config.h:741
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Definition: trunhash.h:35
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:930
void TruncatedFinal(byte *digest, size_t digestSize)
Computes the hash of the current message.
Definition: trunhash.h:15
#define NAMESPACE_END
Definition: config.h:201