#ifndef __CRC_H
#define __CRC_H
-#include <stdint.h> //uint32+
-#include <stdbool.h> //bool
-#include <stddef.h>
+#include "common.h" //stdint, stddef, stdbool
#include "util.h" // reflect, bswap_16
typedef struct crc {
#define __CRC16_H
#include <stdint.h>
-#include "util.h"
+#include "util.h" // SwapBits
unsigned short update_crc16(unsigned short crc, unsigned char c);
uint16_t crc16(uint8_t const *message, int length, uint16_t remainder, uint16_t polynomial);
}
}
-void crc32 (const uint8_t *data, const size_t len, uint8_t *crc) {
+void crc32_ex (const uint8_t *data, const size_t len, uint8_t *crc) {
uint32_t desfire_crc = CRC32_PRESET;
for (size_t i = 0; i < len; i++) {
crc32_byte (&desfire_crc, data[i]);
}
void crc32_append (uint8_t *data, const size_t len) {
- crc32 (data, len, data + len);
+ crc32_ex (data, len, data + len);
}
\ No newline at end of file
#include <stdint.h>
#include <stddef.h>
-
#ifdef __cplusplus
extern "C" {
#endif
-void crc32 (const uint8_t *data, const size_t len, uint8_t *crc);
+void crc32_ex(const uint8_t *data, const size_t len, uint8_t *crc);
void crc32_append (uint8_t *data, const size_t len);
#ifdef __cplusplus
#include <string.h>
#include <stdarg.h>
#include "aes.h"
+#include "mifare.h"
#define MAX_CRYPTO_BLOCK_SIZE 16
/* Mifare DESFire EV1 Application crypto operations */
//-----------------------------------------------------------------------------
// parity functions
//-----------------------------------------------------------------------------
-
-#include <stdint.h>
+#include <parity.h>
const uint8_t OddByteParity[256] = {
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0
};
-
#ifndef __PARITY_H
#define __PARITY_H
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <stdint.h>
extern const uint8_t OddByteParity[256];
+extern const uint8_t EvenByteParity[256];
static inline uint8_t oddparity8(uint8_t bt)
{
return OddByteParity[bt];
}
-
-extern const uint8_t EvenByteParity[256];
-
static inline uint8_t evenparity8(const uint8_t bt)
{
return EvenByteParity[bt];
}
-
static inline uint8_t evenparity32(uint32_t x)
{
x ^= x >> 16;
return EvenByteParity[x & 0xff];
}
+#ifdef __cplusplus
+}
+#endif
#endif /* __PARITY_H */