SEFile
Userspace drivers to manage a secure filesystem
 All Data Structures Files Functions Variables Typedefs Enumerator Macros Groups
CRCSW.h
1 #pragma once
2 
3 
4 #ifndef _CRCSW_H_
5 #define _CRCSW_H_
6 
7 
8 #ifdef __cplusplus
9 extern "C" {
10 #endif
11 
12 
13 
14 /* includes */
15 #include <stdint.h>
16 /* END - includes */
17 
18 
19 
20 /* defines */
21 #define CRC16_POLY 0x1021 // x^16 + x^12 + x^5 + 1
22 /* END - defines */
23 
24 
25 
26 /* struct */
27  // CRC structure
28  typedef struct CRC16sw_ {
29  uint16_t state;
30  // (may be extended in the future)
31  } CRC16sw;
32 /* END - struct */
33 
34 
35 
36 /* prototypes */
37 
38 void crc16Init(CRC16sw *crc16); // Initialize CRC state
39 uint16_t crc16Update(uint8_t* dataIn, uint16_t dataInLen, CRC16sw *crc16); // Starting from the current CRC state, updates it by computing crc of dataIn
40 uint16_t crc16Compute(uint8_t* dataIn, uint16_t dataInLen, CRC16sw *crc16); // Reset the state and computes the CRC of dataIn
41 int32_t crc16Check(uint16_t crc, uint8_t* dataIn, uint16_t dataLen); // Computes the CRC of dataIn and compares it to crc input
42 
43 /* END - prototypes*/
44 
45 
46 #ifdef __cplusplus
47 }
48 #endif
49 
50 #endif /* _CRCSW_H_ */
Definition: CRCSW.h:28