CHG: moved into header files.

This commit is contained in:
iceman1001 2017-01-25 00:35:11 +01:00
parent 0ccf8adac4
commit e36b07efc4
7 changed files with 15 additions and 15 deletions

View file

@ -9,9 +9,7 @@
#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 {

View file

@ -9,7 +9,7 @@
#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);

View file

@ -18,7 +18,7 @@ static void crc32_byte (uint32_t *crc, const uint8_t value) {
}
}
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]);
@ -28,5 +28,5 @@ void crc32 (const uint8_t *data, const size_t len, uint8_t *crc) {
}
void crc32_append (uint8_t *data, const size_t len) {
crc32 (data, len, data + len);
crc32_ex (data, len, data + len);
}

View file

@ -12,12 +12,11 @@
#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

View file

@ -4,6 +4,7 @@
#include <string.h>
#include <stdarg.h>
#include "aes.h"
#include "mifare.h"
#define MAX_CRYPTO_BLOCK_SIZE 16
/* Mifare DESFire EV1 Application crypto operations */

View file

@ -5,8 +5,7 @@
//-----------------------------------------------------------------------------
// 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,
@ -45,5 +44,4 @@ const uint8_t EvenByteParity[256] = {
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
};

View file

@ -9,24 +9,25 @@
#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;
@ -34,5 +35,8 @@ static inline uint8_t evenparity32(uint32_t x)
return EvenByteParity[x & 0xff];
}
#ifdef __cplusplus
}
#endif
#endif /* __PARITY_H */