11 ctx->reflect = reflect;
21 for (
i = 0;
i < sz;
i++) {
24 for (j = 0; j < 4; j++) {
25 if (((
d >> j) ^ (
d >> (7 - j))) & 1) {
26 d ^= (1 << j) ^ (1 << (7 - j));
30 crc ^=
d << (
ctx->size - 8);
31 for (j = 0; j < 8; j++) {
32 crc = ((crc >> (
ctx->size - 1)) & 1 ?
ctx->poly : 0) ^ (crc << 1);
43 crc &= (((
UTCRC_C(1) << (
ctx->size - 1)) - 1) << 1) | 1;
45 for (
i = 0;
i < (
ctx->size >> 1);
i++) {
46 if (((crc >>
i) ^ (crc >> (
ctx->size - 1 -
i))) & 1) {
56 #define CRC_PRESET(crc, size, reflect, poly, xout) \
57 { UTCRC_C(crc), (size), (reflect), UTCRC_C(poly), UTCRC_C(xout) }
96 CRC_PRESET(0xB704CE, 24, 0, 0x864CFB, 0x000000),
97 CRC_PRESET(0xFFFFFFFF, 32, 1, 0x04C11DB7, 0xFFFFFFFF),
98 CRC_PRESET(0x00000000, 32, 0, 0x80000011, 0x00000000),
99 CRC_PRESET(0xFFFFFFFF, 32, 1, 0x1EDC6F41, 0xFFFFFFFF),
100 CRC_PRESET(0xFFFFFFFF, 32, 0, 0x04C11DB7, 0xFFFFFFFF),
101 CRC_PRESET(0xFFFFFFFF, 32, 1, 0xA833982B, 0xFFFFFFFF),
102 CRC_PRESET(0xFFFFFFFF, 32, 0, 0x04C11DB7, 0x00000000),
103 CRC_PRESET(0x00000000, 32, 0, 0x04C11DB7, 0xFFFFFFFF),
104 CRC_PRESET(0x00000000, 32, 0, 0x814141AB, 0x00000000),
105 CRC_PRESET(0xFFFFFFFF, 32, 1, 0x04C11DB7, 0x00000000),
106 CRC_PRESET(0x00000000, 32, 0, 0x000000AF, 0x00000000),
107 CRC_PRESET(0x0000000000000000, 64, 0, 0x42F0E1EBA9EA3693, 0x0000000000000000),
108 CRC_PRESET(0x0000000000000000, 64, 0, 0x42F0E1EBA9EA3693, 0x0000000000000000),
109 CRC_PRESET(0xFFFFFFFFFFFFFFFF, 64, 0, 0x42F0E1EBA9EA3693, 0xFFFFFFFFFFFFFFFF),
110 CRC_PRESET(0xFFFFFFFFFFFFFFFF, 64, 1, 0x42F0E1EBA9EA3693, 0xFFFFFFFFFFFFFFFF),
111 CRC_PRESET(0xFFFFFFFFFFFFFFFF, 64, 1, 0x000000000000001b, 0xFFFFFFFFFFFFFFFF),
utcrc rz_hash_crc_preset(const ut8 *data, ut32 size, RzCrcPresets preset)
#define CRC_PRESET(crc, size, reflect, poly, xout)
void crc_final(RzCrc *ctx, utcrc *r)
void crc_init_preset(RzCrc *ctx, RzCrcPresets preset)
void crc_update(RzCrc *ctx, const ut8 *data, ut32 sz)
void crc_init_custom(RzCrc *ctx, utcrc crc, ut32 size, int reflect, utcrc poly, utcrc xout)