mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-03-06 04:55:42 +08:00
rename typedef structs
This commit is contained in:
parent
f6d88dced2
commit
f4f14317e1
8 changed files with 37 additions and 37 deletions
|
@ -143,12 +143,12 @@ static uint64_t hex2i(const char *s) {
|
|||
"\"0x8829da9daf76\",\"0x8829da9daf76\","
|
||||
"\"0x8829da9daf76\",\"0x8829da9daf76\"]}";*/
|
||||
|
||||
typedef struct MFC1KSchema {
|
||||
typedef struct {
|
||||
uint8_t name[32];
|
||||
uint64_t trigger;
|
||||
uint64_t keysA[16];
|
||||
uint64_t keysB[16];
|
||||
} MFC1KSchema;
|
||||
} MFC1KSchema_t;
|
||||
|
||||
#define MAX_SCHEMAS 4
|
||||
|
||||
|
@ -162,9 +162,9 @@ static void scan_keys(const char *str, int len, uint64_t *user_data) {
|
|||
}
|
||||
}
|
||||
|
||||
static MFC1KSchema Schemas[MAX_SCHEMAS];
|
||||
static MFC1KSchema_t Schemas[MAX_SCHEMAS];
|
||||
|
||||
/*MFC1KSchema Noralsy = {
|
||||
/*MFC1KSchema_t Noralsy = {
|
||||
.name = "Noralsy",
|
||||
.trigger = 0x414c41524f4e,
|
||||
.keysA = {0x414c41524f4e, 0x414c41524f4e, 0x414c41524f4e, 0x414c41524f4e, 0x414c41524f4e, 0x414c41524f4e,
|
||||
|
@ -174,7 +174,7 @@ static MFC1KSchema Schemas[MAX_SCHEMAS];
|
|||
0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e,
|
||||
0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e, 0x424c41524f4e}};
|
||||
|
||||
MFC1KSchema InfiHexact = {.name = "Infineon/Hexact",
|
||||
MFC1KSchema_t InfiHexact = {.name = "Infineon/Hexact",
|
||||
.trigger = 0x484558414354,
|
||||
.keysA = {0x484558414354, 0x484558414354, 0x484558414354, 0x484558414354, 0x484558414354,
|
||||
0x484558414354, 0x484558414354, 0x484558414354, 0x484558414354, 0x484558414354,
|
||||
|
@ -185,7 +185,7 @@ MFC1KSchema InfiHexact = {.name = "Infineon/Hexact",
|
|||
0x8fa1d601d0a2, 0x89347350bd36, 0x66d2b7dc39ef, 0x6bc1e1ae547d, 0x22729a9bd40f}};
|
||||
*/
|
||||
|
||||
/*MFC1KSchema UrmetCaptive = {
|
||||
/*MFC1KSchema_t UrmetCaptive = {
|
||||
.name = "Urmet Captive",
|
||||
.trigger = 0x8829da9daf76,
|
||||
.keysA = {0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76, 0x8829da9daf76,
|
||||
|
@ -198,14 +198,14 @@ MFC1KSchema InfiHexact = {.name = "Infineon/Hexact",
|
|||
|
||||
static int total_schemas = 0;
|
||||
|
||||
static void add_schema(MFC1KSchema *p, MFC1KSchema a, int *schemas_counter) {
|
||||
static void add_schema(MFC1KSchema_t *p, MFC1KSchema_t a, int *schemas_counter) {
|
||||
if (*schemas_counter < MAX_SCHEMAS) {
|
||||
p[*schemas_counter] = a;
|
||||
*schemas_counter += 1;
|
||||
}
|
||||
}
|
||||
/*
|
||||
static void delete_schema(MFC1KSchema *p, int *schemas_counter, int index) {
|
||||
static void delete_schema(MFC1KSchema_t *p, int *schemas_counter, int index) {
|
||||
if (*schemas_counter > 0 && index < *schemas_counter && index > -1) {
|
||||
int last_index = *schemas_counter - 1;
|
||||
for (int i = index; i < last_index; i++) {
|
||||
|
@ -256,7 +256,7 @@ static void add_schemas_from_json_in_spiffs(char *filename) {
|
|||
for (i = 0; json_scanf_array_elem(jsonfile, len, "", i, &t) > 0; i++) {
|
||||
char *tmpname;
|
||||
char *tmptrigger;
|
||||
MFC1KSchema tmpscheme;
|
||||
MFC1KSchema_t tmpscheme;
|
||||
json_scanf(t.ptr, t.len, "{ name:%Q, trigger:%Q, keysA:%M, keysB:%M}", &tmpname, &tmptrigger, scan_keys,
|
||||
&tmpscheme.keysA, scan_keys, &tmpscheme.keysB);
|
||||
memcpy(tmpscheme.name, tmpname, 32);
|
||||
|
|
|
@ -243,6 +243,6 @@ typedef struct {
|
|||
uint8_t tag_BF0C[222]; //File Control Information (FCI) Issuer Discretionary Data
|
||||
uint8_t tag_DFName[16];
|
||||
uint8_t tag_DFName_len;
|
||||
} emvtags;
|
||||
} emvtags_t;
|
||||
|
||||
#endif //__EMVCARD_H
|
||||
|
|
|
@ -22,13 +22,13 @@
|
|||
|
||||
#include "lz4.h" // uncompress
|
||||
|
||||
typedef struct lz4_stream_s {
|
||||
typedef struct {
|
||||
LZ4_streamDecode_t *lz4StreamDecode;
|
||||
char *next_in;
|
||||
int avail_in;
|
||||
} lz4_stream;
|
||||
} lz4_stream_t;
|
||||
|
||||
typedef lz4_stream *lz4_streamp;
|
||||
typedef lz4_stream_t *lz4_streamp_t;
|
||||
|
||||
// remember which version of the bitstream we have already downloaded to the FPGA
|
||||
static int downloaded_bitstream = 0;
|
||||
|
@ -190,7 +190,7 @@ bool FpgaSetupSscDma(uint8_t *buf, uint16_t len) {
|
|||
//----------------------------------------------------------------------------
|
||||
// Uncompress (inflate) the FPGA data. Returns one decompressed byte with each call.
|
||||
//----------------------------------------------------------------------------
|
||||
static int get_from_fpga_combined_stream(lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
static int get_from_fpga_combined_stream(lz4_streamp_t compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
if (fpga_image_ptr == output_buffer + FPGA_RING_BUFFER_BYTES) { // need more data
|
||||
fpga_image_ptr = output_buffer;
|
||||
int cmp_bytes;
|
||||
|
@ -217,7 +217,7 @@ static int get_from_fpga_combined_stream(lz4_streamp compressed_fpga_stream, uin
|
|||
// are combined into one big file:
|
||||
// 288 bytes from FPGA file 1, followed by 288 bytes from FGPA file 2, etc.
|
||||
//----------------------------------------------------------------------------
|
||||
static int get_from_fpga_stream(int bitstream_version, lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
static int get_from_fpga_stream(int bitstream_version, lz4_streamp_t compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
while ((uncompressed_bytes_cnt / FPGA_INTERLEAVE_SIZE) % g_fpga_bitstream_num != (bitstream_version - 1)) {
|
||||
// skip undesired data belonging to other bitstream_versions
|
||||
get_from_fpga_combined_stream(compressed_fpga_stream, output_buffer);
|
||||
|
@ -229,7 +229,7 @@ static int get_from_fpga_stream(int bitstream_version, lz4_streamp compressed_fp
|
|||
//----------------------------------------------------------------------------
|
||||
// Initialize decompression of the respective (HF or LF) FPGA stream
|
||||
//----------------------------------------------------------------------------
|
||||
static bool reset_fpga_stream(int bitstream_version, lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
static bool reset_fpga_stream(int bitstream_version, lz4_streamp_t compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
uint8_t header[FPGA_BITSTREAM_FIXED_HEADER_SIZE];
|
||||
|
||||
uncompressed_bytes_cnt = 0;
|
||||
|
@ -267,7 +267,7 @@ static void DownloadFPGA_byte(uint8_t w) {
|
|||
}
|
||||
|
||||
// Download the fpga image starting at current stream position with length FpgaImageLen bytes
|
||||
static void DownloadFPGA(int bitstream_version, int FpgaImageLen, lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
static void DownloadFPGA(int bitstream_version, int FpgaImageLen, lz4_streamp_t compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
int i = 0;
|
||||
|
||||
AT91C_BASE_PIOA->PIO_OER = GPIO_FPGA_ON;
|
||||
|
@ -349,7 +349,7 @@ static void DownloadFPGA(int bitstream_version, int FpgaImageLen, lz4_streamp co
|
|||
* (big endian), <length> bytes content. Except for section 'e' which has 4 bytes
|
||||
* length.
|
||||
*/
|
||||
static int bitparse_find_section(int bitstream_version, char section_name, uint32_t *section_length, lz4_streamp compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
static int bitparse_find_section(int bitstream_version, char section_name, uint32_t *section_length, lz4_streamp_t compressed_fpga_stream, uint8_t *output_buffer) {
|
||||
|
||||
#define MAX_FPGA_BIT_STREAM_HEADER_SEARCH 100 // maximum number of bytes to search for the requested section
|
||||
|
||||
|
@ -417,7 +417,7 @@ void FpgaDownloadAndGo(int bitstream_version) {
|
|||
BigBuf_free();
|
||||
BigBuf_Clear_ext(verbose);
|
||||
|
||||
lz4_stream compressed_fpga_stream;
|
||||
lz4_stream_t compressed_fpga_stream;
|
||||
LZ4_streamDecode_t lz4StreamDecode_body = {{ 0 }};
|
||||
compressed_fpga_stream.lz4StreamDecode = &lz4StreamDecode_body;
|
||||
uint8_t *output_buffer = BigBuf_malloc(FPGA_RING_BUFFER_BYTES);
|
||||
|
|
|
@ -42,7 +42,7 @@ static sample_config def_config = {
|
|||
static sample_config config = { 1, 8, 1, LF_DIVISOR_125, 0, 0, true} ;
|
||||
|
||||
// Holds bit packed struct of samples.
|
||||
static BitstreamOut data = {0, 0, 0};
|
||||
static BitstreamOut_t data = {0, 0, 0};
|
||||
|
||||
// internal struct to keep track of samples gathered
|
||||
static sampling_t samples = {0, 0, 0, 0};
|
||||
|
@ -123,7 +123,7 @@ sample_config *getSamplingConfig(void) {
|
|||
* @param stream
|
||||
* @param bit
|
||||
*/
|
||||
static void pushBit(BitstreamOut *stream, uint8_t bit) {
|
||||
static void pushBit(BitstreamOut_t *stream, uint8_t bit) {
|
||||
int bytepos = stream->position >> 3; // divide by 8
|
||||
int bitpos = stream->position & 7;
|
||||
*(stream->buffer + bytepos) &= ~(1 << (7 - bitpos));
|
||||
|
|
|
@ -8,7 +8,7 @@ typedef struct {
|
|||
uint8_t *buffer;
|
||||
uint32_t numbits;
|
||||
uint32_t position;
|
||||
} BitstreamOut;
|
||||
} BitstreamOut_t;
|
||||
|
||||
typedef struct {
|
||||
int dec_counter;
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
* @param stream
|
||||
* @return
|
||||
*/
|
||||
bool headBit(BitstreamIn *stream) {
|
||||
bool headBit(BitstreamIn_t *stream) {
|
||||
int bytepos = stream->position >> 3; // divide by 8
|
||||
int bitpos = (stream->position++) & 7; // mask out 00000111
|
||||
return (*(stream->buffer + bytepos) >> (7 - bitpos)) & 1;
|
||||
|
@ -53,7 +53,7 @@ bool headBit(BitstreamIn *stream) {
|
|||
* @param stream
|
||||
* @return
|
||||
*/
|
||||
bool tailBit(BitstreamIn *stream) {
|
||||
bool tailBit(BitstreamIn_t *stream) {
|
||||
int bitpos = stream->numbits - 1 - (stream->position++);
|
||||
|
||||
int bytepos = bitpos >> 3;
|
||||
|
@ -65,7 +65,7 @@ bool tailBit(BitstreamIn *stream) {
|
|||
* @param stream
|
||||
* @param bit
|
||||
*/
|
||||
void pushBit(BitstreamOut *stream, bool bit) {
|
||||
void pushBit(BitstreamOut_t *stream, bool bit) {
|
||||
int bytepos = stream->position >> 3; // divide by 8
|
||||
int bitpos = stream->position & 7;
|
||||
*(stream->buffer + bytepos) |= (bit) << (7 - bitpos);
|
||||
|
@ -79,7 +79,7 @@ void pushBit(BitstreamOut *stream, bool bit) {
|
|||
* @param stream
|
||||
* @param bits
|
||||
*/
|
||||
void push6bits(BitstreamOut *stream, uint8_t bits) {
|
||||
void push6bits(BitstreamOut_t *stream, uint8_t bits) {
|
||||
pushBit(stream, bits & 0x20);
|
||||
pushBit(stream, bits & 0x10);
|
||||
pushBit(stream, bits & 0x08);
|
||||
|
@ -93,7 +93,7 @@ void push6bits(BitstreamOut *stream, uint8_t bits) {
|
|||
* @param stream
|
||||
* @return number of bits left in stream
|
||||
*/
|
||||
int bitsLeft(BitstreamIn *stream) {
|
||||
int bitsLeft(BitstreamIn_t *stream) {
|
||||
return stream->numbits - stream->position;
|
||||
}
|
||||
/**
|
||||
|
|
|
@ -44,20 +44,20 @@ typedef struct {
|
|||
uint8_t *buffer;
|
||||
uint8_t numbits;
|
||||
uint8_t position;
|
||||
} BitstreamIn;
|
||||
} BitstreamIn_t;
|
||||
|
||||
typedef struct {
|
||||
uint8_t *buffer;
|
||||
uint8_t numbits;
|
||||
uint8_t position;
|
||||
} BitstreamOut;
|
||||
} BitstreamOut_t;
|
||||
|
||||
bool headBit(BitstreamIn *stream);
|
||||
bool tailBit(BitstreamIn *stream);
|
||||
void pushBit(BitstreamOut *stream, bool bit);
|
||||
int bitsLeft(BitstreamIn *stream);
|
||||
bool headBit(BitstreamIn_t *stream);
|
||||
bool tailBit(BitstreamIn_t *stream);
|
||||
void pushBit(BitstreamOut_t *stream, bool bit);
|
||||
int bitsLeft(BitstreamIn_t *stream);
|
||||
|
||||
void push6bits(BitstreamOut *stream, uint8_t bits);
|
||||
void push6bits(BitstreamOut_t *stream, uint8_t bits);
|
||||
void x_num_to_bytes(uint64_t n, size_t len, uint8_t *dest);
|
||||
uint64_t x_bytes_to_num(uint8_t *src, size_t len);
|
||||
uint8_t reversebytes(uint8_t b);
|
||||
|
|
|
@ -196,7 +196,7 @@ static uint64_t check(uint64_t z) {
|
|||
return ck1 | ck2 >> 24;
|
||||
}
|
||||
|
||||
static void permute(BitstreamIn *p_in, uint64_t z, int l, int r, BitstreamOut *out) {
|
||||
static void permute(BitstreamIn_t *p_in, uint64_t z, int l, int r, BitstreamOut_t *out) {
|
||||
if (bitsLeft(p_in) == 0)
|
||||
return;
|
||||
|
||||
|
@ -251,9 +251,9 @@ void hash0(uint64_t c, uint8_t k[8]) {
|
|||
if (x & 1) //Check if x7 is 1
|
||||
p = ~p;
|
||||
|
||||
BitstreamIn p_in = { &p, 8, 0 };
|
||||
BitstreamIn_t p_in = { &p, 8, 0 };
|
||||
uint8_t outbuffer[] = {0, 0, 0, 0, 0, 0, 0, 0};
|
||||
BitstreamOut out = {outbuffer, 0, 0};
|
||||
BitstreamOut_t out = {outbuffer, 0, 0};
|
||||
permute(&p_in, zCaret, 0, 4, &out); //returns 48 bits? or 6 8-bytes
|
||||
|
||||
//Out is now a buffer containing six-bit bytes, should be 48 bits
|
||||
|
|
Loading…
Reference in a new issue