Fabcoin Core  0.16.2
P2P Digital Currency
crc.h
Go to the documentation of this file.
1 // crc.h - written and placed in the public domain by Wei Dai
2 
6 
7 #ifndef CRYPTOPP_CRC32_H
8 #define CRYPTOPP_CRC32_H
9 
10 #include "cryptlib.h"
11 
13 
14 const word32 CRC32_NEGL = 0xffffffffL;
15 
16 #ifdef IS_LITTLE_ENDIAN
17 #define CRC32_INDEX(c) (c & 0xff)
18 #define CRC32_SHIFTED(c) (c >> 8)
19 #else
20 #define CRC32_INDEX(c) (c >> 24)
21 #define CRC32_SHIFTED(c) (c << 8)
22 #endif
23 
26 class CRC32 : public HashTransformation
27 {
28 public:
29  CRYPTOPP_CONSTANT(DIGESTSIZE = 4)
30  CRC32();
31  void Update(const byte *input, size_t length);
32  void TruncatedFinal(byte *hash, size_t size);
33  unsigned int DigestSize() const {return DIGESTSIZE;}
34  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "CRC32";}
35  std::string AlgorithmName() const {return StaticAlgorithmName();}
36 
38  byte GetCrcByte(size_t i) const {return ((byte *)&(m_crc))[i];}
39 
40 protected:
41  void Reset() {m_crc = CRC32_NEGL;}
42 
43 private:
44  static const word32 m_tab[256];
46 };
47 
51 class CRC32C : public HashTransformation
52 {
53 public:
54  CRYPTOPP_CONSTANT(DIGESTSIZE = 4)
55  CRC32C();
56  void Update(const byte *input, size_t length);
57  void TruncatedFinal(byte *hash, size_t size);
58  unsigned int DigestSize() const {return DIGESTSIZE;}
59  CRYPTOPP_STATIC_CONSTEXPR const char* StaticAlgorithmName() {return "CRC32C";}
60  std::string AlgorithmName() const {return StaticAlgorithmName();}
61 
63  byte GetCrcByte(size_t i) const {return ((byte *)&(m_crc))[i];}
64 
65 protected:
66  void Reset() {m_crc = CRC32_NEGL;}
67 
68 private:
69  static const word32 m_tab[256];
71 };
72 
74 
75 #endif
void UpdateByte(byte b)
Definition: crc.h:62
uint8_t byte
Definition: Common.h:57
#define CRYPTOPP_STATIC_CONSTEXPR
Definition: config.h:892
byte GetCrcByte(size_t i) const
Definition: crc.h:38
word32 m_crc
Definition: crc.h:70
#define NAMESPACE_BEGIN(x)
Definition: config.h:200
CRC32()
Definition: crc.cpp:127
Abstract base classes that provide a uniform interface to this library.
#define CRC32_INDEX(c)
Definition: crc.h:17
static const word32 m_tab[256]
Definition: crc.h:44
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: crc.h:59
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: crc.h:33
#define CRC32_SHIFTED(c)
Definition: crc.h:18
void TruncatedFinal(byte *hash, size_t size)
Computes the hash of the current message.
Definition: crc.cpp:172
byte GetCrcByte(size_t i) const
Definition: crc.h:63
word32 m_crc
Definition: crc.h:45
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: crc.h:35
#define CRYPTOPP_CONSTANT(x)
Definition: config.h:540
#define b(i, j)
void Update(const byte *input, size_t length)
Updates a hash with additional input.
Definition: crc.cpp:132
const word32 CRC32_NEGL
Definition: crc.h:14
uint8_t const size_t const size
Definition: sha3.h:20
void UpdateByte(byte b)
Definition: crc.h:37
Interface for hash functions and data processing part of MACs.
Definition: cryptlib.h:930
#define NAMESPACE_END
Definition: config.h:201
void Reset()
Definition: crc.h:66
unsigned int word32
Definition: config.h:231
unsigned int DigestSize() const
Provides the digest size of the hash.
Definition: crc.h:58
void Reset()
Definition: crc.h:41
CRYPTOPP_STATIC_CONSTEXPR const char * StaticAlgorithmName()
Definition: crc.h:34
CRC-32C Checksum Calculation.
Definition: crc.h:51
CRC-32 Checksum Calculation.
Definition: crc.h:26
std::string AlgorithmName() const
Provides the name of this algorithm.
Definition: crc.h:60