Merge remote-tracking branch 'upstream/master' into hf_mf_sim

This commit is contained in:
vratiskol 2019-03-24 22:53:04 +01:00
commit 0d5173739c
6 changed files with 27 additions and 21 deletions

View file

@ -260,9 +260,12 @@ int CmdFlashMemLoad(const char *Cmd) {
break; break;
} }
data = realloc(data, datalen); uint8_t *newdata = realloc(data, datalen);
if (!data) { if (newdata == NULL) {
free(data);
return 1; return 1;
} else {
data = newdata;
} }
//Send to device //Send to device

View file

@ -41,8 +41,8 @@ int usage_lf_keri_sim(void) {
// find KERI preamble in already demoded data // find KERI preamble in already demoded data
int detectKeri(uint8_t *dest, size_t *size, bool *invert) { int detectKeri(uint8_t *dest, size_t *size, bool *invert) {
uint8_t preamble[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}; uint8_t preamble[] = {1,1,1,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1};
uint8_t preamble_i[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0}; uint8_t preamble_i[] = {0,0,0,1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0};
// sanity check. // sanity check.
if (*size < sizeof(preamble) + 100) return -1; if (*size < sizeof(preamble) + 100) return -1;
@ -157,18 +157,16 @@ int CmdKeriClone(const char *Cmd) {
2 << T5555_MAXBLOCK_SHIFT; 2 << T5555_MAXBLOCK_SHIFT;
} }
// MSB is ONE // MSB is ONE
internalid |= 0x80000000; internalid |= 0x80000000;
// 3 LSB is ONE // 3 LSB is ONE
uint64_t data = ((uint64_t)internalid << 3) + 7; uint64_t data = ((uint64_t)internalid << 3) + 7;
PrintAndLogEx(INFO, "Preparing to clone KERI to T55x7 with Internal Id: %" PRIx64, internalid );
// //
blocks[1] = data >> 32; blocks[1] = data >> 32;
blocks[2] = data & 0xFFFFFFFF; blocks[2] = data & 0xFFFFFFFF;
PrintAndLogEx(INFO, "Preparing to clone KERI to T55x7 with Internal Id: %u", internalid);
print_blocks(blocks, 3); print_blocks(blocks, 3);

View file

@ -147,8 +147,8 @@ int CmdParadoxRead(const char *Cmd) {
int CmdParadoxSim(const char *Cmd) { int CmdParadoxSim(const char *Cmd) {
char cmdp = param_getchar(Cmd, 0); char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h' || cmdp == 'H') return usage_lf_paradox_sim(); if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_paradox_sim();
uint32_t facilitycode = 0, cardnumber = 0, fc = 0, cn = 0; uint32_t facilitycode = 0, cardnumber = 0, fc = 0, cn = 0;

View file

@ -55,7 +55,7 @@ int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) {
if (getSignalProperties()->isnoise) return -2; if (getSignalProperties()->isnoise) return -2;
// FSK demodulator RF/50 FSK 10,8 // FSK demodulator RF/50 FSK 10,8
*size = fskdemod(dest, *size, 50, 0, 10, 8, waveStartIdx); // pyramid fsk2 *size = fskdemod(dest, *size, 50, 1, 10, 8, waveStartIdx); // pyramid fsk2
//did we get a good demod? //did we get a good demod?
if (*size < 128) return -3; if (*size < 128) return -3;
@ -235,10 +235,12 @@ int CmdPyramidDemod(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Pyramid ID Found - BitLength: %d -unknown BitLength- (%d), Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo); PrintAndLogEx(SUCCESS, "Pyramid ID Found - BitLength: %d -unknown BitLength- (%d), Raw: %08x%08x%08x%08x", fmtLen, cardnum, rawHi3, rawHi2, rawHi, rawLo);
} }
} }
if (checksum == checkCS)
PrintAndLogEx(SUCCESS, "Checksum %02x passed", checksum); PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - %02X - %s"
else , checksum
PrintAndLogEx(FAILED, "Checksum %02x failed - should have been %02x", checksum, checkCS); , checkCS
, (checksum == checkCS) ? _GREEN_("Passed") : _RED_("Failed")
);
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128); PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
if (g_debugMode) if (g_debugMode)

View file

@ -254,7 +254,7 @@ int CmdTIDemod(const char *Cmd) {
//crc = crc16_ccitt(message, sizeof(message); //crc = crc16_ccitt(message, sizeof(message);
char *crcStr = (crc == (shift2 & 0xFFFF)) ? "Passed" : "Failed"; char *crcStr = (crc == (shift2 & 0xFFFF)) ? _GREEN_("Passed") : _RED_("Failed");
PrintAndLogEx(INFO, "Tag data = %08X%08X [Crc %04X %s]", shift1, shift0, crc, crcStr); PrintAndLogEx(INFO, "Tag data = %08X%08X [Crc %04X %s]", shift1, shift0, crc, crcStr);

View file

@ -167,7 +167,6 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
fclose(infile[j]); fclose(infile[j]);
} }
fclose(outfile); fclose(outfile);
free(infile);
free(fpga_config); free(fpga_config);
return (EXIT_FAILURE); return (EXIT_FAILURE);
} }
@ -182,7 +181,6 @@ int zlib_compress(FILE *infile[], uint8_t num_infiles, FILE *outfile, bool hardn
fclose(infile[j]); fclose(infile[j]);
} }
fclose(outfile); fclose(outfile);
free(infile);
free(fpga_config); free(fpga_config);
return (EXIT_SUCCESS); return (EXIT_SUCCESS);
@ -429,9 +427,11 @@ int main(int argc, char **argv) {
return (EXIT_FAILURE); return (EXIT_FAILURE);
} }
return zlib_decompress(infiles[0], outfile); int ret = zlib_decompress(infiles[0], outfile);
free(infiles);
return (ret);
} else { // Compress or gemerate version info } else { // Compress or generate version info
bool hardnested_mode = false; bool hardnested_mode = false;
bool generate_version_file = false; bool generate_version_file = false;
@ -476,7 +476,10 @@ int main(int argc, char **argv) {
return (EXIT_FAILURE); return (EXIT_FAILURE);
} }
} else { } else {
return zlib_compress(infiles, num_input_files, outfile, hardnested_mode); int ret = zlib_compress(infiles, num_input_files, outfile, hardnested_mode);
free(infile_names);
free(infiles);
return (ret);
} }
} }
} }