From f4f14317e1a6c2eacdb991218014e1775b93fd39 Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 21 Aug 2021 22:24:58 +0200 Subject: [PATCH] rename typedef structs --- armsrc/Standalone/hf_colin.c | 18 +++++++++--------- armsrc/emvtags.h | 2 +- armsrc/fpgaloader.c | 18 +++++++++--------- armsrc/lfsampling.c | 4 ++-- armsrc/lfsampling.h | 2 +- armsrc/optimized_cipherutils.c | 10 +++++----- armsrc/optimized_cipherutils.h | 14 +++++++------- armsrc/optimized_ikeys.c | 6 +++--- 8 files changed, 37 insertions(+), 37 deletions(-) diff --git a/armsrc/Standalone/hf_colin.c b/armsrc/Standalone/hf_colin.c index e3115ee7a..945c1cbc9 100644 --- a/armsrc/Standalone/hf_colin.c +++ b/armsrc/Standalone/hf_colin.c @@ -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); diff --git a/armsrc/emvtags.h b/armsrc/emvtags.h index c64b248a3..fda3b2f37 100644 --- a/armsrc/emvtags.h +++ b/armsrc/emvtags.h @@ -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 diff --git a/armsrc/fpgaloader.c b/armsrc/fpgaloader.c index 511958470..0b92f67b2 100644 --- a/armsrc/fpgaloader.c +++ b/armsrc/fpgaloader.c @@ -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), 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); diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index f478b7378..ca9be74b7 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -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)); diff --git a/armsrc/lfsampling.h b/armsrc/lfsampling.h index 7a2967f7e..7173026a9 100644 --- a/armsrc/lfsampling.h +++ b/armsrc/lfsampling.h @@ -8,7 +8,7 @@ typedef struct { uint8_t *buffer; uint32_t numbits; uint32_t position; -} BitstreamOut; +} BitstreamOut_t; typedef struct { int dec_counter; diff --git a/armsrc/optimized_cipherutils.c b/armsrc/optimized_cipherutils.c index c51f83f9b..14b699b8a 100644 --- a/armsrc/optimized_cipherutils.c +++ b/armsrc/optimized_cipherutils.c @@ -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; } /** diff --git a/armsrc/optimized_cipherutils.h b/armsrc/optimized_cipherutils.h index 63ba8b8aa..b95dd5f35 100644 --- a/armsrc/optimized_cipherutils.h +++ b/armsrc/optimized_cipherutils.h @@ -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); diff --git a/armsrc/optimized_ikeys.c b/armsrc/optimized_ikeys.c index eeb00e562..b5600cf52 100644 --- a/armsrc/optimized_ikeys.c +++ b/armsrc/optimized_ikeys.c @@ -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