blob: d6d0b7a697e5bdb085a70f6e7859a357096ecf19 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/*
* File: crc.h
*
* Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
* See included license file for license details.
*/
#if !defined(_crc_h_)
#define CRYPTOPP_CRC32_H
#include "stdafx.h"
const uint32_t CRC32_NEGL = 0xffffffffL;
#ifdef __LITTLE_ENDIAN__
#define CRC32_INDEX(c) (c & 0xff)
#define CRC32_SHIFTED(c) (c >> 8)
#else
#define CRC32_INDEX(c) (c >> 24)
#define CRC32_SHIFTED(c) (c << 8)
#endif
//! CRC Checksum Calculation
class CRC32
{
public:
enum
{
DIGESTSIZE = 4
};
CRC32();
void update(const uint8_t * input, unsigned length);
void truncatedFinal(uint8_t * hash, unsigned size);
void updateByte(uint8_t b) { m_crc = m_tab[CRC32_INDEX(m_crc) ^ b] ^ CRC32_SHIFTED(m_crc); }
uint8_t getCrcByte(unsigned i) const { return ((uint8_t *)&(m_crc))[i]; }
private:
void reset() { m_crc = CRC32_NEGL; m_count = 0; }
static const uint32_t m_tab[256];
uint32_t m_crc;
unsigned m_count;
};
#endif // _crc_h_
|