make style

This commit is contained in:
Philippe Teuwen 2020-06-08 03:15:10 +02:00
parent a1eb8e78b6
commit 224cb2ffd7
38 changed files with 1531 additions and 1550 deletions

View file

@ -330,11 +330,11 @@ void ModInfo(void) {
void RunMod(void) { void RunMod(void) {
StandAloneMode(); StandAloneMode();
FpgaDownloadAndGo(FPGA_BITSTREAM_HF); FpgaDownloadAndGo(FPGA_BITSTREAM_HF);
Dbprintf(">> HF Mifare ultra fast sniff/sim/clone a.k.a VIGIKPWN Started <<"); Dbprintf(">> HF Mifare ultra fast sniff/sim/clone a.k.a VIGIKPWN Started <<");
// turn off all debugging. // turn off all debugging.
DBGLEVEL = DBG_NONE; DBGLEVEL = DBG_NONE;
// add_schema(Schemas, Noralsy, &total_schemas); // add_schema(Schemas, Noralsy, &total_schemas);
// add_schema(Schemas, InfiHexact, &total_schemas); // add_schema(Schemas, InfiHexact, &total_schemas);
// add_schema_from_json_in_spiffs((char *)HFCOLIN_URMETCAPTIVE_JSON); // add_schema_from_json_in_spiffs((char *)HFCOLIN_URMETCAPTIVE_JSON);
@ -504,7 +504,7 @@ failtag:
SpinOff(50); SpinOff(50);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
vtsend_cursor_position_restore(NULL); vtsend_cursor_position_restore(NULL);
DbprintfEx(FLAG_NEWLINE, "\t\t\t%s[ GOT a Tag ! ]%s", _XGREEN_, _XWHITE_); DbprintfEx(FLAG_NEWLINE, "\t\t\t%s[ GOT a Tag ! ]%s", _XGREEN_, _XWHITE_);
cjSetCursLeft(); cjSetCursLeft();
@ -854,7 +854,7 @@ int cjat91_saMifareChkKeys(uint8_t blockNo, uint8_t keyType, bool clearTrace,
pcs = &mpcs; pcs = &mpcs;
int retval = -1; int retval = -1;
for (uint8_t i = 0; i < keyCount; i++) { for (uint8_t i = 0; i < keyCount; i++) {
/* no need for anticollision. just verify tag is still here */ /* no need for anticollision. just verify tag is still here */

View file

@ -263,7 +263,7 @@ static int saMifareECardLoad(uint32_t numofsectors, uint8_t keytype) {
retval = PM3_ESOFT; retval = PM3_ESOFT;
break; break;
}; };
if (blockNo < NumBlocksPerSector(s) - 1) { if (blockNo < NumBlocksPerSector(s) - 1) {
emlSetMem(dataoutbuf, FirstBlockOfSector(s) + blockNo, 1); emlSetMem(dataoutbuf, FirstBlockOfSector(s) + blockNo, 1);
} else { } else {
@ -356,7 +356,7 @@ void RunMod(void) {
0x89347350bd36, // INFINEON B 0B 0x89347350bd36, // INFINEON B 0B
0x66d2b7dc39ef, // INFINEON B 0C 0x66d2b7dc39ef, // INFINEON B 0C
0x6bc1e1ae547d, // INFINEON B 0D 0x6bc1e1ae547d, // INFINEON B 0D
0x22729a9bd40f, // INFINEON B 0E 0x22729a9bd40f, // INFINEON B 0E
0xd2ece8b9395e, // lib / Nat Bieb 0xd2ece8b9395e, // lib / Nat Bieb
0x1494E81663D7, // # NSCP default key 0x1494E81663D7, // # NSCP default key
0x569369c5a0e5, // # kiev 0x569369c5a0e5, // # kiev
@ -505,10 +505,10 @@ void RunMod(void) {
if (ecfill) { if (ecfill) {
int filled; int filled;
Dbprintf("\tFilling in with key A."); Dbprintf("\tFilling in with key A.");
filled = saMifareECardLoad(sectorsCnt, 0); filled = saMifareECardLoad(sectorsCnt, 0);
if (filled != PM3_SUCCESS) { if (filled != PM3_SUCCESS) {
Dbprintf("\t [✕] Failed filling with A."); Dbprintf("\t [✕] Failed filling with A.");
Dbprintf("\tFilling in with key B."); Dbprintf("\tFilling in with key B.");
filled = saMifareECardLoad(sectorsCnt, 1); filled = saMifareECardLoad(sectorsCnt, 1);

View file

@ -23,12 +23,12 @@
#include "lz4.h" // uncompress #include "lz4.h" // uncompress
typedef struct lz4_stream_s { typedef struct lz4_stream_s {
LZ4_streamDecode_t* lz4StreamDecode; LZ4_streamDecode_t *lz4StreamDecode;
char * next_in; char *next_in;
int avail_in; int avail_in;
} lz4_stream; } lz4_stream;
typedef lz4_stream* lz4_streamp; typedef lz4_stream *lz4_streamp;
// remember which version of the bitstream we have already downloaded to the FPGA // remember which version of the bitstream we have already downloaded to the FPGA
static int downloaded_bitstream = 0; static int downloaded_bitstream = 0;
@ -194,9 +194,9 @@ static int get_from_fpga_combined_stream(lz4_streamp compressed_fpga_stream, uin
memcpy(&cmp_bytes, compressed_fpga_stream->next_in, sizeof(int)); memcpy(&cmp_bytes, compressed_fpga_stream->next_in, sizeof(int));
compressed_fpga_stream->next_in += 4; compressed_fpga_stream->next_in += 4;
compressed_fpga_stream->avail_in -= cmp_bytes + 4; compressed_fpga_stream->avail_in -= cmp_bytes + 4;
int res = LZ4_decompress_safe_continue(compressed_fpga_stream->lz4StreamDecode, int res = LZ4_decompress_safe_continue(compressed_fpga_stream->lz4StreamDecode,
compressed_fpga_stream->next_in, compressed_fpga_stream->next_in,
(char*)output_buffer, (char *)output_buffer,
cmp_bytes, cmp_bytes,
FPGA_RING_BUFFER_BYTES); FPGA_RING_BUFFER_BYTES);
if (res <= 0) { if (res <= 0) {
@ -232,9 +232,9 @@ static bool reset_fpga_stream(int bitstream_version, lz4_streamp compressed_fpga
uncompressed_bytes_cnt = 0; uncompressed_bytes_cnt = 0;
// initialize z_stream structure for inflate: // initialize z_stream structure for inflate:
compressed_fpga_stream->next_in = (char*)&_binary_obj_fpga_all_bit_z_start; compressed_fpga_stream->next_in = (char *)&_binary_obj_fpga_all_bit_z_start;
compressed_fpga_stream->avail_in = &_binary_obj_fpga_all_bit_z_end - &_binary_obj_fpga_all_bit_z_start; compressed_fpga_stream->avail_in = &_binary_obj_fpga_all_bit_z_end - &_binary_obj_fpga_all_bit_z_start;
int res = LZ4_setStreamDecode(compressed_fpga_stream->lz4StreamDecode, NULL, 0); int res = LZ4_setStreamDecode(compressed_fpga_stream->lz4StreamDecode, NULL, 0);
if (res == 0) if (res == 0)
return false; return false;
@ -415,7 +415,7 @@ void FpgaDownloadAndGo(int bitstream_version) {
lz4_stream compressed_fpga_stream; lz4_stream compressed_fpga_stream;
LZ4_streamDecode_t lz4StreamDecode_body = {{ 0 }}; LZ4_streamDecode_t lz4StreamDecode_body = {{ 0 }};
compressed_fpga_stream.lz4StreamDecode = &lz4StreamDecode_body; compressed_fpga_stream.lz4StreamDecode = &lz4StreamDecode_body;
uint8_t * output_buffer = BigBuf_malloc(FPGA_RING_BUFFER_BYTES); uint8_t *output_buffer = BigBuf_malloc(FPGA_RING_BUFFER_BYTES);
if (!reset_fpga_stream(bitstream_version, &compressed_fpga_stream, output_buffer)) if (!reset_fpga_stream(bitstream_version, &compressed_fpga_stream, output_buffer))
return; return;

View file

@ -29,7 +29,7 @@ static void uncompress_data_section(void) {
int avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct. int avail_out = &__data_end__ - &__data_start__; // uncompressed size. Correct.
// uncompress data segment to RAM // uncompress data segment to RAM
uintptr_t p = (uintptr_t)&__data_src_start__; uintptr_t p = (uintptr_t)&__data_src_start__;
int res = LZ4_decompress_safe((char*)p + 4, &__data_start__, avail_in, avail_out); int res = LZ4_decompress_safe((char *)p + 4, &__data_start__, avail_in, avail_out);
if (res < 0) if (res < 0)
return; return;

View file

@ -20,21 +20,19 @@ void *memcpy(void *dest, const void *src, int len) {
return dest; return dest;
} }
void *memmove (void *dest, const void *src, size_t len) void *memmove(void *dest, const void *src, size_t len) {
{ char *d = dest;
char *d = dest; const char *s = src;
const char *s = src; if (d < s)
if (d < s) while (len--)
while (len--) *d++ = *s++;
*d++ = *s++; else {
else char *lasts = (char *)s + (len - 1);
{ char *lastd = d + (len - 1);
char *lasts = (char*)s + (len-1); while (len--)
char *lastd = d + (len-1); *lastd-- = *lasts--;
while (len--)
*lastd-- = *lasts--;
} }
return dest; return dest;
} }
void *memset(void *dest, int c, int len) { void *memset(void *dest, int c, int len) {

View file

@ -16,7 +16,7 @@
int strlen(const char *str); int strlen(const char *str);
void *memcpy(void *dest, const void *src, int len); void *memcpy(void *dest, const void *src, int len);
void *memmove (void *dest, const void *src, size_t len); void *memmove(void *dest, const void *src, size_t len);
void *memset(void *dest, int c, int len); void *memset(void *dest, int c, int len);
int memcmp(const void *av, const void *bv, int len); int memcmp(const void *av, const void *bv, int len);
void memxor(uint8_t *dest, uint8_t *src, size_t len); void memxor(uint8_t *dest, uint8_t *src, size_t len);

View file

@ -88,7 +88,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
char *cmd = (char *) ((*env)->GetStringUTFChars(env, cmd_, 0)); char *cmd = (char *)((*env)->GetStringUTFChars(env, cmd_, 0));
int ret = CommandReceived(cmd); int ret = CommandReceived(cmd);
if (ret == 99) { if (ret == 99) {
// exit / quit // exit / quit
@ -104,7 +104,7 @@ jint Console(JNIEnv *env, jobject instance, jstring cmd_) {
* Is client running! * Is client running!
* */ * */
jboolean IsClientRunning(JNIEnv *env, jobject instance) { jboolean IsClientRunning(JNIEnv *env, jobject instance) {
return (jboolean) ((jboolean) conn.run); return (jboolean)((jboolean) conn.run);
} }
/* /*
@ -116,7 +116,7 @@ jboolean TestPm3(JNIEnv *env, jobject instance) {
return false; return false;
} }
bool ret = (TestProxmark() == PM3_SUCCESS); bool ret = (TestProxmark() == PM3_SUCCESS);
return (jboolean) (ret); return (jboolean)(ret);
} }
/* /*
@ -129,8 +129,8 @@ void ClosePm3(JNIEnv *env, jobject instance) {
/* /*
* native function map to jvm * native function map to jvm
* */ * */
//iceman: todo, pm3:ify java class root. Return codes, should match PM3_E* codes. //iceman: todo, pm3:ify java class root. Return codes, should match PM3_E* codes.
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) { JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *jniEnv = NULL; JNIEnv *jniEnv = NULL;
if ((*vm)->GetEnv(vm, (void **) &jniEnv, JNI_VERSION_1_4) != JNI_OK) { if ((*vm)->GetEnv(vm, (void **) &jniEnv, JNI_VERSION_1_4) != JNI_OK) {
@ -143,14 +143,14 @@ JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved) {
} }
jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4"); jclass clz_test = (*jniEnv)->FindClass(jniEnv, "cn/rrg/devices/Proxmark3RRGRdv4");
JNINativeMethod methods[] = { JNINativeMethod methods[] = {
{"startExecute", "(Ljava/lang/String;)I", (void *) Console}, {"startExecute", "(Ljava/lang/String;)I", (void *) Console},
{"stopExecute", "()V", (void *) ClosePm3}, {"stopExecute", "()V", (void *) ClosePm3},
{"isExecuting", "()Z", (void *) IsClientRunning} {"isExecuting", "()Z", (void *) IsClientRunning}
}; };
JNINativeMethod methods1[] = { JNINativeMethod methods1[] = {
{"testPm3", "()Z", (void *) TestPm3}, {"testPm3", "()Z", (void *) TestPm3},
{"closePm3", "()V", ClosePm3} {"closePm3", "()V", ClosePm3}
}; };
if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) != JNI_OK) { if ((*jniEnv)->RegisterNatives(jniEnv, clazz, methods, sizeof(methods) / sizeof(methods[0])) != JNI_OK) {

View file

@ -558,9 +558,9 @@ enum CborPrettyFlags {
/* cf https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ */ /* cf https://sourceforge.net/p/mingw-w64/wiki2/gnu%20printf/ */
typedef CborError(*CborStreamFunction)(void *token, const char *fmt, ...) typedef CborError(*CborStreamFunction)(void *token, const char *fmt, ...)
#if defined(__MINGW32__) || defined(__MINGW64__) #if defined(__MINGW32__) || defined(__MINGW64__)
__attribute__((format (__MINGW_PRINTF_FORMAT, 2, 3))); __attribute__((format(__MINGW_PRINTF_FORMAT, 2, 3)));
#elif defined(__GNUC__) #elif defined(__GNUC__)
__attribute__((__format__(printf, 2, 3))) __attribute__((__format__(printf, 2, 3)))
#endif #endif
; ;

View file

@ -39,7 +39,7 @@ script run test_t55x7 [-h] [-t <modulation type>
]] ]]
arguments = [[ arguments = [[
-h this help -h this help
-t (optional, defaults to ASK) 'PSK1', 'PSK2', 'PSK3', -t (optional, defaults to ASK) 'PSK1', 'PSK2', 'PSK3',
'FSK1', 'FSK2', 'FSK1A', 'FSK2A', 'FSK1', 'FSK2', 'FSK1A', 'FSK2A',
'ASK', 'BI' 'ASK', 'BI'
]] ]]

View file

@ -79,7 +79,7 @@ local function main(args)
local cmdDataLoad = 'data load %s'; local cmdDataLoad = 'data load %s';
local cwd = core.cwd(); local cwd = core.cwd();
local tracesEM = "find '"..cwd.."/traces/ ' -iname 'em*.pm3' -type f" local tracesEM = "find '"..cwd.."/traces/ ' -iname 'em*.pm3' -type f"
local tracesMOD = "find '"..cwd.."/traces/' -iname 'modulation*.pm3' -type f" local tracesMOD = "find '"..cwd.."/traces/' -iname 'modulation*.pm3' -type f"

View file

@ -48,4 +48,4 @@ def main():
print('\nTarget (%02X) requires final LRC XOR byte value: %02X\n' % (target,lrc)) print('\nTarget (%02X) requires final LRC XOR byte value: %02X\n' % (target,lrc))
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View file

@ -1683,7 +1683,7 @@ static int CmdHF15Restore(const char *Cmd) {
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename); PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename);
return PM3_EFILE; return PM3_EFILE;
} }
if ((datalen % blocksize) != 0) { if ((datalen % blocksize) != 0) {
PrintAndLogEx(WARNING, "Datalen %zu isn't dividable with blocksize %zu", datalen, blocksize); PrintAndLogEx(WARNING, "Datalen %zu isn't dividable with blocksize %zu", datalen, blocksize);
free(data); free(data);
@ -1704,7 +1704,7 @@ static int CmdHF15Restore(const char *Cmd) {
if (addressed_mode) { if (addressed_mode) {
char uidhex[17] = {0x00}; char uidhex[17] = {0x00};
hex_to_buffer((uint8_t *)uidhex, uid, sizeof(uid), sizeof(uidhex) - 1, 0, false, true); hex_to_buffer((uint8_t *)uidhex, uid, sizeof(uid), sizeof(uidhex) - 1, 0, false, true);
hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true); hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true);
snprintf(tmpCmd, sizeof(tmpCmd), "%s %s %u %s", newPrefix, uidhex, i, hex); snprintf(tmpCmd, sizeof(tmpCmd), "%s %s %u %s", newPrefix, uidhex, i, hex);
} else { } else {
hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true); hex_to_buffer((uint8_t *)hex, data + i, blocksize, sizeof(hex) - 1, 0, false, true);
@ -1718,7 +1718,7 @@ static int CmdHF15Restore(const char *Cmd) {
break; break;
} }
} }
if (tried >= retries) { if (tried >= retries) {
free(data); free(data);
PrintAndLogEx(FAILED, "Restore failed. Too many retries."); PrintAndLogEx(FAILED, "Restore failed. Too many retries.");
@ -1729,7 +1729,7 @@ static int CmdHF15Restore(const char *Cmd) {
} }
free(data); free(data);
PrintAndLogEx(INFO, "done"); PrintAndLogEx(INFO, "done");
PrintAndLogEx(HINT, "Try reading your card to verify with " _YELLOW_("`hf 15 dump`") ); PrintAndLogEx(HINT, "Try reading your card to verify with " _YELLOW_("`hf 15 dump`"));
return PM3_SUCCESS; return PM3_SUCCESS;
} }

View file

@ -586,7 +586,7 @@ static int CmdHfLTRestore(const char *Cmd) {
} }
} }
if (errors || strlen(Cmd) == 0 ) { if (errors || strlen(Cmd) == 0) {
return usage_lto_restore(); return usage_lto_restore();
} }
@ -597,7 +597,7 @@ static int CmdHfLTRestore(const char *Cmd) {
if (str_endswith(lowstr, ".bin")) { if (str_endswith(lowstr, ".bin")) {
uint8_t *dump = NULL; uint8_t *dump = NULL;
if (loadFile_safe(filename, "", (void**)&dump, &dump_len) == PM3_SUCCESS) { if (loadFile_safe(filename, "", (void **)&dump, &dump_len) == PM3_SUCCESS) {
restoreLTO(dump, true); restoreLTO(dump, true);
} }
free(dump); free(dump);
@ -605,7 +605,7 @@ static int CmdHfLTRestore(const char *Cmd) {
} else if (str_endswith(lowstr, ".eml")) { } else if (str_endswith(lowstr, ".eml")) {
uint8_t *dump = NULL; uint8_t *dump = NULL;
if (loadFileEML_safe(filename, (void**)&dump, &dump_len) == PM3_SUCCESS) { if (loadFileEML_safe(filename, (void **)&dump, &dump_len) == PM3_SUCCESS) {
restoreLTO(dump, true); restoreLTO(dump, true);
} }
free(dump); free(dump);

View file

@ -3533,7 +3533,7 @@ int CmdHF14AMfELoad(const char *Cmd) {
PrintAndLogEx(WARNING, "Fail, cannot allocate memory"); PrintAndLogEx(WARNING, "Fail, cannot allocate memory");
return PM3_EMALLOC; return PM3_EMALLOC;
} }
size_t datalen = 0; size_t datalen = 0;
//int res = loadFile(filename, ".bin", data, maxdatalen, &datalen); //int res = loadFile(filename, ".bin", data, maxdatalen, &datalen);
int res = loadFileEML(filename, data, &datalen); int res = loadFileEML(filename, data, &datalen);
@ -3552,24 +3552,24 @@ int CmdHF14AMfELoad(const char *Cmd) {
// convert plain or old mfu format to new format // convert plain or old mfu format to new format
if (blockWidth == 4) { if (blockWidth == 4) {
res = convert_mfu_dump_format(&data, &datalen, true); res = convert_mfu_dump_format(&data, &datalen, true);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format"); PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
free(data); free(data);
return res; return res;
} }
mfu_dump_t *mfu_dump = (mfu_dump_t *)data; mfu_dump_t *mfu_dump = (mfu_dump_t *)data;
PrintAndLogEx(INFO, _CYAN_("MFU dump file information")); PrintAndLogEx(INFO, _CYAN_("MFU dump file information"));
PrintAndLogEx(INFO, " version %s", sprint_hex(mfu_dump->version, sizeof(mfu_dump->version))); PrintAndLogEx(INFO, " version %s", sprint_hex(mfu_dump->version, sizeof(mfu_dump->version)));
PrintAndLogEx(INFO, " tb 0 %s", sprint_hex(mfu_dump->tbo, sizeof(mfu_dump->tbo))); PrintAndLogEx(INFO, " tb 0 %s", sprint_hex(mfu_dump->tbo, sizeof(mfu_dump->tbo)));
PrintAndLogEx(INFO, " tb 1 %s", sprint_hex(mfu_dump->tbo1, sizeof(mfu_dump->tbo1))); PrintAndLogEx(INFO, " tb 1 %s", sprint_hex(mfu_dump->tbo1, sizeof(mfu_dump->tbo1)));
for(uint8_t m = 0; m < 3; m++) { for (uint8_t m = 0; m < 3; m++) {
PrintAndLogEx(INFO, " counter %d %s - tearing 0x%02x", m + 1, sprint_hex(mfu_dump->counter_tearing[m], 3), mfu_dump->counter_tearing[m][3]); PrintAndLogEx(INFO, " counter %d %s - tearing 0x%02x", m + 1, sprint_hex(mfu_dump->counter_tearing[m], 3), mfu_dump->counter_tearing[m][3]);
} }
PrintAndLogEx(INFO, " signature %s", sprint_hex(mfu_dump->signature, sizeof(mfu_dump->signature))); PrintAndLogEx(INFO, " signature %s", sprint_hex(mfu_dump->signature, sizeof(mfu_dump->signature)));
PrintAndLogEx(INFO, " data %s... (only first 8 bytes showing)", sprint_hex(mfu_dump->data, 8)); PrintAndLogEx(INFO, " data %s... (only first 8 bytes showing)", sprint_hex(mfu_dump->data, 8));
PrintAndLogEx(INFO, " max data page %d, data len %d bytes", mfu_dump->pages, (mfu_dump->pages + 1) * 4); PrintAndLogEx(INFO, " max data page %d, data len %d bytes", mfu_dump->pages, (mfu_dump->pages + 1) * 4);
PrintAndLogEx(INFO, " file header size %d", MFU_DUMP_PREFIX_LENGTH); PrintAndLogEx(INFO, " file header size %d", MFU_DUMP_PREFIX_LENGTH);
PrintAndLogEx(INFO, "----------------------------------------------"); PrintAndLogEx(INFO, "----------------------------------------------");

View file

@ -3577,9 +3577,9 @@ static int CmdHF14ADesAuth(const char *Cmd) {
} }
static void DesFill2bPattern( static void DesFill2bPattern(
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t *deskeyListLen, uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t *deskeyListLen,
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t *aeskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t *aeskeyListLen,
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t *k3kkeyListLen, uint32_t *startPattern) { uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t *k3kkeyListLen, uint32_t *startPattern) {
for (uint32_t pt = *startPattern; pt < 0x10000; pt++) { for (uint32_t pt = *startPattern; pt < 0x10000; pt++) {
if (*deskeyListLen != MAX_KEYS_LIST_LEN) { if (*deskeyListLen != MAX_KEYS_LIST_LEN) {
@ -3618,10 +3618,10 @@ static void DesFill2bPattern(
} }
static int AuthCheckDesfire(uint8_t *aid, static int AuthCheckDesfire(uint8_t *aid,
uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t deskeyListLen, uint8_t deskeyList[MAX_KEYS_LIST_LEN][8], uint32_t deskeyListLen,
uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t aeskeyListLen, uint8_t aeskeyList[MAX_KEYS_LIST_LEN][16], uint32_t aeskeyListLen,
uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t k3kkeyListLen, uint8_t k3kkeyList[MAX_KEYS_LIST_LEN][24], uint32_t k3kkeyListLen,
uint8_t foundKeys[4][0xE][24 + 1], bool *result) { uint8_t foundKeys[4][0xE][24 + 1], bool *result) {
uint32_t curaid = (aid[0] & 0xFF) + ((aid[1] & 0xFF) << 8) + ((aid[2] & 0xFF) << 16); uint32_t curaid = (aid[0] & 0xFF) + ((aid[1] & 0xFF) << 8) + ((aid[2] & 0xFF) << 16);
@ -4078,17 +4078,17 @@ static int CmdHF14aDesChk(const char *Cmd) {
res = loadFileDICTIONARYEx((char *)dict_filename, deskeyList, sizeof(deskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false); res = loadFileDICTIONARYEx((char *)dict_filename, deskeyList, sizeof(deskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
if (res == PM3_SUCCESS && endFilePosition) if (res == PM3_SUCCESS && endFilePosition)
deskeyListLen = keycnt; deskeyListLen = keycnt;
keycnt = 0; keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, aeskeyList, sizeof(aeskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false); res = loadFileDICTIONARYEx((char *)dict_filename, aeskeyList, sizeof(aeskeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
if (res == PM3_SUCCESS && endFilePosition) if (res == PM3_SUCCESS && endFilePosition)
aeskeyListLen = keycnt; aeskeyListLen = keycnt;
keycnt = 0; keycnt = 0;
res = loadFileDICTIONARYEx((char *)dict_filename, k3kkeyList, sizeof(k3kkeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false); res = loadFileDICTIONARYEx((char *)dict_filename, k3kkeyList, sizeof(k3kkeyList), NULL, 16, &keycnt, endFilePosition, &endFilePosition, false);
if (res == PM3_SUCCESS && endFilePosition) if (res == PM3_SUCCESS && endFilePosition)
k3kkeyListLen = keycnt; k3kkeyListLen = keycnt;
continue; continue;
} }
} }

View file

@ -1055,39 +1055,39 @@ uint32_t GetHF14AMfU_Type(void) {
case 0x0A: { case 0x0A: {
/* /*
MF0UL1001DUx 0004030100000B03 MF0UL1001DUx 0004030100000B03
MF0UL1101DUx 0004030101000B03 MF0UL1101DUx 0004030101000B03
MF0ULH1101DUx 0004030201000B03 MF0ULH1101DUx 0004030201000B03
MF0UL1141DUF 0004030301000B03 MF0UL1141DUF 0004030301000B03
MF0UL2101Dxy 0004030101000E03 MF0UL2101Dxy 0004030101000E03
MF0UL2101DUx 0004030201000E03 MF0UL2101DUx 0004030201000E03
MF0UL3101DUx 0004030101001103 MF0UL3101DUx 0004030101001103
MF0ULH3101DUx 0004030201001103 MF0ULH3101DUx 0004030201001103
MF0UL5101DUx 0004030101001303 MF0UL5101DUx 0004030101001303
NT2L1011F0DUx 0004040101000B03 NT2L1011F0DUx 0004040101000B03
NT2H1011G0DUD 0004040201000B03 NT2H1011G0DUD 0004040201000B03
NT2L1211F0DUx 0004040101000E03 NT2L1211F0DUx 0004040101000E03
NT2H1311G0DUx 0004040201000F03 NT2H1311G0DUx 0004040201000F03
NT2H1311F0Dxy 0004040401000F03 NT2H1311F0Dxy 0004040401000F03
NT2H1411G0DUx 0004040201011103 NT2H1411G0DUx 0004040201011103
NT2H1511G0DUx 0004040201001103 NT2H1511G0DUx 0004040201001103
NT2H1511F0Dxy 0004040401001103 NT2H1511F0Dxy 0004040401001103
NT2H1611G0DUx 0004040201001303 NT2H1611G0DUx 0004040201001303
NT2H1611F0Dxy 0004040401001303 NT2H1611F0Dxy 0004040401001303
NT2H1311C1DTL 0004040201010F03 NT2H1311C1DTL 0004040201010F03
NT2H1311TTDUx 0004040203000F03 NT2H1311TTDUx 0004040203000F03
NT3H1101W0FHK 0004040502001303 NT3H1101W0FHK 0004040502001303
NT3H1201W0FHK 0004040502001503 NT3H1201W0FHK 0004040502001503
NT3H1101W0FHK_Variant 0004040502011303 NT3H1101W0FHK_Variant 0004040502011303
NT3H1201 0004040502011503 NT3H1201 0004040502011503
NT3H2111 0004040502021303 NT3H2111 0004040502021303
NT3H2211 0004040502021503 NT3H2211 0004040502021503
nhs 0004040600001303 nhs 0004040600001303
MF0UN0001DUx 0004030102000B03 MF0UN0001DUx 0004030102000B03
MF0UNH0001DUx 0004030202000B03 MF0UNH0001DUx 0004030202000B03
MF0UN1001DUx 0004030103000B03 MF0UN1001DUx 0004030103000B03
MF0UNH1001DUx 0004030203000B03 MF0UNH1001DUx 0004030203000B03
NT2L1001G0DUx 0004040102000B03 NT2L1001G0DUx 0004040102000B03
NT2H1001G0DUx 0004040202000B03 NT2H1001G0DUx 0004040202000B03
*/ */
if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; } if (memcmp(version, "\x00\x04\x03\x01\x01\x00\x0B", 7) == 0) { tagtype = UL_EV1_48; break; }
@ -2189,7 +2189,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
uint8_t *dump = NULL; uint8_t *dump = NULL;
size_t bytes_read = 0; size_t bytes_read = 0;
if (loadFile_safe(filename, "", (void**)&dump, &bytes_read) != PM3_SUCCESS) { if (loadFile_safe(filename, "", (void **)&dump, &bytes_read) != PM3_SUCCESS) {
PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename); PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename);
return PM3_EIO; return PM3_EIO;
} }
@ -2200,7 +2200,7 @@ static int CmdHF14AMfURestore(const char *Cmd) {
return PM3_ESOFT; return PM3_ESOFT;
} }
int res = convert_mfu_dump_format(&dump, &bytes_read, verbose); int res = convert_mfu_dump_format(&dump, &bytes_read, verbose);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format"); PrintAndLogEx(FAILED, "Failed convert on load to new Ultralight/NTAG format");
free(dump); free(dump);

View file

@ -266,8 +266,8 @@ int demodFDX(void) {
} }
uint8_t bt_par = (extended & 0x100) >> 8; uint8_t bt_par = (extended & 0x100) >> 8;
uint8_t bt_temperature = extended & 0xff; uint8_t bt_temperature = extended & 0xff;
uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1; uint8_t bt_calc_parity = (bitcount(bt_temperature) & 0x1) ? 0 : 1;
uint8_t is_bt_temperature = (bt_calc_parity == bt_par) && !(extended & 0xe00) ; uint8_t is_bt_temperature = (bt_calc_parity == bt_par) && !(extended & 0xe00) ;
if (is_bt_temperature) { if (is_bt_temperature) {

View file

@ -84,7 +84,7 @@ static void set_python_path(char *path) {
} }
if (PySys_SetObject("path", syspath)) { if (PySys_SetObject("path", syspath)) {
PrintAndLogEx(WARNING,"Error setting sys.path object"); PrintAndLogEx(WARNING, "Error setting sys.path object");
} }
} }
@ -300,10 +300,10 @@ static int CmdScriptRun(const char *Cmd) {
wchar_t *py_args[argc]; wchar_t *py_args[argc];
py_args[0] = Py_DecodeLocale(preferredName, NULL); py_args[0] = Py_DecodeLocale(preferredName, NULL);
for (int i = 0; i < argc; i++) { for (int i = 0; i < argc; i++) {
py_args[i+1] = Py_DecodeLocale(argv[i], NULL); py_args[i + 1] = Py_DecodeLocale(argv[i], NULL);
} }
PySys_SetArgv(argc+1, py_args); PySys_SetArgv(argc + 1, py_args);
// clean up // clean up
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {

View file

@ -509,11 +509,11 @@ static int CmdSmartRaw(const char *Cmd) {
TLVPrintFromBuffer(buf, len - 2); TLVPrintFromBuffer(buf, len - 2);
else { else {
if (len > 16) { if (len > 16) {
for (int i=0; i<len; i += 16) { for (int i = 0; i < len; i += 16) {
PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf + i, 16)) ; PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf + i, 16)) ;
} }
} else { } else {
PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf, len)) ; PrintAndLogEx(SUCCESS, "%s", sprint_hex_ascii(buf, len)) ;
} }
} }
@ -577,7 +577,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
// load firmware file // load firmware file
size_t firmware_size = 0; size_t firmware_size = 0;
uint8_t *firmware = NULL; uint8_t *firmware = NULL;
if (loadFile_safe(filename, "", (void**)&firmware, &firmware_size) != PM3_SUCCESS) { if (loadFile_safe(filename, "", (void **)&firmware, &firmware_size) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Firmware file " _YELLOW_("%s") " not found or locked.", filename); PrintAndLogEx(FAILED, "Firmware file " _YELLOW_("%s") " not found or locked.", filename);
return PM3_EFILE; return PM3_EFILE;
} }
@ -585,7 +585,7 @@ static int CmdSmartUpgrade(const char *Cmd) {
// load sha512 file // load sha512 file
size_t sha512_size = 0; size_t sha512_size = 0;
char *hashstring = NULL; char *hashstring = NULL;
if (loadFile_safe(sha512filename, "", (void**)&hashstring, &sha512_size) != PM3_SUCCESS) { if (loadFile_safe(sha512filename, "", (void **)&hashstring, &sha512_size) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "SHA-512 file not found or locked."); PrintAndLogEx(FAILED, "SHA-512 file not found or locked.");
free(firmware); free(firmware);
return PM3_EFILE; return PM3_EFILE;

View file

@ -95,7 +95,7 @@ static bool merge_topaz_reader_frames(uint32_t timestamp, uint32_t *duration, ui
while (!is_last_record(*tracepos, traceLen) && !next_record_is_response(*tracepos, trace)) { while (!is_last_record(*tracepos, traceLen) && !next_record_is_response(*tracepos, trace)) {
tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + *tracepos); tracelog_hdr_t *hdr = (tracelog_hdr_t *)(trace + *tracepos);
*tracepos += TRACELOG_HDR_LEN + hdr->data_len; *tracepos += TRACELOG_HDR_LEN + hdr->data_len;
if ((hdr->data_len == 1) && (*data_len + hdr->data_len <= MAX_TOPAZ_READER_CMD_LEN)) { if ((hdr->data_len == 1) && (*data_len + hdr->data_len <= MAX_TOPAZ_READER_CMD_LEN)) {
@ -153,7 +153,7 @@ static uint16_t printHexLine(uint16_t tracepos, uint16_t traceLen, uint8_t *trac
char data_len_str[5]; char data_len_str[5];
char temp_str1[3] = {0}; char temp_str1[3] = {0};
char temp_str2[3] = {0}; char temp_str2[3] = {0};
sprintf(data_len_str, "%04x", hdr->data_len); sprintf(data_len_str, "%04x", hdr->data_len);
strncat(temp_str1, data_len_str, 2); strncat(temp_str1, data_len_str, 2);
temp_str1[2] = '\0'; temp_str1[2] = '\0';
@ -257,10 +257,10 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
//1 CRC-command, CRC ok //1 CRC-command, CRC ok
//2 Not crc-command //2 Not crc-command
//--- Draw the data column //--- Draw the data column
char line[18][120] = {{0}}; char line[18][120] = {{0}};
if (data_len == 0) { if (data_len == 0) {
sprintf(line[0], "<empty trace - possible error>"); sprintf(line[0], "<empty trace - possible error>");
return tracepos; return tracepos;
} }
@ -401,9 +401,9 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
if (is_last_record(tracepos, traceLen)) return traceLen; if (is_last_record(tracepos, traceLen)) return traceLen;
if (showWaitCycles && !hdr->isResponse && next_record_is_response(tracepos, trace)) { if (showWaitCycles && !hdr->isResponse && next_record_is_response(tracepos, trace)) {
tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos); tracelog_hdr_t *next_hdr = (tracelog_hdr_t *)(trace + tracepos);
PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d", PrintAndLogEx(NORMAL, " %10u | %10u | %s |fdt (Frame Delay Time): %d",
(EndOfTransmissionTimestamp - first_hdr->timestamp), (EndOfTransmissionTimestamp - first_hdr->timestamp),
(next_hdr->timestamp - first_hdr->timestamp), (next_hdr->timestamp - first_hdr->timestamp),
@ -415,7 +415,7 @@ static uint16_t printTraceLine(uint16_t tracepos, uint16_t traceLen, uint8_t *tr
} }
static int download_trace(void) { static int download_trace(void) {
if (!IfPm3Present()) { if (!IfPm3Present()) {
PrintAndLogEx(FAILED, "You requested a trace upload in offline mode, consider using parameter '1' for working from Tracebuffer"); PrintAndLogEx(FAILED, "You requested a trace upload in offline mode, consider using parameter '1' for working from Tracebuffer");
return PM3_EINVARG; return PM3_EINVARG;
@ -487,23 +487,23 @@ static int CmdTraceLoad(const char *Cmd) {
free(g_trace); free(g_trace);
size_t len = 0; size_t len = 0;
if (loadFile_safe(filename, ".trace", (void**)&g_trace, &len) != PM3_SUCCESS) { if (loadFile_safe(filename, ".trace", (void **)&g_trace, &len) != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "Could not open file " _YELLOW_("%s"), filename); PrintAndLogEx(FAILED, "Could not open file " _YELLOW_("%s"), filename);
return PM3_EIO; return PM3_EIO;
} }
g_traceLen = (long)len; g_traceLen = (long)len;
PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = " _YELLOW_("%lu") " bytes) loaded from " _YELLOW_("%s"), g_traceLen, filename); PrintAndLogEx(SUCCESS, "Recorded Activity (TraceLen = " _YELLOW_("%lu") " bytes) loaded from " _YELLOW_("%s"), g_traceLen, filename);
return PM3_SUCCESS; return PM3_SUCCESS;
} }
static int CmdTraceSave(const char *Cmd) { static int CmdTraceSave(const char *Cmd) {
if (g_traceLen == 0) { if (g_traceLen == 0) {
download_trace(); download_trace();
} }
if (g_traceLen == 0) { if (g_traceLen == 0) {
PrintAndLogEx(WARNING, "trace is empty, nothing to save"); PrintAndLogEx(WARNING, "trace is empty, nothing to save");
return PM3_SUCCESS; return PM3_SUCCESS;

View file

@ -1380,7 +1380,7 @@ static int CmdEMVScan(const char *Cmd) {
uint8_t buf[APDU_RES_LEN] = {0}; uint8_t buf[APDU_RES_LEN] = {0};
size_t len = 0; size_t len = 0;
uint8_t ODAI_list[4096]; uint8_t ODAI_list[4096];
size_t ODAI_listlen = 0; size_t ODAI_listlen = 0;
uint16_t sw = 0; uint16_t sw = 0;
int res; int res;
json_t *root; json_t *root;
@ -1683,24 +1683,24 @@ static int CmdEMVScan(const char *Cmd) {
} }
// Build Input list for Offline Data Authentication // Build Input list for Offline Data Authentication
// EMV 4.3 book3 10.3, page 96 // EMV 4.3 book3 10.3, page 96
if (first_time && SFIoffline) { if (first_time && SFIoffline) {
if (SFI < 11) { if (SFI < 11) {
const unsigned char *abuf = buf; const unsigned char *abuf = buf;
size_t elmlen = len; size_t elmlen = len;
struct tlv e; struct tlv e;
if (tlv_parse_tl(&abuf, &elmlen, &e)) { if (tlv_parse_tl(&abuf, &elmlen, &e)) {
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen); memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
ODAI_listlen += elmlen; ODAI_listlen += elmlen;
} else { } else {
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI); PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
} }
} else { } else {
memcpy(ODAI_list + ODAI_listlen, buf, len); memcpy(ODAI_list + ODAI_listlen, buf, len);
ODAI_listlen += len; ODAI_listlen += len;
} }
first_time = false; first_time = false;
} }
if (decodeTLV) { if (decodeTLV) {
TLVPrintFromBuffer(buf, len); TLVPrintFromBuffer(buf, len);
@ -1720,18 +1720,18 @@ static int CmdEMVScan(const char *Cmd) {
else else
JsonSaveTLVTreeElm(jsonelm, "$.Data", rsfi, true, true, false); JsonSaveTLVTreeElm(jsonelm, "$.Data", rsfi, true, true, false);
tlvdb_free(rsfi); tlvdb_free(rsfi);
} }
} }
break; break;
} }
// copy Input list for Offline Data Authentication // copy Input list for Offline Data Authentication
if (ODAI_listlen) { if (ODAI_listlen) {
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
tlvdb_add(tlvRoot, oda); tlvdb_add(tlvRoot, oda);
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen); PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
} }
// getting certificates // getting certificates
if (tlvdb_get(tlvRoot, 0x90, NULL)) { if (tlvdb_get(tlvRoot, 0x90, NULL)) {
@ -1791,7 +1791,7 @@ static int CmdEMVRoca(const char *Cmd) {
size_t len = 0; size_t len = 0;
uint16_t sw = 0; uint16_t sw = 0;
uint8_t ODAI_list[4096]; uint8_t ODAI_list[4096];
size_t ODAI_listlen = 0; size_t ODAI_listlen = 0;
int res; int res;
CLIParserContext *ctx; CLIParserContext *ctx;
@ -1955,26 +1955,26 @@ static int CmdEMVRoca(const char *Cmd) {
PrintAndLogEx(ERR, "SFI[%02x]. APDU error %4x", SFI, sw); PrintAndLogEx(ERR, "SFI[%02x]. APDU error %4x", SFI, sw);
continue; continue;
} }
// Build Input list for Offline Data Authentication // Build Input list for Offline Data Authentication
// EMV 4.3 book3 10.3, page 96 // EMV 4.3 book3 10.3, page 96
if (SFIoffline > 0) { if (SFIoffline > 0) {
if (SFI < 11) { if (SFI < 11) {
const unsigned char *abuf = buf; const unsigned char *abuf = buf;
size_t elmlen = len; size_t elmlen = len;
struct tlv e; struct tlv e;
if (tlv_parse_tl(&abuf, &elmlen, &e)) { if (tlv_parse_tl(&abuf, &elmlen, &e)) {
memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen); memcpy(ODAI_list + ODAI_listlen, &buf[len - elmlen], elmlen);
ODAI_listlen += elmlen; ODAI_listlen += elmlen;
} else { } else {
PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI); PrintAndLogEx(WARNING, "Error SFI[%02x]. Creating input list for Offline Data Authentication error", SFI);
} }
} else { } else {
memcpy(ODAI_list + ODAI_listlen, buf, len); memcpy(ODAI_list + ODAI_listlen, buf, len);
ODAI_listlen += len; ODAI_listlen += len;
} }
SFIoffline--; SFIoffline--;
} }
} }
} }
break; break;
@ -1982,14 +1982,14 @@ static int CmdEMVRoca(const char *Cmd) {
// getting certificates // getting certificates
int ret = PM3_SUCCESS; int ret = PM3_SUCCESS;
// copy Input list for Offline Data Authentication // copy Input list for Offline Data Authentication
if (ODAI_listlen) { if (ODAI_listlen) {
struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag struct tlvdb *oda = tlvdb_fixed(0x21, ODAI_listlen, ODAI_list); // not a standard tag
tlvdb_add(tlvRoot, oda); tlvdb_add(tlvRoot, oda);
PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen); PrintAndLogEx(INFO, "Input list for Offline Data Authentication added to TLV [%zu bytes]", ODAI_listlen);
} }
if (tlvdb_get(tlvRoot, 0x90, NULL)) { if (tlvdb_get(tlvRoot, 0x90, NULL)) {
PrintAndLogEx(INFO, "Recovering certificates"); PrintAndLogEx(INFO, "Recovering certificates");
PKISetStrictExecution(false); PKISetStrictExecution(false);
@ -2025,7 +2025,7 @@ static int CmdEMVRoca(const char *Cmd) {
ret = PM3_ESOFT; ret = PM3_ESOFT;
goto out; goto out;
} }
PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(icc_pk->rid, 5), sprint_hex(icc_pk->rid, 5),
icc_pk->index, icc_pk->index,

View file

@ -309,7 +309,7 @@ static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool Lea
res = 1; res = 1;
if (IfPm3Smartcard()) if (IfPm3Smartcard())
res = ExchangeAPDUSC(true, data, datalen, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen); res = ExchangeAPDUSC(true, data, datalen, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
if (res) { if (res) {
return res; return res;
} }
@ -677,12 +677,12 @@ int trSDA(struct tlvdb *tlv) {
PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting"); PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting");
return 2; return 2;
} }
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(issuer_pk->rid, 5), sprint_hex(issuer_pk->rid, 5),
issuer_pk->index, issuer_pk->index,
sprint_hex(issuer_pk->serial, 3) sprint_hex(issuer_pk->serial, 3)
); );
const struct tlv *sda_tlv = tlvdb_get(tlv, 0x21, NULL); const struct tlv *sda_tlv = tlvdb_get(tlv, 0x21, NULL);
if (!sda_tlv || sda_tlv->len < 1) { if (!sda_tlv || sda_tlv->len < 1) {
@ -736,12 +736,12 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting"); PrintAndLogEx(ERR, "Error: Issuer certificate not found, exiting");
return 2; return 2;
} }
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(issuer_pk->rid, 5), sprint_hex(issuer_pk->rid, 5),
issuer_pk->index, issuer_pk->index,
sprint_hex(issuer_pk->serial, 3) sprint_hex(issuer_pk->serial, 3)
); );
struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv); struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv);
if (!icc_pk) { if (!icc_pk) {
@ -765,7 +765,7 @@ int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
PrintAndLogEx(SUCCESS, "ICC PE Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "ICC PE Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(icc_pe_pk->rid, 5), sprint_hex(icc_pe_pk->rid, 5),
icc_pe_pk->index, icc_pe_pk->index,
sprint_hex(icc_pe_pk->serial,3) sprint_hex(icc_pe_pk->serial, 3)
); );
} }
} else { } else {
@ -943,12 +943,12 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
emv_pk_free(pk); emv_pk_free(pk);
return 2; return 2;
} }
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(issuer_pk->rid, 5), sprint_hex(issuer_pk->rid, 5),
issuer_pk->index, issuer_pk->index,
sprint_hex(issuer_pk->serial, 3) sprint_hex(issuer_pk->serial, 3)
); );
struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv); struct emv_pk *icc_pk = emv_pki_recover_icc_cert(issuer_pk, tlv, sda_tlv);
if (!icc_pk) { if (!icc_pk) {
@ -961,7 +961,7 @@ int trCDA(struct tlvdb *tlv, struct tlvdb *ac_tlv, struct tlv *pdol_data_tlv, st
PrintAndLogEx(SUCCESS, "ICC Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "ICC Public key recovered. RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(icc_pk->rid, 5), sprint_hex(icc_pk->rid, 5),
icc_pk->index, icc_pk->index,
sprint_hex(icc_pk->serial,3) sprint_hex(icc_pk->serial, 3)
); );
struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv); struct tlvdb *dac_db = emv_pki_recover_dac(issuer_pk, tlv, sda_tlv);
@ -1013,10 +1013,10 @@ int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root) {
} }
PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "Issuer Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(issuer_pk->rid, 5), sprint_hex(issuer_pk->rid, 5),
issuer_pk->index, issuer_pk->index,
sprint_hex(issuer_pk->serial, 3) sprint_hex(issuer_pk->serial, 3)
); );
JsonSaveBufAsHex(root, "$.ApplicationData.RID", issuer_pk->rid, 5); JsonSaveBufAsHex(root, "$.ApplicationData.RID", issuer_pk->rid, 5);
@ -1033,12 +1033,12 @@ int RecoveryCertificates(struct tlvdb *tlvRoot, json_t *root) {
PrintAndLogEx(WARNING, "WARNING: ICC certificate not found, exiting"); PrintAndLogEx(WARNING, "WARNING: ICC certificate not found, exiting");
return 2; return 2;
} }
PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"), PrintAndLogEx(SUCCESS, "ICC Public key recovered RID " _YELLOW_("%s") " IDX " _YELLOW_("%02hhx") " CSN " _YELLOW_("%s"),
sprint_hex(icc_pk->rid, 5), sprint_hex(icc_pk->rid, 5),
icc_pk->index, icc_pk->index,
sprint_hex(icc_pk->serial, 3) sprint_hex(icc_pk->serial, 3)
); );
char *icc_pk_c = emv_pk_dump_pk(icc_pk); char *icc_pk_c = emv_pk_dump_pk(icc_pk);
JsonSaveStr(root, "$.ApplicationData.ICCPublicKeyDec", icc_pk_c); JsonSaveStr(root, "$.ApplicationData.ICCPublicKeyDec", icc_pk_c);

View file

@ -219,7 +219,7 @@ static int sda_test_pk(bool verbose) {
struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db); struct emv_pk *ipk = emv_pki_recover_issuer_cert(pk, db);
if (!ipk) { if (!ipk) {
PrintAndLogEx(WARNING, "Could not recover Issuer certificate!"); PrintAndLogEx(WARNING, "Could not recover Issuer certificate!");
tlvdb_free(db); tlvdb_free(db);
return 2; return 2;
} }
@ -269,4 +269,4 @@ int exec_sda_test(bool verbose) {
} }
PrintAndLogEx(SUCCESS, "SDA test pk: %s", _GREEN_("passed")); PrintAndLogEx(SUCCESS, "SDA test pk: %s", _GREEN_("passed"));
return 0; return 0;
} }

View file

@ -832,7 +832,7 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
continue; continue;
strcleanrn(line, sizeof(line)); strcleanrn(line, sizeof(line));
int res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen); int res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen);
if (res == 0) { if (res == 0) {
memcpy(udata + counter, buf, hexlen); memcpy(udata + counter, buf, hexlen);
@ -884,7 +884,7 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) {
fclose(f); fclose(f);
return PM3_EMALLOC; return PM3_EMALLOC;
} }
// 128 + 2 newline chars + 1 null terminator // 128 + 2 newline chars + 1 null terminator
char line[131]; char line[131];
memset(line, 0, sizeof(line)); memset(line, 0, sizeof(line));
@ -911,10 +911,10 @@ int loadFileEML_safe(const char *preferredName, void **pdata, size_t *datalen) {
continue; continue;
strcleanrn(line, sizeof(line)); strcleanrn(line, sizeof(line));
res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen); res = param_gethex_to_eol(line, 0, buf, sizeof(buf), &hexlen);
if (res == 0) { if (res == 0) {
memcpy( tmp + counter, buf, hexlen); memcpy(tmp + counter, buf, hexlen);
counter += hexlen; counter += hexlen;
} else { } else {
retval = PM3_ESOFT; retval = PM3_ESOFT;
@ -1286,11 +1286,11 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
mfu_df_e retval = MFU_DF_UNKNOWN; mfu_df_e retval = MFU_DF_UNKNOWN;
uint8_t bcc0, bcc1; uint8_t bcc0, bcc1;
uint8_t ct = 0x88; uint8_t ct = 0x88;
// detect new // detect new
mfu_dump_t *new = (mfu_dump_t *)*dump; mfu_dump_t *new = (mfu_dump_t *)*dump;
bcc0 = ct ^ new->data[0] ^ new->data[1] ^ new->data[2]; bcc0 = ct ^ new->data[0] ^ new->data[1] ^ new->data[2];
bcc1 = new->data[4] ^ new->data[5] ^ new->data[6] ^ new->data[7]; bcc1 = new->data[4] ^ new->data[5] ^ new->data[6] ^ new->data[7];
if (bcc0 == new->data[3] && bcc1 == new->data[8]) { if (bcc0 == new->data[3] && bcc1 == new->data[8]) {
retval = MFU_DF_NEWBIN; retval = MFU_DF_NEWBIN;
} }
@ -1316,8 +1316,8 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
} }
if (verbose) { if (verbose) {
switch(retval) { switch (retval) {
case MFU_DF_NEWBIN: case MFU_DF_NEWBIN:
PrintAndLogEx(INFO, "detected " _GREEN_("new") " mfu dump format"); PrintAndLogEx(INFO, "detected " _GREEN_("new") " mfu dump format");
break; break;
case MFU_DF_OLDBIN: case MFU_DF_OLDBIN:
@ -1335,8 +1335,8 @@ mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
} }
static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) { static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
mfu_dump_t *mfu = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t)); mfu_dump_t *mfu = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t));
if (mfu == NULL) { if (mfu == NULL) {
return PM3_EMALLOC; return PM3_EMALLOC;
} }
@ -1344,11 +1344,11 @@ static int convert_plain_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose)
memcpy(mfu->data, *dump, *dumplen); memcpy(mfu->data, *dump, *dumplen);
mfu->pages = *dumplen / 4 - 1; mfu->pages = *dumplen / 4 - 1;
if (verbose) { if (verbose) {
PrintAndLogEx(SUCCESS, "plain mfu dump format was converted to " _GREEN_("%d") " blocks", mfu->pages + 1); PrintAndLogEx(SUCCESS, "plain mfu dump format was converted to " _GREEN_("%d") " blocks", mfu->pages + 1);
} }
*dump = (uint8_t *)mfu; *dump = (uint8_t *)mfu;
*dumplen += MFU_DUMP_PREFIX_LENGTH ; *dumplen += MFU_DUMP_PREFIX_LENGTH ;
return PM3_SUCCESS; return PM3_SUCCESS;
@ -1361,8 +1361,8 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
size_t old_data_len = *dumplen - OLD_MFU_DUMP_PREFIX_LENGTH; size_t old_data_len = *dumplen - OLD_MFU_DUMP_PREFIX_LENGTH;
size_t new_dump_len = old_data_len + MFU_DUMP_PREFIX_LENGTH; size_t new_dump_len = old_data_len + MFU_DUMP_PREFIX_LENGTH;
mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc( sizeof(mfu_dump_t), sizeof(uint8_t)); mfu_dump_t *mfu_dump = (mfu_dump_t *) calloc(sizeof(mfu_dump_t), sizeof(uint8_t));
if (mfu_dump == NULL) { if (mfu_dump == NULL) {
return PM3_EMALLOC; return PM3_EMALLOC;
} }
@ -1370,7 +1370,7 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
memcpy(mfu_dump->version, old_mfu_dump->version, sizeof(mfu_dump->version)); memcpy(mfu_dump->version, old_mfu_dump->version, sizeof(mfu_dump->version));
memcpy(mfu_dump->tbo, old_mfu_dump->tbo, sizeof(mfu_dump->tbo)); memcpy(mfu_dump->tbo, old_mfu_dump->tbo, sizeof(mfu_dump->tbo));
memcpy(mfu_dump->signature, old_mfu_dump->signature, sizeof(mfu_dump->signature)); memcpy(mfu_dump->signature, old_mfu_dump->signature, sizeof(mfu_dump->signature));
mfu_dump->tbo1[0] = old_mfu_dump->tbo1[0]; mfu_dump->tbo1[0] = old_mfu_dump->tbo1[0];
for (int i = 0; i < 3; i++) { for (int i = 0; i < 3; i++) {
@ -1381,7 +1381,7 @@ static int convert_old_mfu_dump(uint8_t **dump, size_t *dumplen, bool verbose) {
mfu_dump->pages = old_data_len / 4 - 1; mfu_dump->pages = old_data_len / 4 - 1;
if (verbose) { if (verbose) {
PrintAndLogEx(SUCCESS, "old mfu dump format was converted to " _GREEN_("%d") " blocks", mfu_dump->pages + 1); PrintAndLogEx(SUCCESS, "old mfu dump format was converted to " _GREEN_("%d") " blocks", mfu_dump->pages + 1);
} }
@ -1396,11 +1396,11 @@ int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose) {
if (!dump || !dumplen || *dumplen < OLD_MFU_DUMP_PREFIX_LENGTH) { if (!dump || !dumplen || *dumplen < OLD_MFU_DUMP_PREFIX_LENGTH) {
return PM3_EINVARG; return PM3_EINVARG;
} }
mfu_df_e res = detect_mfu_dump_format(dump, dumplen, verbose); mfu_df_e res = detect_mfu_dump_format(dump, dumplen, verbose);
switch(res) { switch (res) {
case MFU_DF_NEWBIN: case MFU_DF_NEWBIN:
return PM3_SUCCESS; return PM3_SUCCESS;
case MFU_DF_OLDBIN: case MFU_DF_OLDBIN:
return convert_old_mfu_dump(dump, dumplen, verbose); return convert_old_mfu_dump(dump, dumplen, verbose);

View file

@ -264,7 +264,7 @@ typedef enum {
* @return PM3_SUCCESS for ok, PM3_ESOFT for fails * @return PM3_SUCCESS for ok, PM3_ESOFT for fails
*/ */
int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose); int convert_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose); mfu_df_e detect_mfu_dump_format(uint8_t **dump, size_t *dumplen, bool verbose);
int searchAndList(const char *pm3dir, const char *ext); int searchAndList(const char *pm3dir, const char *ext);
int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent); int searchFile(char **foundpath, const char *pm3dir, const char *searchname, const char *suffix, bool silent);

View file

@ -85,8 +85,8 @@ static void jsonp_error_init(json_error_t *error, const char *source) {
} }
static void jsonp_error_vset(json_error_t *error, int line, int column, static void jsonp_error_vset(json_error_t *error, int line, int column,
size_t position, enum json_error_code code, size_t position, enum json_error_code code,
const char *msg, va_list ap) { const char *msg, va_list ap) {
if (!error) if (!error)
return; return;
@ -105,8 +105,8 @@ static void jsonp_error_vset(json_error_t *error, int line, int column,
} }
static void jsonp_error_set(json_error_t *error, int line, int column, static void jsonp_error_set(json_error_t *error, int line, int column,
size_t position, enum json_error_code code, size_t position, enum json_error_code code,
const char *msg, ...) { const char *msg, ...) {
va_list ap; va_list ap;
va_start(ap, msg); va_start(ap, msg);
jsonp_error_vset(error, line, column, position, code, msg, ap); jsonp_error_vset(error, line, column, position, code, msg, ap);

View file

@ -174,7 +174,7 @@ void printarr_human_readable(const char *title, uint8_t *arr, int len) {
PrintAndLogEx(INFO, "%s", title); PrintAndLogEx(INFO, "%s", title);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
if (i % 16 == 0) { if (i % 16 == 0) {
if (i == 0) if (i == 0)
cx += snprintf(output + cx, outsize - cx, "%02x| ", i); cx += snprintf(output + cx, outsize - cx, "%02x| ", i);
else else
@ -204,9 +204,9 @@ static int testBitStream(void) {
} }
if (memcmp(input, output, sizeof(input)) == 0) { if (memcmp(input, output, sizeof(input)) == 0) {
PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok") ); PrintAndLogEx(SUCCESS, " Bitstream test 1 (%s)", _GREEN_("ok"));
} else { } else {
PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed") ); PrintAndLogEx(FAILED, " Bitstream test 1 (%s)", _RED_("failed"));
uint8_t i; uint8_t i;
for (i = 0 ; i < ARRAYLEN(input) ; i++) { for (i = 0 ; i < ARRAYLEN(input) ; i++) {
PrintAndLogEx(NORMAL, " IN %02x, OUT %02x", input[i], output[i]); PrintAndLogEx(NORMAL, " IN %02x, OUT %02x", input[i], output[i]);
@ -234,9 +234,9 @@ static int testReversedBitstream(void) {
} }
if (memcmp(input, output, sizeof(input)) == 0) { if (memcmp(input, output, sizeof(input)) == 0) {
PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok") ); PrintAndLogEx(SUCCESS, " Bitstream test 2 (%s)", _GREEN_("ok"));
} else { } else {
PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed") ); PrintAndLogEx(FAILED, " Bitstream test 2 (%s)", _RED_("failed"));
uint8_t i; uint8_t i;
for (i = 0 ; i < ARRAYLEN(input) ; i++) { for (i = 0 ; i < ARRAYLEN(input) ; i++) {
PrintAndLogEx(NORMAL, " IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]); PrintAndLogEx(NORMAL, " IN %02x, MIDDLE: %02x, OUT %02x", input[i], reverse[i], output[i]);
@ -251,7 +251,7 @@ int testCipherUtils(void) {
int retval = testBitStream(); int retval = testBitStream();
if (retval == PM3_SUCCESS) if (retval == PM3_SUCCESS)
retval = testReversedBitstream(); retval = testReversedBitstream();
return retval; return retval;
} }
#endif #endif

View file

@ -481,7 +481,7 @@ int calculateMasterKey(uint8_t first16bytes[], uint64_t master_key[]) {
if (memcmp(z_0, result, 4) != 0) { if (memcmp(z_0, result, 4) != 0) {
PrintAndLogEx(WARNING, _RED_("Failed to verify") " calculated master key (k_cus)! Something is wrong."); PrintAndLogEx(WARNING, _RED_("Failed to verify") " calculated master key (k_cus)! Something is wrong.");
return PM3_ESOFT; return PM3_ESOFT;
} }
PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!")); PrintAndLogEx(SUCCESS, _GREEN_("Key verified ok!"));
return PM3_SUCCESS; return PM3_SUCCESS;
@ -501,9 +501,9 @@ int bruteforceDump(uint8_t dump[], size_t dumpsize, uint16_t keytable[]) {
dumpdata *attack = (dumpdata *) calloc(itemsize, sizeof(uint8_t)); dumpdata *attack = (dumpdata *) calloc(itemsize, sizeof(uint8_t));
if (attack == NULL) { if (attack == NULL) {
PrintAndLogEx(WARNING, "failed to allocate memory"); PrintAndLogEx(WARNING, "failed to allocate memory");
return PM3_EMALLOC; return PM3_EMALLOC;
} }
int res = 0; int res = 0;
for (i = 0 ; i * itemsize < dumpsize ; i++) { for (i = 0 ; i * itemsize < dumpsize ; i++) {
memcpy(attack, dump + i * itemsize, itemsize); memcpy(attack, dump + i * itemsize, itemsize);
@ -670,13 +670,13 @@ int testElite(bool slowtests) {
int res = PM3_SUCCESS; int res = PM3_SUCCESS;
PrintAndLogEx(INFO, "Testing hash1..."); PrintAndLogEx(INFO, "Testing hash1...");
res += _testHash1(); res += _testHash1();
PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") ); PrintAndLogEx(INFO, " hash1 (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
PrintAndLogEx(INFO, "Testing key diversification..."); PrintAndLogEx(INFO, "Testing key diversification...");
res += _test_iclass_key_permutation(); res += _test_iclass_key_permutation();
if (res == PM3_SUCCESS) if (res == PM3_SUCCESS)
PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail") ); PrintAndLogEx(INFO, " key diversification (%s)", (res == PM3_SUCCESS) ? _GREEN_("ok") : _RED_("fail"));
if (slowtests) if (slowtests)
res += _testBruteforce(); res += _testBruteforce();

View file

@ -228,13 +228,13 @@ static void printState(const char *desc, uint64_t c) {
return; return;
char s[60] = {0}; char s[60] = {0};
snprintf(s, sizeof(s), "%s : ", desc); snprintf(s, sizeof(s), "%s : ", desc);
uint8_t x = (c & 0xFF00000000000000) >> 56; uint8_t x = (c & 0xFF00000000000000) >> 56;
uint8_t y = (c & 0x00FF000000000000) >> 48; uint8_t y = (c & 0x00FF000000000000) >> 48;
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x %02x", x, y); snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x %02x", x, y);
for (uint8_t i = 0; i < 8; i++) for (uint8_t i = 0; i < 8; i++)
snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x", getSixBitByte(c, i)); snprintf(s + strlen(s), sizeof(s) - strlen(s), " %02x", getSixBitByte(c, i));
PrintAndLogEx(DEBUG, "%s", s); PrintAndLogEx(DEBUG, "%s", s);
@ -353,7 +353,7 @@ void hash0(uint64_t c, uint8_t k[8]) {
* @param key * @param key
* @param div_key * @param div_key
*/ */
void diversifyKey(uint8_t* csn, uint8_t* key, uint8_t* div_key) { void diversifyKey(uint8_t *csn, uint8_t *key, uint8_t *div_key) {
// Prepare the DES key // Prepare the DES key
mbedtls_des_setkey_enc(&ctx_enc, key); mbedtls_des_setkey_enc(&ctx_enc, key);
@ -581,7 +581,7 @@ static int testCryptedCSN(uint64_t crypted_csn, uint64_t expected) {
PrintAndLogEx(DEBUG, ""); PrintAndLogEx(DEBUG, "");
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypted_csn); PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypted_csn);
PrintAndLogEx(DEBUG, " {csn-revz} %"PRIx64, crypted_csn_swapped); PrintAndLogEx(DEBUG, " {csn-revz} %"PRIx64, crypted_csn_swapped);
PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL") ); PrintAndLogEx(DEBUG, " hash0 %"PRIx64 " (%s)", resultbyte, (resultbyte == expected) ? _GREEN_("OK") : _RED_("FAIL"));
if (resultbyte != expected) { if (resultbyte != expected) {
PrintAndLogEx(DEBUG, " expected " _YELLOW_("%"PRIx64), expected); PrintAndLogEx(DEBUG, " expected " _YELLOW_("%"PRIx64), expected);
@ -602,7 +602,7 @@ static int testDES2(uint64_t csn, uint64_t expected) {
uint64_t crypt_csn = x_bytes_to_num(result, 8); uint64_t crypt_csn = x_bytes_to_num(result, 8);
PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypt_csn); PrintAndLogEx(DEBUG, " {csn} %"PRIx64, crypt_csn);
PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL") ); PrintAndLogEx(DEBUG, " expected %"PRIx64 " (%s)", expected, (expected == crypt_csn) ? _GREEN_("OK") : _RED_("FAIL"));
if (expected != crypt_csn) if (expected != crypt_csn)
return PM3_ESOFT; return PM3_ESOFT;
@ -635,7 +635,7 @@ static int doTestsWithKnownInputs(void) {
res += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea); res += testCryptedCSN(0x21ba6565071f9299, 0x34e80f88d5cf39ea);
res += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3); res += testCryptedCSN(0x14e2adfc5bb7e134, 0x6ac90c6508bd9ea3);
if (res != PM3_SUCCESS) { if (res != PM3_SUCCESS) {
PrintAndLogEx(FAILED, "%d res occurred (9 testcases)", res); PrintAndLogEx(FAILED, "%d res occurred (9 testcases)", res);
res = PM3_ESOFT; res = PM3_ESOFT;
} else { } else {

View file

@ -912,7 +912,7 @@ static int CmdPrefShow(const char *Cmd) {
char *fn = prefGetFilename(); char *fn = prefGetFilename();
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(INFO, _CYAN_("Preferences loaded from " _YELLOW_("%s")), fn); PrintAndLogEx(INFO, _CYAN_("Preferences loaded from " _YELLOW_("%s")), fn);
free(fn); free(fn);
} else { } else {
PrintAndLogEx(ERR, "Preferences not loaded"); PrintAndLogEx(ERR, "Preferences not loaded");
return PM3_ESOFT; return PM3_ESOFT;

File diff suppressed because it is too large Load diff

View file

@ -109,8 +109,8 @@ extern "C" {
#define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str) #define LZ4_EXPAND_AND_QUOTE(str) LZ4_QUOTE(str)
#define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION) #define LZ4_VERSION_STRING LZ4_EXPAND_AND_QUOTE(LZ4_LIB_VERSION)
LZ4LIB_API int LZ4_versionNumber (void); /**< library version number; useful to check dll version */ LZ4LIB_API int LZ4_versionNumber(void); /**< library version number; useful to check dll version */
LZ4LIB_API const char* LZ4_versionString (void); /**< library version string; useful to check dll version */ LZ4LIB_API const char *LZ4_versionString(void); /**< library version string; useful to check dll version */
/*-************************************ /*-************************************
@ -145,7 +145,7 @@ LZ4LIB_API const char* LZ4_versionString (void); /**< library version string;
* or 0 if compression fails * or 0 if compression fails
* Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer). * Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
*/ */
LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity); LZ4LIB_API int LZ4_compress_default(const char *src, char *dst, int srcSize, int dstCapacity);
/*! LZ4_decompress_safe() : /*! LZ4_decompress_safe() :
* compressedSize : is the exact complete size of the compressed block. * compressedSize : is the exact complete size of the compressed block.
@ -161,7 +161,7 @@ LZ4LIB_API int LZ4_compress_default(const char* src, char* dst, int srcSize, int
* The implementation is free to send / store / derive this information in whichever way is most beneficial. * The implementation is free to send / store / derive this information in whichever way is most beneficial.
* If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead. * If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
*/ */
LZ4LIB_API int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity); LZ4LIB_API int LZ4_decompress_safe(const char *src, char *dst, int compressedSize, int dstCapacity);
/*-************************************ /*-************************************
@ -188,7 +188,7 @@ LZ4LIB_API int LZ4_compressBound(int inputSize);
An acceleration value of "1" is the same as regular LZ4_compress_default() An acceleration value of "1" is the same as regular LZ4_compress_default()
Values <= 0 will be replaced by ACCELERATION_DEFAULT (currently == 1, see lz4.c). Values <= 0 will be replaced by ACCELERATION_DEFAULT (currently == 1, see lz4.c).
*/ */
LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); LZ4LIB_API int LZ4_compress_fast(const char *src, char *dst, int srcSize, int dstCapacity, int acceleration);
/*! LZ4_compress_fast_extState() : /*! LZ4_compress_fast_extState() :
@ -198,7 +198,7 @@ LZ4LIB_API int LZ4_compress_fast (const char* src, char* dst, int srcSize, int d
* Then, provide this buffer as `void* state` to compression function. * Then, provide this buffer as `void* state` to compression function.
*/ */
LZ4LIB_API int LZ4_sizeofState(void); LZ4LIB_API int LZ4_sizeofState(void);
LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); LZ4LIB_API int LZ4_compress_fast_extState(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration);
/*! LZ4_compress_destSize() : /*! LZ4_compress_destSize() :
@ -213,7 +213,7 @@ LZ4LIB_API int LZ4_compress_fast_extState (void* state, const char* src, char* d
* @return : Nb bytes written into 'dst' (necessarily <= targetDestSize) * @return : Nb bytes written into 'dst' (necessarily <= targetDestSize)
* or 0 if compression fails. * or 0 if compression fails.
*/ */
LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePtr, int targetDstSize); LZ4LIB_API int LZ4_compress_destSize(const char *src, char *dst, int *srcSizePtr, int targetDstSize);
/*! LZ4_decompress_safe_partial() : /*! LZ4_decompress_safe_partial() :
@ -240,7 +240,7 @@ LZ4LIB_API int LZ4_compress_destSize (const char* src, char* dst, int* srcSizePt
* This is no longer necessary. * This is no longer necessary.
* The function nonetheless keeps its signature, in an effort to not break API. * The function nonetheless keeps its signature, in an effort to not break API.
*/ */
LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcSize, int targetOutputSize, int dstCapacity); LZ4LIB_API int LZ4_decompress_safe_partial(const char *src, char *dst, int srcSize, int targetOutputSize, int dstCapacity);
/*-********************************************* /*-*********************************************
@ -248,8 +248,8 @@ LZ4LIB_API int LZ4_decompress_safe_partial (const char* src, char* dst, int srcS
***********************************************/ ***********************************************/
typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */ typedef union LZ4_stream_u LZ4_stream_t; /* incomplete type (defined later) */
LZ4LIB_API LZ4_stream_t* LZ4_createStream(void); LZ4LIB_API LZ4_stream_t *LZ4_createStream(void);
LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr); LZ4LIB_API int LZ4_freeStream(LZ4_stream_t *streamPtr);
/*! LZ4_resetStream_fast() : v1.9.0+ /*! LZ4_resetStream_fast() : v1.9.0+
* Use this to prepare an LZ4_stream_t for a new chain of dependent blocks * Use this to prepare an LZ4_stream_t for a new chain of dependent blocks
@ -273,7 +273,7 @@ LZ4LIB_API int LZ4_freeStream (LZ4_stream_t* streamPtr);
* The *extState* functions perform their own resets. * The *extState* functions perform their own resets.
* Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive. * Invoking LZ4_resetStream_fast() before is redundant, and even counterproductive.
*/ */
LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr); LZ4LIB_API void LZ4_resetStream_fast(LZ4_stream_t *streamPtr);
/*! LZ4_loadDict() : /*! LZ4_loadDict() :
* Use this function to reference a static dictionary into LZ4_stream_t. * Use this function to reference a static dictionary into LZ4_stream_t.
@ -286,7 +286,7 @@ LZ4LIB_API void LZ4_resetStream_fast (LZ4_stream_t* streamPtr);
* Loading a size of 0 is allowed, and is the same as reset. * Loading a size of 0 is allowed, and is the same as reset.
* @return : loaded dictionary size, in bytes (necessarily <= 64 KB) * @return : loaded dictionary size, in bytes (necessarily <= 64 KB)
*/ */
LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, int dictSize); LZ4LIB_API int LZ4_loadDict(LZ4_stream_t *streamPtr, const char *dictionary, int dictSize);
/*! LZ4_compress_fast_continue() : /*! LZ4_compress_fast_continue() :
* Compress 'src' content using data from previously compressed blocks, for better compression ratio. * Compress 'src' content using data from previously compressed blocks, for better compression ratio.
@ -311,7 +311,7 @@ LZ4LIB_API int LZ4_loadDict (LZ4_stream_t* streamPtr, const char* dictionary, in
* *
* Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed. * Note 5 : After an error, the stream status is undefined (invalid), it can only be reset or freed.
*/ */
LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); LZ4LIB_API int LZ4_compress_fast_continue(LZ4_stream_t *streamPtr, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration);
/*! LZ4_saveDict() : /*! LZ4_saveDict() :
* If last 64KB data cannot be guaranteed to remain available at its current memory location, * If last 64KB data cannot be guaranteed to remain available at its current memory location,
@ -320,7 +320,7 @@ LZ4LIB_API int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char*
* but is much faster, because LZ4_saveDict() doesn't need to rebuild tables. * but is much faster, because LZ4_saveDict() doesn't need to rebuild tables.
* @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error. * @return : saved dictionary size in bytes (necessarily <= maxDictSize), or 0 if error.
*/ */
LZ4LIB_API int LZ4_saveDict (LZ4_stream_t* streamPtr, char* safeBuffer, int maxDictSize); LZ4LIB_API int LZ4_saveDict(LZ4_stream_t *streamPtr, char *safeBuffer, int maxDictSize);
/*-********************************************** /*-**********************************************
@ -333,8 +333,8 @@ typedef union LZ4_streamDecode_u LZ4_streamDecode_t; /* tracking context */
* creation / destruction of streaming decompression tracking context. * creation / destruction of streaming decompression tracking context.
* A tracking context can be re-used multiple times. * A tracking context can be re-used multiple times.
*/ */
LZ4LIB_API LZ4_streamDecode_t* LZ4_createStreamDecode(void); LZ4LIB_API LZ4_streamDecode_t *LZ4_createStreamDecode(void);
LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_stream); LZ4LIB_API int LZ4_freeStreamDecode(LZ4_streamDecode_t *LZ4_stream);
/*! LZ4_setStreamDecode() : /*! LZ4_setStreamDecode() :
* An LZ4_streamDecode_t context can be allocated once and re-used multiple times. * An LZ4_streamDecode_t context can be allocated once and re-used multiple times.
@ -343,7 +343,7 @@ LZ4LIB_API int LZ4_freeStreamDecode (LZ4_streamDecode_t* LZ4_str
* Dictionary is presumed stable : it must remain accessible and unmodified during next decompression. * Dictionary is presumed stable : it must remain accessible and unmodified during next decompression.
* @return : 1 if OK, 0 if error * @return : 1 if OK, 0 if error
*/ */
LZ4LIB_API int LZ4_setStreamDecode (LZ4_streamDecode_t* LZ4_streamDecode, const char* dictionary, int dictSize); LZ4LIB_API int LZ4_setStreamDecode(LZ4_streamDecode_t *LZ4_streamDecode, const char *dictionary, int dictSize);
/*! LZ4_decoderRingBufferSize() : v1.8.2+ /*! LZ4_decoderRingBufferSize() : v1.8.2+
* Note : in a ring buffer scenario (optional), * Note : in a ring buffer scenario (optional),
@ -384,7 +384,7 @@ LZ4LIB_API int LZ4_decoderRingBufferSize(int maxBlockSize);
* save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression, * save the last 64KB of decoded data into a safe buffer where it can't be modified during decompression,
* then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block. * then indicate where this data is saved using LZ4_setStreamDecode(), before decompressing next block.
*/ */
LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int srcSize, int dstCapacity); LZ4LIB_API int LZ4_decompress_safe_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int srcSize, int dstCapacity);
/*! LZ4_decompress_*_usingDict() : /*! LZ4_decompress_*_usingDict() :
@ -395,7 +395,7 @@ LZ4LIB_API int LZ4_decompress_safe_continue (LZ4_streamDecode_t* LZ4_streamDecod
* Performance tip : Decompression speed can be substantially increased * Performance tip : Decompression speed can be substantially increased
* when dst == dictStart + dictSize. * when dst == dictStart + dictSize.
*/ */
LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int srcSize, int dstCapcity, const char* dictStart, int dictSize); LZ4LIB_API int LZ4_decompress_safe_usingDict(const char *src, char *dst, int srcSize, int dstCapcity, const char *dictStart, int dictSize);
#endif /* LZ4_H_2983827168210 */ #endif /* LZ4_H_2983827168210 */
@ -446,7 +446,7 @@ LZ4LIB_API int LZ4_decompress_safe_usingDict (const char* src, char* dst, int sr
* this function initializes the provided state with a call to something like LZ4_resetStream_fast() * this function initializes the provided state with a call to something like LZ4_resetStream_fast()
* while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream(). * while LZ4_compress_fast_extState() starts with a call to LZ4_resetStream().
*/ */
LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration); LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset(void *state, const char *src, char *dst, int srcSize, int dstCapacity, int acceleration);
/*! LZ4_attach_dictionary() : /*! LZ4_attach_dictionary() :
* This is an experimental API that allows * This is an experimental API that allows
@ -474,7 +474,7 @@ LZ4LIB_STATIC_API int LZ4_compress_fast_extState_fastReset (void* state, const c
* stream (and source buffer) must remain in-place / accessible / unchanged * stream (and source buffer) must remain in-place / accessible / unchanged
* through the completion of the first compression call on the stream. * through the completion of the first compression call on the stream.
*/ */
LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t* workingStream, const LZ4_stream_t* dictionaryStream); LZ4LIB_STATIC_API void LZ4_attach_dictionary(LZ4_stream_t *workingStream, const LZ4_stream_t *dictionaryStream);
/*! In-place compression and decompression /*! In-place compression and decompression
@ -566,15 +566,15 @@ struct LZ4_stream_t_internal {
uint32_t currentOffset; uint32_t currentOffset;
uint16_t dirty; uint16_t dirty;
uint16_t tableType; uint16_t tableType;
const uint8_t* dictionary; const uint8_t *dictionary;
const LZ4_stream_t_internal* dictCtx; const LZ4_stream_t_internal *dictCtx;
uint32_t dictSize; uint32_t dictSize;
}; };
typedef struct { typedef struct {
const uint8_t* externalDict; const uint8_t *externalDict;
size_t extDictSize; size_t extDictSize;
const uint8_t* prefixEnd; const uint8_t *prefixEnd;
size_t prefixSize; size_t prefixSize;
} LZ4_streamDecode_t_internal; } LZ4_streamDecode_t_internal;
@ -586,14 +586,14 @@ struct LZ4_stream_t_internal {
unsigned int currentOffset; unsigned int currentOffset;
unsigned short dirty; unsigned short dirty;
unsigned short tableType; unsigned short tableType;
const unsigned char* dictionary; const unsigned char *dictionary;
const LZ4_stream_t_internal* dictCtx; const LZ4_stream_t_internal *dictCtx;
unsigned int dictSize; unsigned int dictSize;
}; };
typedef struct { typedef struct {
const unsigned char* externalDict; const unsigned char *externalDict;
const unsigned char* prefixEnd; const unsigned char *prefixEnd;
size_t extDictSize; size_t extDictSize;
size_t prefixSize; size_t prefixSize;
} LZ4_streamDecode_t_internal; } LZ4_streamDecode_t_internal;
@ -630,7 +630,7 @@ union LZ4_stream_u {
* Note2: An LZ4_stream_t structure guarantees correct alignment and size. * Note2: An LZ4_stream_t structure guarantees correct alignment and size.
* Note3: Before v1.9.0, use LZ4_resetStream() instead * Note3: Before v1.9.0, use LZ4_resetStream() instead
*/ */
LZ4LIB_API LZ4_stream_t* LZ4_initStream (void* buffer, size_t size); LZ4LIB_API LZ4_stream_t *LZ4_initStream(void *buffer, size_t size);
/*! LZ4_streamDecode_t : /*! LZ4_streamDecode_t :
@ -683,16 +683,16 @@ union LZ4_streamDecode_u {
#endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */ #endif /* LZ4_DISABLE_DEPRECATE_WARNINGS */
/* Obsolete compression functions */ /* Obsolete compression functions */
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress (const char* src, char* dest, int srcSize); LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress(const char *src, char *dest, int srcSize);
LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput (const char* src, char* dest, int srcSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_default() instead") LZ4LIB_API int LZ4_compress_limitedOutput(const char *src, char *dest, int srcSize, int maxOutputSize);
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState (void* state, const char* source, char* dest, int inputSize); LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_withState(void *state, const char *source, char *dest, int inputSize);
LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_fast_extState() instead") LZ4LIB_API int LZ4_compress_limitedOutput_withState(void *state, const char *source, char *dest, int inputSize, int maxOutputSize);
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize); LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize);
LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue (LZ4_stream_t* LZ4_streamPtr, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_fast_continue() instead") LZ4LIB_API int LZ4_compress_limitedOutput_continue(LZ4_stream_t *LZ4_streamPtr, const char *source, char *dest, int inputSize, int maxOutputSize);
/* Obsolete decompression functions */ /* Obsolete decompression functions */
LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress (const char* source, char* dest, int outputSize); LZ4_DEPRECATED("use LZ4_decompress_fast() instead") LZ4LIB_API int LZ4_uncompress(const char *source, char *dest, int outputSize);
LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize (const char* source, char* dest, int isize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompress_unknownOutputSize(const char *source, char *dest, int isize, int maxOutputSize);
/* Obsolete streaming functions; degraded functionality; do not use! /* Obsolete streaming functions; degraded functionality; do not use!
* *
@ -703,14 +703,14 @@ LZ4_DEPRECATED("use LZ4_decompress_safe() instead") LZ4LIB_API int LZ4_uncompres
* achieved will therefore be no better than compressing each chunk * achieved will therefore be no better than compressing each chunk
* independently. * independently.
*/ */
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void* LZ4_create (char* inputBuffer); LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API void *LZ4_create(char *inputBuffer);
LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void); LZ4_DEPRECATED("Use LZ4_createStream() instead") LZ4LIB_API int LZ4_sizeofStreamState(void);
LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void* state, char* inputBuffer); LZ4_DEPRECATED("Use LZ4_resetStream() instead") LZ4LIB_API int LZ4_resetStreamState(void *state, char *inputBuffer);
LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char* LZ4_slideInputBuffer (void* state); LZ4_DEPRECATED("Use LZ4_saveDict() instead") LZ4LIB_API char *LZ4_slideInputBuffer(void *state);
/* Obsolete streaming decoding functions */ /* Obsolete streaming decoding functions */
LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k (const char* src, char* dst, int compressedSize, int maxDstSize); LZ4_DEPRECATED("use LZ4_decompress_safe_usingDict() instead") LZ4LIB_API int LZ4_decompress_safe_withPrefix64k(const char *src, char *dst, int compressedSize, int maxDstSize);
LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k (const char* src, char* dst, int originalSize); LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4_decompress_fast_withPrefix64k(const char *src, char *dst, int originalSize);
/*! LZ4_decompress_fast() : **unsafe!** /*! LZ4_decompress_fast() : **unsafe!**
* These functions used to be faster than LZ4_decompress_safe(), * These functions used to be faster than LZ4_decompress_safe(),
@ -741,11 +741,11 @@ LZ4_DEPRECATED("use LZ4_decompress_fast_usingDict() instead") LZ4LIB_API int LZ4
*/ */
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead") LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe() instead")
LZ4LIB_API int LZ4_decompress_fast (const char* src, char* dst, int originalSize); LZ4LIB_API int LZ4_decompress_fast(const char *src, char *dst, int originalSize);
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead") LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_continue() instead")
LZ4LIB_API int LZ4_decompress_fast_continue (LZ4_streamDecode_t* LZ4_streamDecode, const char* src, char* dst, int originalSize); LZ4LIB_API int LZ4_decompress_fast_continue(LZ4_streamDecode_t *LZ4_streamDecode, const char *src, char *dst, int originalSize);
LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead") LZ4_DEPRECATED("This function is deprecated and unsafe. Consider using LZ4_decompress_safe_usingDict() instead")
LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int originalSize, const char* dictStart, int dictSize); LZ4LIB_API int LZ4_decompress_fast_usingDict(const char *src, char *dst, int originalSize, const char *dictStart, int dictSize);
/*! LZ4_resetStream() : /*! LZ4_resetStream() :
* An LZ4_stream_t structure must be initialized at least once. * An LZ4_stream_t structure must be initialized at least once.
@ -753,7 +753,7 @@ LZ4LIB_API int LZ4_decompress_fast_usingDict (const char* src, char* dst, int or
* Consider switching to LZ4_initStream(), * Consider switching to LZ4_initStream(),
* invoking LZ4_resetStream() will trigger deprecation warnings in the future. * invoking LZ4_resetStream() will trigger deprecation warnings in the future.
*/ */
LZ4LIB_API void LZ4_resetStream (LZ4_stream_t* streamPtr); LZ4LIB_API void LZ4_resetStream(LZ4_stream_t *streamPtr);
#endif /* LZ4_H_98237428734687 */ #endif /* LZ4_H_98237428734687 */

File diff suppressed because it is too large Load diff

View file

@ -63,7 +63,7 @@ extern "C" {
* @return : the number of bytes written into 'dst' * @return : the number of bytes written into 'dst'
* or 0 if compression fails. * or 0 if compression fails.
*/ */
LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dstCapacity, int compressionLevel); LZ4LIB_API int LZ4_compress_HC(const char *src, char *dst, int srcSize, int dstCapacity, int compressionLevel);
/* Note : /* Note :
@ -77,7 +77,7 @@ LZ4LIB_API int LZ4_compress_HC (const char* src, char* dst, int srcSize, int dst
* Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly). * Memory segment must be aligned on 8-bytes boundaries (which a normal malloc() should do properly).
*/ */
LZ4LIB_API int LZ4_sizeofStateHC(void); LZ4LIB_API int LZ4_sizeofStateHC(void);
LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel); LZ4LIB_API int LZ4_compress_HC_extStateHC(void *stateHC, const char *src, char *dst, int srcSize, int maxDstSize, int compressionLevel);
/*! LZ4_compress_HC_destSize() : v1.9.0+ /*! LZ4_compress_HC_destSize() : v1.9.0+
@ -88,9 +88,9 @@ LZ4LIB_API int LZ4_compress_HC_extStateHC(void* stateHC, const char* src, char*
* or 0 if compression fails. * or 0 if compression fails.
* `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src` * `srcSizePtr` : on success, *srcSizePtr is updated to indicate how much bytes were read from `src`
*/ */
LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC, LZ4LIB_API int LZ4_compress_HC_destSize(void *stateHC,
const char* src, char* dst, const char *src, char *dst,
int* srcSizePtr, int targetDstSize, int *srcSizePtr, int targetDstSize,
int compressionLevel); int compressionLevel);
@ -98,7 +98,7 @@ LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
* Streaming Compression * Streaming Compression
* Bufferless synchronous API * Bufferless synchronous API
**************************************/ **************************************/
typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */ typedef union LZ4_streamHC_u LZ4_streamHC_t; /* incomplete type (defined later) */
/*! LZ4_createStreamHC() and LZ4_freeStreamHC() : /*! LZ4_createStreamHC() and LZ4_freeStreamHC() :
* These functions create and release memory for LZ4 HC streaming state. * These functions create and release memory for LZ4 HC streaming state.
@ -106,8 +106,8 @@ LZ4LIB_API int LZ4_compress_HC_destSize(void* stateHC,
* A same state can be used multiple times consecutively, * A same state can be used multiple times consecutively,
* starting with LZ4_resetStreamHC_fast() to start a new stream of blocks. * starting with LZ4_resetStreamHC_fast() to start a new stream of blocks.
*/ */
LZ4LIB_API LZ4_streamHC_t* LZ4_createStreamHC(void); LZ4LIB_API LZ4_streamHC_t *LZ4_createStreamHC(void);
LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr); LZ4LIB_API int LZ4_freeStreamHC(LZ4_streamHC_t *streamHCPtr);
/* /*
These functions compress data in successive blocks of any size, These functions compress data in successive blocks of any size,
@ -152,12 +152,12 @@ LZ4LIB_API int LZ4_freeStreamHC (LZ4_streamHC_t* streamHCPtr);
just by resetting it, using LZ4_resetStreamHC_fast(). just by resetting it, using LZ4_resetStreamHC_fast().
*/ */
LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t* streamHCPtr, int compressionLevel); /* v1.9.0+ */ LZ4LIB_API void LZ4_resetStreamHC_fast(LZ4_streamHC_t *streamHCPtr, int compressionLevel); /* v1.9.0+ */
LZ4LIB_API int LZ4_loadDictHC (LZ4_streamHC_t* streamHCPtr, const char* dictionary, int dictSize); LZ4LIB_API int LZ4_loadDictHC(LZ4_streamHC_t *streamHCPtr, const char *dictionary, int dictSize);
LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr, LZ4LIB_API int LZ4_compress_HC_continue(LZ4_streamHC_t *streamHCPtr,
const char* src, char* dst, const char *src, char *dst,
int srcSize, int maxDstSize); int srcSize, int maxDstSize);
/*! LZ4_compress_HC_continue_destSize() : v1.9.0+ /*! LZ4_compress_HC_continue_destSize() : v1.9.0+
* Similar to LZ4_compress_HC_continue(), * Similar to LZ4_compress_HC_continue(),
@ -169,11 +169,11 @@ LZ4LIB_API int LZ4_compress_HC_continue (LZ4_streamHC_t* streamHCPtr,
* `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`. * `srcSizePtr` : on success, *srcSizePtr will be updated to indicate how much bytes were read from `src`.
* Note that this function may not consume the entire input. * Note that this function may not consume the entire input.
*/ */
LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t* LZ4_streamHCPtr, LZ4LIB_API int LZ4_compress_HC_continue_destSize(LZ4_streamHC_t *LZ4_streamHCPtr,
const char* src, char* dst, const char *src, char *dst,
int* srcSizePtr, int targetDstSize); int *srcSizePtr, int targetDstSize);
LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, int maxDictSize); LZ4LIB_API int LZ4_saveDictHC(LZ4_streamHC_t *streamHCPtr, char *safeBuffer, int maxDictSize);
@ -202,13 +202,12 @@ LZ4LIB_API int LZ4_saveDictHC (LZ4_streamHC_t* streamHCPtr, char* safeBuffer, in
#include <stdint.h> #include <stdint.h>
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal; typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
struct LZ4HC_CCtx_internal struct LZ4HC_CCtx_internal {
{
uint32_t hashTable[LZ4HC_HASHTABLESIZE]; uint32_t hashTable[LZ4HC_HASHTABLESIZE];
uint16_t chainTable[LZ4HC_MAXD]; uint16_t chainTable[LZ4HC_MAXD];
const uint8_t* end; /* next block here to continue on current prefix */ const uint8_t *end; /* next block here to continue on current prefix */
const uint8_t* base; /* All index relative to this position */ const uint8_t *base; /* All index relative to this position */
const uint8_t* dictBase; /* alternate base for extDict */ const uint8_t *dictBase; /* alternate base for extDict */
uint32_t dictLimit; /* below that point, need extDict */ uint32_t dictLimit; /* below that point, need extDict */
uint32_t lowLimit; /* below that point, no more dict */ uint32_t lowLimit; /* below that point, no more dict */
uint32_t nextToUpdate; /* index from which to continue dictionary update */ uint32_t nextToUpdate; /* index from which to continue dictionary update */
@ -216,19 +215,18 @@ struct LZ4HC_CCtx_internal
int8_t favorDecSpeed; /* favor decompression speed if this flag set, int8_t favorDecSpeed; /* favor decompression speed if this flag set,
otherwise, favor compression ratio */ otherwise, favor compression ratio */
int8_t dirty; /* stream has to be fully reset if this flag is set */ int8_t dirty; /* stream has to be fully reset if this flag is set */
const LZ4HC_CCtx_internal* dictCtx; const LZ4HC_CCtx_internal *dictCtx;
}; };
#else #else
typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal; typedef struct LZ4HC_CCtx_internal LZ4HC_CCtx_internal;
struct LZ4HC_CCtx_internal struct LZ4HC_CCtx_internal {
{
unsigned int hashTable[LZ4HC_HASHTABLESIZE]; unsigned int hashTable[LZ4HC_HASHTABLESIZE];
unsigned short chainTable[LZ4HC_MAXD]; unsigned short chainTable[LZ4HC_MAXD];
const unsigned char* end; /* next block here to continue on current prefix */ const unsigned char *end; /* next block here to continue on current prefix */
const unsigned char* base; /* All index relative to this position */ const unsigned char *base; /* All index relative to this position */
const unsigned char* dictBase; /* alternate base for extDict */ const unsigned char *dictBase; /* alternate base for extDict */
unsigned int dictLimit; /* below that point, need extDict */ unsigned int dictLimit; /* below that point, need extDict */
unsigned int lowLimit; /* below that point, no more dict */ unsigned int lowLimit; /* below that point, no more dict */
unsigned int nextToUpdate; /* index from which to continue dictionary update */ unsigned int nextToUpdate; /* index from which to continue dictionary update */
@ -236,7 +234,7 @@ struct LZ4HC_CCtx_internal
char favorDecSpeed; /* favor decompression speed if this flag set, char favorDecSpeed; /* favor decompression speed if this flag set,
otherwise, favor compression ratio */ otherwise, favor compression ratio */
char dirty; /* stream has to be fully reset if this flag is set */ char dirty; /* stream has to be fully reset if this flag is set */
const LZ4HC_CCtx_internal* dictCtx; const LZ4HC_CCtx_internal *dictCtx;
}; };
#endif #endif
@ -269,7 +267,7 @@ union LZ4_streamHC_u {
* Required before first use of a statically allocated LZ4_streamHC_t. * Required before first use of a statically allocated LZ4_streamHC_t.
* Before v1.9.0 : use LZ4_resetStreamHC() instead * Before v1.9.0 : use LZ4_resetStreamHC() instead
*/ */
LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size); LZ4LIB_API LZ4_streamHC_t *LZ4_initStreamHC(void *buffer, size_t size);
/*-************************************ /*-************************************
@ -278,16 +276,16 @@ LZ4LIB_API LZ4_streamHC_t* LZ4_initStreamHC (void* buffer, size_t size);
/* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */ /* see lz4.h LZ4_DISABLE_DEPRECATE_WARNINGS to turn off deprecation warnings */
/* deprecated compression functions */ /* deprecated compression functions */
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC (const char* source, char* dest, int inputSize); LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC(const char *source, char *dest, int inputSize);
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput (const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize);
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2 (const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2(const char *source, char *dest, int inputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput(const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC (void* state, const char* source, char* dest, int inputSize); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_withStateHC(void *state, const char *source, char *dest, int inputSize);
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC (void* state, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_withStateHC(void *state, const char *source, char *dest, int inputSize, int maxOutputSize);
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC (void* state, const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_withStateHC(void *state, const char *source, char *dest, int inputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_extStateHC() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_withStateHC(void *state, const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize); LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize);
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize); LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC_limitedOutput_continue(LZ4_streamHC_t *LZ4_streamHCPtr, const char *source, char *dest, int inputSize, int maxOutputSize);
/* Obsolete streaming functions; degraded functionality; do not use! /* Obsolete streaming functions; degraded functionality; do not use!
* *
@ -297,13 +295,13 @@ LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_comp
* LZ4_slideInputBufferHC() will truncate the history of the stream, rather * LZ4_slideInputBufferHC() will truncate the history of the stream, rather
* than preserve a window-sized chunk of history. * than preserve a window-sized chunk of history.
*/ */
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void* LZ4_createHC (const char* inputBuffer); LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API void *LZ4_createHC(const char *inputBuffer);
LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char* LZ4_slideInputBufferHC (void* LZ4HC_Data); LZ4_DEPRECATED("use LZ4_saveDictHC() instead") LZ4LIB_API char *LZ4_slideInputBufferHC(void *LZ4HC_Data);
LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC (void* LZ4HC_Data); LZ4_DEPRECATED("use LZ4_freeStreamHC() instead") LZ4LIB_API int LZ4_freeHC(void *LZ4HC_Data);
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_continue(void *LZ4HC_Data, const char *source, char *dest, int inputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel); LZ4_DEPRECATED("use LZ4_compress_HC_continue() instead") LZ4LIB_API int LZ4_compressHC2_limitedOutput_continue(void *LZ4HC_Data, const char *source, char *dest, int inputSize, int maxOutputSize, int compressionLevel);
LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void); LZ4_DEPRECATED("use LZ4_createStreamHC() instead") LZ4LIB_API int LZ4_sizeofStreamStateHC(void);
LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void* state, char* inputBuffer); LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStreamStateHC(void *state, char *inputBuffer);
/* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC(). /* LZ4_resetStreamHC() is now replaced by LZ4_initStreamHC().
@ -314,7 +312,7 @@ LZ4_DEPRECATED("use LZ4_initStreamHC() instead") LZ4LIB_API int LZ4_resetStre
* It is recommended to switch to LZ4_initStreamHC(). * It is recommended to switch to LZ4_initStreamHC().
* LZ4_resetStreamHC() will generate deprecation warnings in a future version. * LZ4_resetStreamHC() will generate deprecation warnings in a future version.
*/ */
LZ4LIB_API void LZ4_resetStreamHC (LZ4_streamHC_t* streamHCPtr, int compressionLevel); LZ4LIB_API void LZ4_resetStreamHC(LZ4_streamHC_t *streamHCPtr, int compressionLevel);
#if defined (__cplusplus) #if defined (__cplusplus)
@ -349,14 +347,14 @@ extern "C" {
* for dynamic adaptation. * for dynamic adaptation.
*/ */
LZ4LIB_STATIC_API void LZ4_setCompressionLevel( LZ4LIB_STATIC_API void LZ4_setCompressionLevel(
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel); LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel);
/*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental) /*! LZ4_favorDecompressionSpeed() : v1.8.2+ (experimental)
* Opt. Parser will favor decompression speed over compression ratio. * Opt. Parser will favor decompression speed over compression ratio.
* Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN. * Only applicable to levels >= LZ4HC_CLEVEL_OPT_MIN.
*/ */
LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed( LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
LZ4_streamHC_t* LZ4_streamHCPtr, int favor); LZ4_streamHC_t *LZ4_streamHCPtr, int favor);
/*! LZ4_resetStreamHC_fast() : v1.9.0+ /*! LZ4_resetStreamHC_fast() : v1.9.0+
* When an LZ4_streamHC_t is known to be in a internally coherent state, * When an LZ4_streamHC_t is known to be in a internally coherent state,
@ -382,7 +380,7 @@ LZ4LIB_STATIC_API void LZ4_favorDecompressionSpeed(
* clear any existing history and settings from the context. * clear any existing history and settings from the context.
*/ */
LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast( LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
LZ4_streamHC_t* LZ4_streamHCPtr, int compressionLevel); LZ4_streamHC_t *LZ4_streamHCPtr, int compressionLevel);
/*! LZ4_compress_HC_extStateHC_fastReset() : /*! LZ4_compress_HC_extStateHC_fastReset() :
* A variant of LZ4_compress_HC_extStateHC(). * A variant of LZ4_compress_HC_extStateHC().
@ -395,9 +393,9 @@ LZ4LIB_STATIC_API void LZ4_resetStreamHC_fast(
* LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a * LZ4_resetStreamHC_fast() while LZ4_compress_HC_extStateHC() starts with a
* call to LZ4_resetStreamHC(). * call to LZ4_resetStreamHC().
*/ */
LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset ( LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset(
void* state, void *state,
const char* src, char* dst, const char *src, char *dst,
int srcSize, int dstCapacity, int srcSize, int dstCapacity,
int compressionLevel); int compressionLevel);
@ -427,7 +425,7 @@ LZ4LIB_STATIC_API int LZ4_compress_HC_extStateHC_fastReset (
* through the lifetime of the stream session. * through the lifetime of the stream session.
*/ */
LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary( LZ4LIB_STATIC_API void LZ4_attach_HC_dictionary(
LZ4_streamHC_t *working_stream, LZ4_streamHC_t *working_stream,
const LZ4_streamHC_t *dictionary_stream); const LZ4_streamHC_t *dictionary_stream);
#if defined (__cplusplus) #if defined (__cplusplus)

View file

@ -1,4 +1,4 @@
MYSRCPATHS = MYSRCPATHS =
MYINCLUDES = -I../../common_fpga MYINCLUDES = -I../../common_fpga
MYCFLAGS = -std=c99 -D_ISOC99_SOURCE MYCFLAGS = -std=c99 -D_ISOC99_SOURCE
MYDEFS = MYDEFS =

View file

@ -61,7 +61,7 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
for (uint16_t j = 0; j < num_infiles; j++) { for (uint16_t j = 0; j < num_infiles; j++) {
for (uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) { for (uint16_t k = 0; k < FPGA_INTERLEAVE_SIZE; k++) {
uint8_t c = (uint8_t)fgetc(infile[j]); uint8_t c = (uint8_t)fgetc(infile[j]);
if (!feof(infile[j])) { if (!feof(infile[j])) {
fpga_config[total_size++] = c; fpga_config[total_size++] = c;
} else if (num_infiles > 1) { } else if (num_infiles > 1) {
@ -81,12 +81,12 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
char *outbuf = calloc(outsize_max, sizeof(char)); char *outbuf = calloc(outsize_max, sizeof(char));
LZ4_streamHC_t* lz4_streamhc = LZ4_createStreamHC(); LZ4_streamHC_t *lz4_streamhc = LZ4_createStreamHC();
LZ4_resetStreamHC_fast(lz4_streamhc, LZ4HC_CLEVEL_MAX); LZ4_resetStreamHC_fast(lz4_streamhc, LZ4HC_CLEVEL_MAX);
int current_in = 0; int current_in = 0;
int current_out = 0; int current_out = 0;
char * ring_buffer = calloc(buffer_size, sizeof(char)); char *ring_buffer = calloc(buffer_size, sizeof(char));
while (current_in < total_size) { while (current_in < total_size) {
int bytes_to_copy = FPGA_RING_BUFFER_BYTES; int bytes_to_copy = FPGA_RING_BUFFER_BYTES;
if (total_size - current_in < FPGA_RING_BUFFER_BYTES) if (total_size - current_in < FPGA_RING_BUFFER_BYTES)
@ -105,13 +105,13 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
free(ring_buffer); free(ring_buffer);
free(outbuf); free(outbuf);
free(fpga_config); free(fpga_config);
fclose(outfile); fclose(outfile);
for (uint16_t j = 0; j < num_infiles; j++) { for (uint16_t j = 0; j < num_infiles; j++) {
fclose(infile[j]); fclose(infile[j]);
} }
LZ4_freeStreamHC(lz4_streamhc); LZ4_freeStreamHC(lz4_streamhc);
fprintf(stdout, "compressed %u input bytes to %u output bytes\n", total_size, current_out); fprintf(stdout, "compressed %u input bytes to %u output bytes\n", total_size, current_out);
if (current_out == 0) { if (current_out == 0) {
@ -122,8 +122,8 @@ static int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile) {
} }
typedef struct lz4_stream_s { typedef struct lz4_stream_s {
LZ4_streamDecode_t* lz4StreamDecode; LZ4_streamDecode_t *lz4StreamDecode;
char* next_in; char *next_in;
int avail_in; int avail_in;
} lz4_stream; } lz4_stream;
@ -143,7 +143,7 @@ static int zlib_decompress(FILE *infile, FILE *outfile) {
return (EXIT_FAILURE); return (EXIT_FAILURE);
} }
char* inbuf = calloc(infile_size, sizeof(char)); char *inbuf = calloc(infile_size, sizeof(char));
size_t num_read = fread(inbuf, sizeof(char), infile_size, infile); size_t num_read = fread(inbuf, sizeof(char), infile_size, infile);
if (num_read != infile_size) { if (num_read != infile_size) {

View file

@ -43,7 +43,7 @@ def lfsr_bs(state, i):
def f20a_bs(a,b,c,d): def f20a_bs(a,b,c,d):
return (~(((a|b)&c)^(a|d)^b)) # 6 ops return (~(((a|b)&c)^(a|d)^b)) # 6 ops
def f20b_bs(a,b,c,d): def f20b_bs(a,b,c,d):
return (~(((d|c)&(a^b))^(d|a|b))) # 7 ops return (~(((d|c)&(a^b))^(d|a|b))) # 7 ops
def f20c_bs(a,b,c,d,e): def f20c_bs(a,b,c,d,e):
return (~((((((c^e)|d)&a)^b)&(c^b))^(((d^e)|a)&((d^b)|c)))) # 13 ops return (~((((((c^e)|d)&a)^b)&(c^b))^(((d^e)|a)&((d^b)|c)))) # 13 ops

View file

@ -1,9 +1,9 @@
#define __STDC_FORMAT_MACROS #define __STDC_FORMAT_MACROS
#if !defined(_WIN64) #if !defined(_WIN64)
#if defined(_WIN32) || defined(__WIN32__) #if defined(_WIN32) || defined(__WIN32__)
# define _USE_32BIT_TIME_T 1 # define _USE_32BIT_TIME_T 1
#endif #endif
#endif #endif
#include <inttypes.h> #include <inttypes.h>