forked from CunningLogic/crchack
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcrc.h
27 lines (22 loc) · 772 Bytes
/
crc.h
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
#ifndef CRC_H
#define CRC_H
#include <stddef.h>
#include "crchack.h"
#include "bigint.h"
struct crc_params {
int width; /* Width of the CRC register in bits */
struct bigint poly; /* Generator polynomial */
struct bigint init; /* Initial CRC register value */
struct bigint xor_out; /* Final CRC register XOR mask */
int reflect_in; /* Reverse input bits (LSB first instead of MSB) */
int reflect_out; /* Reverse the final CRC register bits */
};
/**
* Calculate CRC checksum using parameters defined in *config.
*
* The result is written to *out which must point to an initialized bigint
* structure.
*/
void crc(const u8 *msg, size_t length, struct crc_params *config,
struct bigint *out);
#endif