Crypto++ 8.2
Free C&
trunhash.h
1#ifndef CRYPTOPP_TRUNHASH_H
2#define CRYPTOPP_TRUNHASH_H
3
4#include "cryptlib.h"
5
6NAMESPACE_BEGIN(CryptoPP)
7
9{
10public:
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
21/// construct new HashModule with smaller DigestSize() from existing one
22template <class T>
24{
25public:
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
43private:
44 T m_hm;
45 unsigned int m_digestSize;
46};
47
49
50NAMESPACE_END
51
52#endif
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:1085
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: trunhash.h:13
bool TruncatedVerify(const byte *digest, size_t digestLength)
Verifies the hash of the current message.
Definition: trunhash.h:17
void TruncatedFinal(byte *digest, size_t digestSize)
Computes the hash of the current message.
Definition: trunhash.h:15
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Definition: trunhash.h:11
construct new HashModule with smaller DigestSize() from existing one
Definition: trunhash.h:24
void Restart()
Restart the hash.
Definition: trunhash.h:33
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: trunhash.h:37
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Definition: trunhash.h:35
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
Abstract base classes that provide a uniform interface to this library.
Crypto++ library namespace.