]>
git.zerfleddert.de Git - proxmark3-svn/blob - common/crc32.c
69d770f4afb382efecf1c6aeabe9bf8bfb7531e5
6 #define CRC32_PRESET 0xFFFFFFFF
9 static void crc32_byte (uint32_t *crc
, const uint8_t value
);
11 static void crc32_byte (uint32_t *crc
, const uint8_t value
) {
12 /* x32 + x26 + x23 + x22 + x16 + x12 + x11 + x10 + x8 + x7 + x5 + x4 + x2 + x + 1 */
13 const uint32_t poly
= 0xEDB88320;
16 for (int current_bit
= 7; current_bit
>= 0; current_bit
--) {
17 int bit_out
= (*crc
) & 0x00000001;
24 void crc32 (const uint8_t *data
, const size_t len
, uint8_t *crc
) {
25 uint32_t desfire_crc
= CRC32_PRESET
;
26 for (size_t i
= 0; i
< len
; i
++) {
27 crc32_byte (&desfire_crc
, data
[i
]);
30 *((uint32_t *)(crc
)) = htole32 (desfire_crc
);
33 void crc32_append (uint8_t *data
, const size_t len
) {
34 crc32 (data
, len
, data
+ len
);