This commit is contained in:
iceman1001 2020-01-09 20:08:40 +01:00
commit 30e50cf407
48 changed files with 869 additions and 627 deletions

View file

@ -3,6 +3,10 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Fix `lf config` - when called with no params, it no longer mess up all device lf config settings. (@iceman1001)
- Change `lf indala clone` - new option `--Q5` writes to q5/T5555 tags. (@iceman1001)
- Change `lf indala clone` - new option `-c <card id>` allows cloning INDALA tag from Heden2L/Hedengren ID format (@iceman1001) - Thanks to @randomdude42 for solution
- Change `lf indala demod` - added decode Heden2L/Hedengren format (@iceman1001) - Thanks to @randomdude42 for solution
- Add `commands.md` - document with all proxmark client commands. Generated with XX_internal_command_dump_markdown_XX. (@iceman1001)
- Change `lf pac clone` - new option `c <card id>` to allow cloning PAC/Stanley tag from card ID (@danshuk)
- Change `lf pac read` - decoded PAC/Stanley card ID (@danshuk)

View file

@ -730,11 +730,11 @@ static void PacketReceived(PacketCommandNG *packet) {
}
case CMD_LF_ACQ_RAW_ADC: {
struct p {
uint8_t silent;
uint8_t verbose;
uint32_t samples;
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
uint32_t bits = SampleLF(payload->silent, payload->samples);
uint32_t bits = SampleLF(payload->verbose, payload->samples);
reply_ng(CMD_LF_ACQ_RAW_ADC, PM3_SUCCESS, (uint8_t *)&bits, sizeof(bits));
break;
}
@ -780,7 +780,7 @@ static void PacketReceived(PacketCommandNG *packet) {
}
case CMD_LF_NRZ_SIMULATE: {
lf_nrzsim_t *payload = (lf_nrzsim_t *)packet->data.asBytes;
CmdNRZsimTAG(payload->invert, payload->separator, payload->clock, packet->length - sizeof(lf_asksim_t), payload->data, true);
CmdNRZsimTAG(payload->invert, payload->separator, payload->clock, packet->length - sizeof(lf_nrzsim_t), payload->data, true);
break;
}
case CMD_LF_HID_CLONE: {
@ -1603,7 +1603,7 @@ static void PacketReceived(PacketCommandNG *packet) {
BigBuf_Clear_ext(false);
BigBuf_free();
}
// 40 000 - (512-3) 509 = 39491
uint16_t offset = MIN(BIGBUF_SIZE - PM3_CMD_DATA_SIZE - 3, payload->offset);

View file

@ -1299,13 +1299,13 @@ void ReadHitagS(hitag_function htf, hitag_data *htd) {
tag.pages[pageNum][i] = 0x0;
for (i = 0; i < 4; i++) { // set page bytes from recieved bits
tag.pages[pageNum][i] += ((pageData[i * 8] << 7)
| (pageData[1 + (i * 8)] << 6)
| (pageData[2 + (i * 8)] << 5)
| (pageData[3 + (i * 8)] << 4)
| (pageData[4 + (i * 8)] << 3)
| (pageData[5 + (i * 8)] << 2)
| (pageData[6 + (i * 8)] << 1)
| pageData[7 + (i * 8)]);
| (pageData[1 + (i * 8)] << 6)
| (pageData[2 + (i * 8)] << 5)
| (pageData[3 + (i * 8)] << 4)
| (pageData[4 + (i * 8)] << 3)
| (pageData[5 + (i * 8)] << 2)
| (pageData[6 + (i * 8)] << 1)
| pageData[7 + (i * 8)]);
}
if (tag.auth && tag.LKP && pageNum == 1) {
Dbprintf("Page[%2d]: %02X %02X %02X %02X", pageNum, pwdh0,

View file

@ -61,7 +61,7 @@ size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
adc_val = AT91C_BASE_SSC->SSC_RHR;
periods++;
if (logging) logSample(adc_val, 1, 8, 0, 0);
if (logging) logSample(adc_val, 1, 8, 0);
// Only test field changes if state of adc values matter
if (!wait) {
@ -91,7 +91,7 @@ size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
if (periods == max) return 0;
}
}
if (logging) logSample(255, 1, 8, 0, 0);
if (logging) logSample(255, 1, 8, 0);
return 0;
}
@ -150,12 +150,12 @@ void lf_init(bool reader) {
AT91C_BASE_PIOA->PIO_OER = GPIO_SSC_DOUT;
LOW(GPIO_SSC_DOUT);
// Enable peripheral Clock for TIMER_CLOCK0
// Enable peripheral Clock for TIMER_CLOCK 0
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_TC0);
AT91C_BASE_TC0->TC_CCR = AT91C_TC_CLKDIS;
AT91C_BASE_TC0->TC_CMR = AT91C_TC_CLKS_TIMER_DIV4_CLOCK;
// Enable peripheral Clock for TIMER_CLOCK0
// Enable peripheral Clock for TIMER_CLOCK 1
AT91C_BASE_PMC->PMC_PCER = (1 << AT91C_ID_TC1);
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKDIS;
AT91C_BASE_TC1->TC_CMR = AT91C_TC_CLKS_TIMER_DIV4_CLOCK;
@ -168,7 +168,7 @@ void lf_init(bool reader) {
AT91C_BASE_TC1->TC_CCR = AT91C_TC_CLKEN | AT91C_TC_SWTRG;
// Prepare data trace
if (logging) initSamplingBuffer();
if (logging) initSampleBuffer(NULL);
}
@ -189,9 +189,21 @@ void lf_finalize() {
size_t lf_detect_field_drop(size_t max) {
size_t periods = 0;
volatile uint8_t adc_val;
int16_t checked = 0;
while (true) {
// only every 1000th times, in order to save time when collecting samples.
if (checked == 1000) {
if (BUTTON_PRESS() || data_available()) {
checked = -1;
break;
} else {
checked = 0;
}
}
++checked;
// usb check?
while (!BUTTON_PRESS()) {
// Watchdog hit
WDT_HIT();
@ -199,7 +211,7 @@ size_t lf_detect_field_drop(size_t max) {
periods++;
adc_val = AT91C_BASE_SSC->SSC_RHR;
if (logging) logSample(adc_val, 1, 8, 0, 0);
if (logging) logSample(adc_val, 1, 8, 0);
if (adc_val == 0) {
rising_edge = false;

View file

@ -473,7 +473,7 @@ void ModThenAcquireRawAdcSamples125k(uint32_t delay_off, uint32_t period_0, uint
FpgaWriteConfWord(FPGA_MAJOR_MODE_LF_READER | FPGA_LF_ADC_READER_FIELD);
// now do the read
DoAcquisition_config(false, 0);
DoAcquisition_config(true, 0);
// Turn off antenna
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
@ -1182,7 +1182,7 @@ static void nrzSimBit(uint8_t c, int *n, uint8_t clock) {
*n += clock;
}
// args clock,
// args clock,
void CmdNRZsimTAG(uint8_t invert, uint8_t separator, uint8_t clk, uint16_t size, uint8_t *bits, bool ledcontrol) {
FpgaDownloadAndGo(FPGA_BITSTREAM_LF);
@ -1198,7 +1198,7 @@ void CmdNRZsimTAG(uint8_t invert, uint8_t separator, uint8_t clk, uint16_t size,
nrzSimBit(bits[i] ^ invert, &n, clk);
}
if (bits[0] == bits[size - 1]) { //run a second set inverted (for ask/raw || biphase phase)
if (bits[0] == bits[size - 1]) {
for (i = 0; i < size; i++) {
nrzSimBit(bits[i] ^ invert ^ 1, &n, clk);
}
@ -1239,7 +1239,7 @@ void CmdHIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
WDT_HIT();
if (ledcontrol) LED_A_ON();
DoAcquisition_default(-1, true);
DoAcquisition_default(-1, false);
// FSK demodulator
size = 50 * 128 * 2; //big enough to catch 2 sequences of largest format
int idx = HIDdemodFSK(dest, &size, &hi2, &hi, &lo, &dummyIdx);
@ -1330,7 +1330,7 @@ void CmdAWIDdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol)
WDT_HIT();
if (ledcontrol) LED_A_ON();
DoAcquisition_default(-1, true);
DoAcquisition_default(-1, false);
// FSK demodulator
size = MIN(12800, BigBuf_max_traceLen());
@ -1421,11 +1421,11 @@ void CmdEM410xdemod(int findone, uint32_t *high, uint64_t *low, int ledcontrol)
WDT_HIT();
if (ledcontrol) LED_A_ON();
DoAcquisition_default(-1, true);
DoAcquisition_default(-1, false);
size = MIN(16385, BigBuf_max_traceLen());
//askdemod and manchester decode
//askdemod and manchester decode
int errCnt = askdemod(dest, &size, &clk, &invert, maxErr, 0, 1);
WDT_HIT();
@ -1486,10 +1486,10 @@ void CmdIOdemodFSK(int findone, uint32_t *high, uint32_t *low, int ledcontrol) {
WDT_HIT();
if (ledcontrol) LED_A_ON();
DoAcquisition_default(-1, true);
DoAcquisition_default(-1, false);
size = MIN(12000, BigBuf_max_traceLen());
//fskdemod and get start index
int idx = detectIOProx(dest, &size, &dummyIdx);
if (idx < 0) continue;
@ -1772,7 +1772,7 @@ void T55xxResetRead(uint8_t flags) {
TurnReadLFOn(T55xx_Timing.m[downlink_mode].read_gap);
// Acquisition
DoPartialAcquisition(0, true, BigBuf_max_traceLen(), 0);
DoPartialAcquisition(0, false, BigBuf_max_traceLen(), 0);
// Turn the field off
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
@ -1869,7 +1869,7 @@ void T55xxWriteBlock(uint8_t *data) {
// response should be (for t55x7) a 0 bit then (ST if on)
// block data written in on repeat until reset.
//DoPartialAcquisition(20, true, 12000);
//DoPartialAcquisition(20, false, 12000);
}
// turn field off
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
@ -1930,7 +1930,7 @@ bool brute_mem = (flags & 0x0100) >> 8;
// Acquisition
// Now do the acquisition
DoPartialAcquisition(0, true, samples, 0);
DoPartialAcquisition(0, false, samples, 0);
// Turn the field off
if (!brute_mem) {
@ -1990,7 +1990,7 @@ void T55xxReadBlock(uint8_t page, bool pwd_mode, bool brute_mem, uint8_t block,
// Acquisition
// Now do the acquisition
DoPartialAcquisition(0, true, samples, 0);
DoPartialAcquisition(0, false, samples, 0);
// Turn the field off
if (!brute_mem) {
@ -2447,7 +2447,7 @@ void EM4xReadWord(uint8_t addr, uint32_t pwd, uint8_t usepwd) {
WaitUS(400);
DoPartialAcquisition(20, true, 6000, 1000);
DoPartialAcquisition(20, false, 6000, 1000);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
reply_ng(CMD_LF_EM4X_READWORD, PM3_SUCCESS, NULL, 0);
@ -2480,7 +2480,7 @@ void EM4xWriteWord(uint8_t addr, uint32_t data, uint32_t pwd, uint8_t usepwd) {
//Wait 20ms for write to complete?
WaitMS(7);
DoPartialAcquisition(20, true, 6000, 1000);
DoPartialAcquisition(20, false, 6000, 1000);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
reply_ng(CMD_LF_EM4X_WRITEWORD, PM3_SUCCESS, NULL, 0);
@ -2550,7 +2550,7 @@ void Cotag(uint32_t arg0) {
doCotagAcquisitionManchester();
break;
case 2:
DoAcquisition_config(true, 0);
DoAcquisition_config(true, true);
break;
}

View file

@ -15,6 +15,7 @@
#include "dbprint.h"
#include "util.h"
#include "lfdemod.h"
#include "string.h" // memset
/*
Default LF config is set to:
@ -32,7 +33,7 @@ void printConfig() {
uint32_t d = config.divisor;
DbpString(_BLUE_("LF Sampling config"));
Dbprintf(" [q] divisor.............%d ( "_GREEN_("%d.%02d kHz")")", d, 12000 / (d + 1), ((1200000 + (d + 1) / 2) / (d + 1)) - ((12000 / (d + 1)) * 100));
Dbprintf(" [b] bps.................%d", config.bits_per_sample);
Dbprintf(" [b] bits per sample.....%d", config.bits_per_sample);
Dbprintf(" [d] decimation..........%d", config.decimation);
Dbprintf(" [a] averaging...........%s", (config.averaging) ? "Yes" : "No");
Dbprintf(" [t] trigger threshold...%d", config.trigger_threshold);
@ -41,25 +42,40 @@ void printConfig() {
/**
* Called from the USB-handler to set the sampling configuration
* The sampling config is used for std reading and sniffing.
* The sampling config is used for standard reading and sniffing.
*
* Other functions may read samples and ignore the sampling config,
* such as functions to read the UID from a prox tag or similar.
*
* Values set to '0' implies no change (except for averaging)
* Values set to '-1' implies no change
* @brief setSamplingConfig
* @param sc
*/
void setSamplingConfig(sample_config *sc) {
if (sc->divisor != 0) config.divisor = sc->divisor;
if (sc->bits_per_sample != 0) config.bits_per_sample = sc->bits_per_sample;
if (sc->trigger_threshold != -1) config.trigger_threshold = sc->trigger_threshold;
// if (sc->samples_to_skip == 0xffffffff) // if needed to not update if not supplied
config.samples_to_skip = sc->samples_to_skip;
config.decimation = (sc->decimation != 0) ? sc->decimation : 1;
config.averaging = sc->averaging;
if (config.bits_per_sample > 8) config.bits_per_sample = 8;
// decimation (1-8) how many bits of adc sample value to save
if (sc->decimation > 0 && sc->decimation < 8)
config.decimation = sc->decimation;
// bits per sample (1-8)
if (sc->bits_per_sample > 0 && sc->bits_per_sample < 8)
config.bits_per_sample = sc->bits_per_sample;
//
if (sc->averaging > -1)
config.averaging = (sc->averaging > 0) ? 1 : 0;
// Frequency divisor (19 - 255)
if (sc->divisor > 18 && sc->divisor < 256)
config.divisor = sc->divisor;
// Start saving samples when adc value larger than trigger_threshold
if (sc->trigger_threshold > -1)
config.trigger_threshold = sc->trigger_threshold;
// Skip n adc samples before saving
if (sc->samples_to_skip > -1)
config.samples_to_skip = sc->samples_to_skip;
if (sc->verbose)
printConfig();
@ -69,12 +85,6 @@ sample_config *getSamplingConfig() {
return &config;
}
struct BitstreamOut {
uint8_t *buffer;
uint32_t numbits;
uint32_t position;
};
/**
* @brief Pushes bit onto the stream
* @param stream
@ -88,6 +98,87 @@ void pushBit(BitstreamOut *stream, uint8_t bit) {
stream->numbits++;
}
// Holds bit packed struct of samples.
BitstreamOut data = {0, 0, 0};
// internal struct to keep track of samples gathered
sampling_t samples = {0, 0, 0, 0};
void initSampleBuffer(uint32_t *sample_size) {
if (sample_size == NULL || *sample_size == 0) {
*sample_size = BigBuf_max_traceLen();
} else {
*sample_size = MIN(*sample_size, BigBuf_max_traceLen());
}
// use a bitstream to handle the output
data.buffer = BigBuf_get_addr();
memset(data.buffer, 0, *sample_size);
//
samples.dec_counter = 0;
samples.sum = 0;
samples.counter = 0;
samples.total_saved = 0;
}
uint32_t getSampleCounter() {
return samples.total_saved;
}
void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg) {
if (!data.buffer) return;
if (bits_per_sample == 0) bits_per_sample = 1;
if (bits_per_sample > 8) bits_per_sample = 8;
if (decimation == 0) decimation = 1;
// keep track of total gather samples regardless how many was discarded.
samples.counter++;
if (avg) {
samples.sum += sample;
}
// check decimation
if (decimation > 1) {
samples.dec_counter++;
if (samples.dec_counter < decimation) return;
samples.dec_counter = 0;
}
// averaging
if (avg && decimation > 1) {
sample = samples.sum / decimation;
samples.sum = 0;
}
// store the sample
samples.total_saved++;
if (bits_per_sample == 8) {
data.buffer[samples.total_saved - 1] = sample;
// add number of bits.
data.numbits = samples.total_saved << 3;
} else {
pushBit(&data, sample & 0x80);
if (bits_per_sample > 1) pushBit(&data, sample & 0x40);
if (bits_per_sample > 2) pushBit(&data, sample & 0x20);
if (bits_per_sample > 3) pushBit(&data, sample & 0x10);
if (bits_per_sample > 4) pushBit(&data, sample & 0x08);
if (bits_per_sample > 5) pushBit(&data, sample & 0x04);
if (bits_per_sample > 6) pushBit(&data, sample & 0x02);
}
}
/**
* Setup the FPGA to listen for samples. This method downloads the FPGA bitstream
* if not already loaded, sets divisor and starts up the antenna.
@ -128,45 +219,39 @@ void LFSetupFPGAForADC(int divisor, bool lf_field) {
* value that will be used is the average value of the three samples.
* @param trigger_threshold - a threshold. The sampling won't commence until this threshold has been reached. Set
* to -1 to ignore threshold.
* @param silent - is true, now outputs are made. If false, dbprints the status
* @param verbose - is true, dbprints the status, else no outputs
* @return the number of bits occupied by the samples.
*/
uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold, bool silent, int bufsize, uint32_t cancel_after, uint32_t samples_to_skip) {
uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, int16_t trigger_threshold,
bool verbose, uint32_t sample_size, uint32_t cancel_after, int32_t samples_to_skip) {
uint8_t *dest = BigBuf_get_addr();
bufsize = (bufsize > 0 && bufsize < BigBuf_max_traceLen()) ? bufsize : BigBuf_max_traceLen();
initSampleBuffer(&sample_size);
if (bits_per_sample < 1) bits_per_sample = 1;
if (bits_per_sample > 8) bits_per_sample = 8;
if (decimation < 1) decimation = 1;
// use a bit stream to handle the output
BitstreamOut data = { dest, 0, 0};
int sample_counter = 0;
uint8_t sample;
// if we want to do averaging
uint32_t sample_sum = 0 ;
uint32_t sample_total_numbers = 0;
uint32_t sample_total_saved = 0;
uint32_t cancel_counter = 0;
uint16_t checked = 0;
int16_t checked = 0;
while (true) {
// only every 1000th times, in order to save time when collecting samples.
if (checked == 1000) {
if (BUTTON_PRESS() || data_available())
if (BUTTON_PRESS() || data_available()) {
checked = -1;
break;
else
} else {
checked = 0;
}
}
++checked;
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
// AT91C_BASE_SSC->SSC_THR = 0x43;
LED_D_ON();
}
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
// Testpoint 8 (TP8) can be used to trigger oscilliscope
LED_D_OFF();
@ -188,57 +273,23 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
continue;
}
sample_total_numbers++;
logSample(sample, decimation, bits_per_sample, avg);
if (averaging)
sample_sum += sample;
// check decimation
if (decimation > 1) {
sample_counter++;
if (sample_counter < decimation) continue;
sample_counter = 0;
}
// averaging
if (averaging && decimation > 1) {
sample = sample_sum / decimation;
sample_sum = 0;
}
// store the sample
sample_total_saved ++;
if (bits_per_sample == 8) {
dest[sample_total_saved - 1] = sample;
// Get the return value correct
data.numbits = sample_total_saved << 3;
if (sample_total_saved >= bufsize) break;
} else {
pushBit(&data, sample & 0x80);
if (bits_per_sample > 1) pushBit(&data, sample & 0x40);
if (bits_per_sample > 2) pushBit(&data, sample & 0x20);
if (bits_per_sample > 3) pushBit(&data, sample & 0x10);
if (bits_per_sample > 4) pushBit(&data, sample & 0x08);
if (bits_per_sample > 5) pushBit(&data, sample & 0x04);
if (bits_per_sample > 6) pushBit(&data, sample & 0x02);
if ((data.numbits >> 3) + 1 >= bufsize) break;
}
if (samples.total_saved >= sample_size) break;
}
}
if (!silent) {
Dbprintf("Done, saved " _YELLOW_("%d")"out of " _YELLOW_("%d")"seen samples at " _YELLOW_("%d")"bits/sample", sample_total_saved, sample_total_numbers, bits_per_sample);
Dbprintf("buffer samples: %02x %02x %02x %02x %02x %02x %02x %02x ...",
dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
if (checked == -1 && verbose) {
Dbprintf("lf sampling aborted");
}
if (verbose) {
Dbprintf("Done, saved " _YELLOW_("%d")"out of " _YELLOW_("%d")"seen samples at " _YELLOW_("%d")"bits/sample", samples.total_saved, samples.counter, bits_per_sample);
}
// Ensure that DC offset removal and noise check is performed for any device-side processing
removeSignalOffset(dest, bufsize);
computeSignalProperties(dest, bufsize);
removeSignalOffset(data.buffer, samples.total_saved);
computeSignalProperties(data.buffer, samples.total_saved);
return data.numbits;
}
@ -247,32 +298,33 @@ uint32_t DoAcquisition(uint8_t decimation, uint32_t bits_per_sample, bool averag
* This method is typically used by tag-specific readers who just wants to read the samples
* the normal way
* @param trigger_threshold
* @param silent
* @param verbose
* @return number of bits sampled
*/
uint32_t DoAcquisition_default(int trigger_threshold, bool silent) {
return DoAcquisition(1, 8, 0, trigger_threshold, silent, 0, 0, 0);
uint32_t DoAcquisition_default(int trigger_threshold, bool verbose) {
return DoAcquisition(1, 8, 0, trigger_threshold, verbose, 0, 0, 0);
}
uint32_t DoAcquisition_config(bool silent, int sample_size) {
uint32_t DoAcquisition_config(bool verbose, uint32_t sample_size) {
return DoAcquisition(config.decimation
, config.bits_per_sample
, config.averaging
, config.trigger_threshold
, silent
, verbose
, sample_size
, 0
, config.samples_to_skip);
}
uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size, uint32_t cancel_after) {
return DoAcquisition(1, 8, 0, trigger_threshold, silent, sample_size, cancel_after, 0);
uint32_t DoPartialAcquisition(int trigger_threshold, bool verbose, uint32_t sample_size, uint32_t cancel_after) {
return DoAcquisition(1, 8, 0, trigger_threshold, verbose, sample_size, cancel_after, 0);
}
uint32_t ReadLF(bool activeField, bool silent, int sample_size) {
if (!silent)
uint32_t ReadLF(bool activeField, bool verbose, uint32_t sample_size) {
if (verbose)
printConfig();
LFSetupFPGAForADC(config.divisor, activeField);
uint32_t ret = DoAcquisition_config(silent, sample_size);
uint32_t ret = DoAcquisition_config(verbose, sample_size);
FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF);
return ret;
}
@ -281,9 +333,9 @@ uint32_t ReadLF(bool activeField, bool silent, int sample_size) {
* Initializes the FPGA for reader-mode (field on), and acquires the samples.
* @return number of bits sampled
**/
uint32_t SampleLF(bool silent, int sample_size) {
uint32_t SampleLF(bool verbose, uint32_t sample_size) {
BigBuf_Clear_ext(false);
return ReadLF(true, silent, sample_size);
return ReadLF(true, verbose, sample_size);
}
/**
* Initializes the FPGA for sniffer-mode (field off), and acquires the samples.
@ -310,7 +362,7 @@ void doT55x7Acquisition(size_t sample_size) {
if (bufsize > sample_size)
bufsize = sample_size;
uint8_t curSample, lastSample = 0;
uint8_t lastSample = 0;
uint16_t i = 0, skipCnt = 0;
bool startFound = false;
bool highFound = false;
@ -330,24 +382,24 @@ void doT55x7Acquisition(size_t sample_size) {
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
LED_D_ON();
}
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
curSample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
LED_D_OFF();
// skip until the first high sample above threshold
if (!startFound && curSample > T55xx_READ_UPPER_THRESHOLD) {
//if (curSample > lastSample)
// lastSample = curSample;
if (!startFound && sample > T55xx_READ_UPPER_THRESHOLD) {
highFound = true;
} else if (!highFound) {
skipCnt++;
continue;
}
// skip until the first low sample below threshold
if (!startFound && curSample < T55xx_READ_LOWER_THRESHOLD) {
//if (curSample > lastSample)
lastSample = curSample;
if (!startFound && sample < T55xx_READ_LOWER_THRESHOLD) {
lastSample = sample;
lowFound = true;
} else if (!lowFound) {
skipCnt++;
@ -355,14 +407,14 @@ void doT55x7Acquisition(size_t sample_size) {
}
// skip until first high samples begin to change
if (startFound || curSample > T55xx_READ_LOWER_THRESHOLD + T55xx_READ_TOL) {
if (startFound || sample > T55xx_READ_LOWER_THRESHOLD + T55xx_READ_TOL) {
// if just found start - recover last sample
if (!startFound) {
dest[i++] = lastSample;
startFound = true;
}
// collect samples
dest[i++] = curSample;
dest[i++] = sample;
}
}
}
@ -388,7 +440,7 @@ void doCotagAcquisition(size_t sample_size) {
bufsize = sample_size;
dest[0] = 0;
uint8_t sample, firsthigh = 0, firstlow = 0;
uint8_t firsthigh = 0, firstlow = 0;
uint16_t i = 0;
uint16_t noise_counter = 0;
@ -406,8 +458,12 @@ void doCotagAcquisition(size_t sample_size) {
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
LED_D_ON();
}
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
// find first peak
if (!firsthigh) {
@ -441,7 +497,6 @@ void doCotagAcquisition(size_t sample_size) {
// Ensure that DC offset removal and noise check is performed for any device-side processing
removeSignalOffset(dest, bufsize);
computeSignalProperties(dest, bufsize);
}
uint32_t doCotagAcquisitionManchester() {
@ -453,7 +508,7 @@ uint32_t doCotagAcquisitionManchester() {
bufsize = COTAG_BITS;
dest[0] = 0;
uint8_t sample, firsthigh = 0, firstlow = 0;
uint8_t firsthigh = 0, firstlow = 0;
uint16_t sample_counter = 0, period = 0;
uint8_t curr = 0, prev = 0;
uint16_t noise_counter = 0;
@ -471,8 +526,12 @@ uint32_t doCotagAcquisitionManchester() {
WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_TXRDY) {
LED_D_ON();
}
if (AT91C_BASE_SSC->SSC_SR & AT91C_SSC_RXRDY) {
sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
volatile uint8_t sample = (uint8_t)AT91C_BASE_SSC->SSC_RHR;
// find first peak
if (!firsthigh) {

View file

@ -4,7 +4,18 @@
#include "common.h"
#include "pm3_cmd.h"
typedef struct BitstreamOut BitstreamOut;
typedef struct {
uint8_t *buffer;
uint32_t numbits;
uint32_t position;
} BitstreamOut;
typedef struct {
int dec_counter;
uint32_t sum;
uint32_t counter;
uint32_t total_saved;
} sampling_t;
/**
* acquisition of Cotag LF signal. Similar to other LF, since the Cotag has such long datarate RF/384
@ -23,7 +34,7 @@ void doT55x7Acquisition(size_t sample_size);
* Initializes the FPGA for reader-mode (field on), and acquires the samples.
* @return number of bits sampled
**/
uint32_t SampleLF(bool silent, int sample_size);
uint32_t SampleLF(bool verbose, uint32_t sample_size);
/**
* Initializes the FPGA for sniff-mode (field off), and acquires the samples.
@ -31,32 +42,35 @@ uint32_t SampleLF(bool silent, int sample_size);
**/
uint32_t SniffLF();
uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, int16_t trigger_threshold,
bool verbose, uint32_t sample_size, uint32_t cancel_after, int32_t samples_to_skip);
// adds sample size to default options
uint32_t DoPartialAcquisition(int trigger_threshold, bool silent, int sample_size, uint32_t cancel_after);
uint32_t DoPartialAcquisition(int trigger_threshold, bool verbose, uint32_t sample_size, uint32_t cancel_after);
/**
* @brief Does sample acquisition, ignoring the config values set in the sample_config.
* This method is typically used by tag-specific readers who just wants to read the samples
* the normal way
* @param trigger_threshold
* @param silent
* @param verbose
* @return number of bits sampled
*/
uint32_t DoAcquisition_default(int trigger_threshold, bool silent);
uint32_t DoAcquisition_default(int trigger_threshold, bool verbose);
/**
* @brief Does sample acquisition, using the config values set in the sample_config.
* @param trigger_threshold
* @param silent
* @param verbose
* @return number of bits sampled
*/
uint32_t DoAcquisition_config(bool silent, int sample_size);
uint32_t DoAcquisition_config(bool verbose, uint32_t sample_size);
/**
* Refactoring of lf sampling buffer
*/
void initSamplingBuffer(void);
void logSample(uint8_t sample, uint8_t decimation, uint32_t bits_per_sample, bool averaging, int trigger_threshold);
void initSampleBuffer(uint32_t *sample_size);
void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg);
uint32_t getSampleCounter();
/**

View file

@ -3421,7 +3421,7 @@ TRexBool trex_searchrange(TRex *exp, const TRexChar *text_begin, const TRexChar
if (!cur)
break;
node = exp->_nodes[node].next;
}
}
text_begin++;
} while (cur == NULL && text_begin != text_end);
@ -3484,8 +3484,12 @@ TRexBool trex_getsubexp(TRex *exp, int n, TRexMatch *subexp) {
static void arg_str_resetfn(struct arg_str *parent) {
int i;
ARG_TRACE(("%s:resetfn(%p)\n", __FILE__, parent));
parent->count = 0;
for (i = 0; i < parent->count; i++) {
parent->sval[i] = "";
}
}
@ -3671,8 +3675,7 @@ void arg_register_error(struct arg_end *end,
* Return index of first table entry with a matching short option
* or -1 if no match was found.
*/
static
int find_shortoption(struct arg_hdr * *table, char shortopt) {
static int find_shortoption(struct arg_hdr** table, char shortopt) {
int tabindex;
for (tabindex = 0; !(table[tabindex]->flag & ARG_TERMINATOR); tabindex++) {
if (table[tabindex]->shortopts &&
@ -3682,7 +3685,6 @@ int find_shortoption(struct arg_hdr * *table, char shortopt) {
return -1;
}
struct longoptions {
int getoptval;
int noptions;
@ -3706,8 +3708,7 @@ void dump_longoptions(struct longoptions *longoptions) {
}
#endif
static
struct longoptions *alloc_longoptions(struct arg_hdr * *table) {
static struct longoptions* alloc_longoptions(struct arg_hdr** table) {
struct longoptions *result;
size_t nbytes;
int noptions = 1;
@ -3789,8 +3790,7 @@ struct longoptions *alloc_longoptions(struct arg_hdr * *table) {
return result;
}
static
char *alloc_shortoptions(struct arg_hdr * *table) {
static char* alloc_shortoptions(struct arg_hdr** table) {
char *result;
size_t len = 2;
int tabindex;
@ -3830,8 +3830,7 @@ char *alloc_shortoptions(struct arg_hdr * *table) {
/* return index of the table terminator entry */
static
int arg_endindex(struct arg_hdr * *table) {
static int arg_endindex(struct arg_hdr** table) {
int tabindex = 0;
while (!(table[tabindex]->flag & ARG_TERMINATOR))
tabindex++;
@ -3839,10 +3838,9 @@ int arg_endindex(struct arg_hdr * *table) {
}
static
void arg_parse_tagged(int argc,
char * *argv,
struct arg_hdr * *table,
static void arg_parse_tagged(int argc,
char **argv,
struct arg_hdr **table,
struct arg_end *endtable) {
struct longoptions *longoptions;
char *shortoptions;
@ -3953,10 +3951,9 @@ void arg_parse_tagged(int argc,
}
static
void arg_parse_untagged(int argc,
char * *argv,
struct arg_hdr * *table,
static void arg_parse_untagged(int argc,
char **argv,
struct arg_hdr **table,
struct arg_end *endtable) {
int tabindex = 0;
int errorlast = 0;
@ -4010,7 +4007,6 @@ void arg_parse_untagged(int argc,
optarglast = argv[optind];
parentlast = parent;
}
}
/* if a tenative error still remains at this point then register it as a proper error */
@ -4030,8 +4026,7 @@ void arg_parse_untagged(int argc,
}
static
void arg_parse_check(struct arg_hdr * *table, struct arg_end *endtable) {
static void arg_parse_check(struct arg_hdr **table, struct arg_end *endtable) {
int tabindex = 0;
/* printf("arg_parse_check()\n"); */
do {
@ -4045,8 +4040,7 @@ void arg_parse_check(struct arg_hdr * *table, struct arg_end *endtable) {
}
static
void arg_reset(void * *argtable) {
static void arg_reset(void **argtable) {
struct arg_hdr * *table = (struct arg_hdr * *)argtable;
int tabindex = 0;
/*printf("arg_reset(%p)\n",argtable);*/
@ -4138,8 +4132,7 @@ int arg_parse(int argc, char * *argv, void * *argtable) {
* dest[] == "goodbye cruel world!"
* ndest == 10
*/
static
void arg_cat(char * *pdest, const char *src, size_t *pndest) {
static void arg_cat(char **pdest, const char *src, size_t *pndest) {
char *dest = *pdest;
char *end = dest + *pndest;
@ -4160,8 +4153,7 @@ void arg_cat(char * *pdest, const char *src, size_t *pndest) {
}
static
void arg_cat_option(char *dest,
static void arg_cat_option(char *dest,
size_t ndest,
const char *shortopts,
const char *longopts,
@ -4219,8 +4211,7 @@ void arg_cat_option(char *dest,
}
}
static
void arg_cat_optionv(char *dest,
static void arg_cat_optionv(char *dest,
size_t ndest,
const char *shortopts,
const char *longopts,
@ -4666,7 +4657,6 @@ int arg_nullcheck(void * *argtable) {
return 0;
}
/*
* arg_free() is deprecated in favour of arg_freetable() due to a flaw in its design.
* The flaw results in memory leak in the (very rare) case that an intermediate

View file

@ -1,4 +1,6 @@
/*******************************************************************************
* argtable3: Declares the main interfaces of the library
*
* This file is part of the argtable3 library.
*
* Copyright (C) 1998-2001,2003-2011,2013 Stewart Heitmann
@ -39,6 +41,13 @@ extern "C" {
#endif
#define ARG_REX_ICASE 1
#define ARG_DSTR_SIZE 200
#define ARG_CMD_NAME_LEN 100
#define ARG_CMD_DESCRIPTION_LEN 256
#ifndef ARG_REPLACE_GETOPT
#define ARG_REPLACE_GETOPT 1 /* use the embedded getopt as the system getopt(3) */
#endif /* ARG_REPLACE_GETOPT */
/* bit masks for arg_hdr.flag */
enum {
@ -143,6 +152,13 @@ struct arg_end {
const char **argval; /* Array of pointers to offending argv[] string */
};
/*
typedef struct arg_cmd_info {
char name[ARG_CMD_NAME_LEN];
char description[ARG_CMD_DESCRIPTION_LEN];
arg_cmdfn* proc;
} arg_cmd_info_t;
*/
/**** arg_xxx constructor functions *********************************/

View file

@ -13,16 +13,16 @@
#include "argtable3.h"
#include "util.h"
#define arg_param_begin arg_lit0("hH", "help", "print this help and exit")
#define arg_param_begin arg_lit0("hH", "help", "This help")
#define arg_param_end arg_end(20)
#define arg_getsize(a) (sizeof(a) / sizeof(a[0]))
#define arg_get_lit(n)(((struct arg_lit*)argtable[n])->count)
#define arg_getsize(a) (sizeof(a) / sizeof(a[0]))
#define arg_get_lit(n) (((struct arg_lit*)argtable[n])->count)
#define arg_get_int_count(n)(((struct arg_int*)argtable[n])->count)
#define arg_get_int(n)(((struct arg_int*)argtable[n])->ival[0])
#define arg_get_int_def(n,def)(arg_get_int_count(n)?(arg_get_int(n)):(def))
#define arg_get_str(n)((struct arg_str*)argtable[n])
#define arg_get_str_len(n)(strlen(((struct arg_str*)argtable[n])->sval[0]))
#define arg_get_int(n) (((struct arg_int*)argtable[n])->ival[0])
#define arg_get_int_def(n, def)(arg_get_int_count(n) ? (arg_get_int(n)) : (def))
#define arg_get_str(n) ((struct arg_str*)argtable[n])
#define arg_get_str_len(n) (strlen(((struct arg_str*)argtable[n])->sval[0]))
#define arg_strx1(shortopts, longopts, datatype, glossary) (arg_strn((shortopts), (longopts), (datatype), 1, 250, (glossary)))
#define arg_strx0(shortopts, longopts, datatype, glossary) (arg_strn((shortopts), (longopts), (datatype), 0, 250, (glossary)))

View file

@ -1589,7 +1589,7 @@ static uint8_t getByte(uint8_t bits_per_sample, BitstreamOut *b) {
return val;
}
int getSamples(uint32_t n, bool silent) {
int getSamples(uint32_t n, bool verbose) {
//If we get all but the last byte in bigbuf,
// we don't have to worry about remaining trash
// in the last byte in case the bits-per-sample
@ -1599,7 +1599,7 @@ int getSamples(uint32_t n, bool silent) {
if (n == 0 || n > sizeof(got))
n = sizeof(got);
if (!silent) PrintAndLogEx(NORMAL, "Reading %d bytes from device memory\n", n);
if (verbose) PrintAndLogEx(NORMAL, "Reading %d bytes from device memory\n", n);
PacketResponseNG response;
if (!GetFromDevice(BIG_BUF, got, n, 0, NULL, 0, &response, 10000, true)) {
@ -1607,20 +1607,20 @@ int getSamples(uint32_t n, bool silent) {
return PM3_ETIMEOUT;
}
if (!silent) PrintAndLogEx(NORMAL, "Data fetched");
if (verbose) PrintAndLogEx(NORMAL, "Data fetched");
uint8_t bits_per_sample = 8;
//Old devices without this feature would send 0 at arg[0]
if (response.oldarg[0] > 0) {
sample_config *sc = (sample_config *) response.data.asBytes;
if (!silent) PrintAndLogEx(NORMAL, "Samples @ %d bits/smpl, decimation 1:%d ", sc->bits_per_sample, sc->decimation);
if (verbose) PrintAndLogEx(NORMAL, "Samples @ %d bits/smpl, decimation 1:%d ", sc->bits_per_sample, sc->decimation);
bits_per_sample = sc->bits_per_sample;
}
if (bits_per_sample < 8) {
if (!silent) PrintAndLogEx(NORMAL, "Unpacking...");
if (verbose) PrintAndLogEx(NORMAL, "Unpacking...");
BitstreamOut bout = { got, bits_per_sample * n, 0};
int j = 0;
@ -1630,7 +1630,7 @@ int getSamples(uint32_t n, bool silent) {
}
GraphTraceLen = j;
if (!silent) PrintAndLogEx(NORMAL, "Unpacked %d samples", j);
if (verbose) PrintAndLogEx(NORMAL, "Unpacked %d samples", j);
} else {
for (int j = 0; j < n; j++) {

View file

@ -68,7 +68,7 @@ void setDemodBuff(uint8_t *buff, size_t size, size_t start_idx);
bool getDemodBuff(uint8_t *buff, size_t *size);
void save_restoreDB(uint8_t saveOpt);// option '1' to save DemodBuffer any other to restore
int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveGrph, bool verbose);
int getSamples(uint32_t n, bool silent);
int getSamples(uint32_t n, bool verbose);
void setClockGrid(uint32_t clk, int offset);
int directionalThreshold(const int *in, int *out, size_t len, int8_t up, int8_t down);
int AskEdgeDetect(const int *in, int *out, int len, int threshold);

View file

@ -633,7 +633,7 @@ static int CmdHF15Samples(const char *Cmd) {
clearCommandBuffer();
SendCommandNG(CMD_HF_ISO15693_ACQ_RAW_ADC, NULL, 0);
getSamples(0, false);
getSamples(0, true);
return PM3_SUCCESS;
}
@ -684,9 +684,9 @@ static int NxpSysInfo(uint8_t *uid) {
return PM3_EWRONGANSVER;
}
bool support_signature = (recv[5] & 0x01);
bool support_signature = (recv[5] & 0x01);
bool support_easmode = (recv[4] & 0x03);
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " NXP SYSINFO : %s", sprint_hex(recv, 8));
PrintAndLogEx(NORMAL, " Password protection configuration:");

View file

@ -440,10 +440,10 @@ static void clear_and_send_command(uint8_t flags, uint16_t datalen, uint8_t *dat
*/
static bool add_param(const char *Cmd, uint8_t paramCount, uint8_t *data, uint8_t dataPosition, uint8_t length) {
if (param_getlength(Cmd, paramCount) == length) {
if (param_gethex(Cmd, paramCount, data + dataPosition, length) == 1)
return false;
else
return false;
else
return true;
} else {
@ -460,7 +460,7 @@ static bool add_param(const char *Cmd, uint8_t paramCount, uint8_t *data, uint8_
static void print_rd_noEncrpytion_response(felica_read_without_encryption_response_t *rd_noCry_resp) {
if (rd_noCry_resp->status_flags.status_flag1[0] == 00 &&
rd_noCry_resp->status_flags.status_flag2[0] == 00) {
rd_noCry_resp->status_flags.status_flag2[0] == 00) {
char *temp = sprint_hex(rd_noCry_resp->block_data, sizeof(rd_noCry_resp->block_data));
@ -653,7 +653,7 @@ static int CmdHFFelicaAuthentication1(const char *Cmd) {
mbedtls_des3_set3key_enc(&des3_ctx, master_key);
PrintAndLogEx(INFO, "3DES Master Secret: %s", sprint_hex(master_key, 24));
} else if (param_getlength(Cmd, paramCount) == 32) {
if (param_gethex(Cmd, paramCount, master_key, 32) == 1) {
PrintAndLogEx(ERR, "Failed param key");
return PM3_EINVARG;
@ -781,7 +781,7 @@ static int CmdHFFelicaAuthentication2(const char *Cmd) {
mbedtls_des3_init(&des3_ctx);
unsigned char p3c[8];
if (param_getlength(Cmd, paramCount) == 32) {
if (param_gethex(Cmd, paramCount, master_key, 32) == 1) {
PrintAndLogEx(ERR, "Failed param key");
return PM3_EINVARG;
@ -1131,7 +1131,7 @@ static int CmdHFFelicaRequestSpecificationVersion(const char *Cmd) {
} else {
felica_request_spec_response_t spec_response;
memcpy(&spec_response, (felica_request_spec_response_t *)resp.data.asBytes, sizeof(felica_request_spec_response_t));
if (spec_response.frame_response.IDm[0] != 0) {
PrintAndLogEx(SUCCESS, "\nGot Request Response:");
PrintAndLogEx(SUCCESS, "\nIDm: %s", sprint_hex(spec_response.frame_response.IDm, sizeof(spec_response.frame_response.IDm)));
@ -1336,12 +1336,12 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
if (!all_nodes) {
// Node Number
if (param_getlength(Cmd, paramCount) == 2) {
if (param_gethex(Cmd, paramCount++, data + 10, 2) == 1) {
PrintAndLogEx(ERR, "Failed param key");
return PM3_EINVARG;
}
} else {
PrintAndLogEx(ERR, "Incorrect Node number length!");
return PM3_EINVARG;
@ -1349,7 +1349,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
}
if (param_getlength(Cmd, paramCount) == 4) {
if (param_gethex(Cmd, paramCount++, data + 11, 4) == 1) {
PrintAndLogEx(ERR, "Failed param key");
return PM3_EINVARG;
@ -1372,7 +1372,7 @@ static int CmdHFFelicaRequestService(const char *Cmd) {
if (!custom_IDm && !check_last_idm(data, datalen)) {
return PM3_EINVARG;
}
data[0] = int_to_hex(&datalen);
data[1] = 0x02; // Service Request Command ID
if (all_nodes) {
@ -1435,12 +1435,12 @@ static int CmdHFFelicaSniff(const char *Cmd) {
}
i++;
}
if (samples2skip == 0) {
samples2skip = 10;
PrintAndLogEx(INFO, "Set default samples2skip: %" PRIu64, samples2skip);
}
if (triggers2skip == 0) {
triggers2skip = 5000;
PrintAndLogEx(INFO, "Set default triggers2skip: %" PRIu64, triggers2skip);

View file

@ -68,27 +68,28 @@ static int usage_lf_cmdread(void) {
PrintAndLogEx(NORMAL, " c <cmd> Command bytes (in ones and zeros)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, " ************* " _YELLOW_("All periods in microseconds (us)"));
PrintAndLogEx(NORMAL, " ************* Use " _YELLOW_("'lf config'") "to configure options.");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf cmdread d 80 z 100 o 200 c 11000");
PrintAndLogEx(NORMAL, "Extras:");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")"to set parameters.");
return PM3_SUCCESS;
}
static int usage_lf_read(void) {
PrintAndLogEx(NORMAL, "Usage: lf read [h] [s] [d numofsamples]");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
PrintAndLogEx(NORMAL, " s silent run, no printout");
PrintAndLogEx(NORMAL, " d #samples # samples to collect (optional)");
PrintAndLogEx(NORMAL, "Use 'lf config' to set parameters.");
PrintAndLogEx(NORMAL, " s silent");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf read s d 12000 - collects 12000samples silent");
PrintAndLogEx(NORMAL, " lf read s");
PrintAndLogEx(NORMAL, " lf read s d 12000 - collects 12000 samples silent");
PrintAndLogEx(NORMAL, " lf read");
PrintAndLogEx(NORMAL, "Extras:");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")"to set parameters.");
return PM3_SUCCESS;
}
static int usage_lf_sim(void) {
PrintAndLogEx(NORMAL, "Simulate low frequence tag from graphbuffer.");
PrintAndLogEx(NORMAL, "Use " _YELLOW_("'lf config'")" to set parameters.");
PrintAndLogEx(NORMAL, "Usage: lf sim [h] <gap>");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
@ -96,16 +97,19 @@ static int usage_lf_sim(void) {
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf sim 240 - start simulating with 240ms gap");
PrintAndLogEx(NORMAL, " lf sim");
PrintAndLogEx(NORMAL, "Extras:");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")"to set parameters.");
return PM3_SUCCESS;
}
static int usage_lf_sniff(void) {
PrintAndLogEx(NORMAL, "Sniff low frequence signal.");
PrintAndLogEx(NORMAL, "Use " _YELLOW_("'lf config'")" to set parameters.");
PrintAndLogEx(NORMAL, "Use " _YELLOW_("'data samples'")" command to download from device, and " _YELLOW_("'data plot'")" to look at it");
PrintAndLogEx(NORMAL, "Usage: lf sniff [h]");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h This help");
PrintAndLogEx(NORMAL, "Extras:");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'lf config'")"to set parameters.");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'data samples'")"command to download from device");
PrintAndLogEx(NORMAL, " use " _YELLOW_("'data plot'")"to look at it");
return PM3_SUCCESS;
}
static int usage_lf_config(void) {
@ -117,22 +121,17 @@ static int usage_lf_config(void) {
PrintAndLogEx(NORMAL, " q <divisor> Manually set freq divisor. %d -> 134 kHz, %d -> 125 kHz", LF_DIVISOR_134, LF_DIVISOR_125);
PrintAndLogEx(NORMAL, " f <freq> Manually set frequency in kHz");
PrintAndLogEx(NORMAL, " b <bps> Sets resolution of bits per sample. Default (max): 8");
PrintAndLogEx(NORMAL, " d <decim> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
PrintAndLogEx(NORMAL, " d <decimate> Sets decimation. A value of N saves only 1 in N samples. Default: 1");
PrintAndLogEx(NORMAL, " a [0|1] Averaging - if set, will average the stored sample value when decimating. Default: 1");
PrintAndLogEx(NORMAL, " t <threshold> Sets trigger threshold. 0 means no threshold (range: 0-128)");
PrintAndLogEx(NORMAL, " s <samplestoskip> Sets a number of samples to skip before capture. Default: 0");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf config");
PrintAndLogEx(NORMAL, " Shows current config");
PrintAndLogEx(NORMAL, " lf config b 8 L");
PrintAndLogEx(NORMAL, " Samples at 125 kHz, 8bps.");
PrintAndLogEx(NORMAL, " lf config H b 4 d 3");
PrintAndLogEx(NORMAL, " Samples at 134 kHz, averages three samples into one, stored with ");
PrintAndLogEx(NORMAL, " a resolution of 4 bits per sample.");
PrintAndLogEx(NORMAL, " lf read");
PrintAndLogEx(NORMAL, " Performs a read (active field)");
PrintAndLogEx(NORMAL, " lf sniff");
PrintAndLogEx(NORMAL, " Performs a sniff (no active field)");
PrintAndLogEx(NORMAL, " lf config - shows current config");
PrintAndLogEx(NORMAL, " lf config b 8 L - samples at 125 kHz, 8bps.");
PrintAndLogEx(NORMAL, " lf config H b 4 d 3 - samples at 134 kHz, averages three samples into one, stored with ");
PrintAndLogEx(NORMAL, " a resolution of 4 bits per sample.");
PrintAndLogEx(NORMAL, " lf read - performs a read (active field)");
PrintAndLogEx(NORMAL, " lf sniff - performs a sniff (no active field)");
return PM3_SUCCESS;
}
static int usage_lf_simfsk(void) {
@ -367,7 +366,7 @@ int CmdLFCommandRead(const char *Cmd) {
if (resp.status == PM3_SUCCESS) {
if (i) {
PrintAndLogEx(SUCCESS, "Downloading response signal data");
getSamples(0, true);
getSamples(0, false);
return PM3_SUCCESS;
} else {
PrintAndLogEx(WARNING, "timeout while waiting for reply.");
@ -457,7 +456,11 @@ int lf_config(sample_config *config) {
if (!session.pm3_present) return PM3_ENOTTY;
clearCommandBuffer();
SendCommandNG(CMD_LF_SAMPLING_SET_CONFIG, (uint8_t *)config, sizeof(sample_config));
if (config != NULL)
SendCommandNG(CMD_LF_SAMPLING_SET_CONFIG, (uint8_t *)config, sizeof(sample_config));
else
SendCommandNG(CMD_LF_SAMPLING_GET_CONFIG, NULL, 0);
return PM3_SUCCESS;
}
@ -465,15 +468,22 @@ int CmdLFConfig(const char *Cmd) {
if (!session.pm3_present) return PM3_ENOTTY;
uint8_t divisor = 0;//Frequency divisor
uint8_t bps = 0; // Bits per sample
uint8_t decimation = 0; //How many to keep
bool averaging = 1; // Defaults to true
bool errors = false;
int trigger_threshold = -1;//Means no change
uint8_t unsigned_trigg = 0;
uint32_t samples_to_skip = 0; // will return offset to 0 if not supplied. Could set to 0xffffffff if needed to not update
// if called with no params, just print the device config
if (strlen(Cmd) == 0) {
return lf_config(NULL);
}
sample_config config = {
.decimation = -1,
.bits_per_sample = -1,
.averaging = -1,
.divisor = -1,
.trigger_threshold = -1,
.samples_to_skip = -1,
.verbose = true
};
bool errors = false;
uint8_t cmdp = 0;
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
@ -481,16 +491,16 @@ int CmdLFConfig(const char *Cmd) {
case 'h':
return usage_lf_config();
case 'H':
divisor = LF_DIVISOR_134;
config.divisor = LF_DIVISOR_134;
cmdp++;
break;
case 'L':
divisor = LF_DIVISOR_125;
config.divisor = LF_DIVISOR_125;
cmdp++;
break;
case 'q':
errors |= param_getdec(Cmd, cmdp + 1, &divisor);
if (divisor < 19) {
config.divisor = param_get8ex(Cmd, cmdp + 1, 95, 10);
if (config.divisor < 19) {
PrintAndLogEx(ERR, "divisor must be between 19 and 255");
return PM3_EINVARG;
}
@ -498,36 +508,50 @@ int CmdLFConfig(const char *Cmd) {
break;
case 'f': {
int freq = param_get32ex(Cmd, cmdp + 1, 125, 10);
divisor = LF_FREQ2DIV(freq);
if (divisor < 19) {
config.divisor = LF_FREQ2DIV(freq);
if (config.divisor < 19) {
PrintAndLogEx(ERR, "freq must be between 47 and 600");
return PM3_EINVARG;
}
cmdp += 2;
break;
}
case 't':
errors |= param_getdec(Cmd, cmdp + 1, &unsigned_trigg);
case 't': {
uint8_t trigg = 0;
errors |= param_getdec(Cmd, cmdp + 1, &trigg);
cmdp += 2;
if (!errors) {
trigger_threshold = unsigned_trigg;
g_lf_threshold_set = (trigger_threshold > 0);
config.trigger_threshold = trigg;
g_lf_threshold_set = (config.trigger_threshold > 0);
}
break;
case 'b':
errors |= param_getdec(Cmd, cmdp + 1, &bps);
}
case 'b': {
config.bits_per_sample = param_get8ex(Cmd, cmdp + 1, 8, 10);
// bps is limited to 8
if (config.bits_per_sample >> 4)
config.bits_per_sample = 8;
cmdp += 2;
break;
case 'd':
errors |= param_getdec(Cmd, cmdp + 1, &decimation);
}
case 'd': {
config.decimation = param_get8ex(Cmd, cmdp + 1, 1, 10);
// decimation is limited to 255
if (config.decimation >> 4)
config.decimation = 8;
cmdp += 2;
break;
}
case 'a':
averaging = param_getchar(Cmd, cmdp + 1) == '1';
config.averaging = (param_getchar(Cmd, cmdp + 1) == '1');
cmdp += 2;
break;
case 's':
samples_to_skip = param_get32ex(Cmd, cmdp + 1, 0, 10);
config.samples_to_skip = param_get32ex(Cmd, cmdp + 1, 0, 10);
cmdp += 2;
break;
default:
@ -540,28 +564,19 @@ int CmdLFConfig(const char *Cmd) {
// validations
if (errors) return usage_lf_config();
// print current settings.
if (cmdp == 0)
return lf_config(NULL);
// bps is limited to 8
if (bps >> 4) bps = 8;
sample_config config = { decimation, bps, averaging, divisor, trigger_threshold, samples_to_skip, true };
return lf_config(&config);
}
int lf_read(bool silent, uint32_t samples) {
int lf_read(bool verbose, uint32_t samples) {
if (!session.pm3_present) return PM3_ENOTTY;
struct p {
uint8_t silent;
uint8_t verbose;
uint32_t samples;
} PACKED;
struct p payload;
payload.silent = silent;
payload.verbose = verbose;
payload.samples = samples;
clearCommandBuffer();
@ -579,7 +594,7 @@ int lf_read(bool silent, uint32_t samples) {
// resp.oldarg[0] is bits read not bytes read.
uint32_t bits = (resp.data.asDwords[0] / 8);
getSamples(bits, silent);
getSamples(bits, verbose);
return PM3_SUCCESS;
}
@ -589,21 +604,21 @@ int CmdLFRead(const char *Cmd) {
if (!session.pm3_present) return PM3_ENOTTY;
bool errors = false;
bool silent = false;
bool verbose = true;
uint32_t samples = 0;
uint8_t cmdp = 0;
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
switch (tolower(param_getchar(Cmd, cmdp))) {
case 'h':
return usage_lf_read();
case 's':
silent = true;
cmdp++;
break;
case 'd':
samples = param_get32ex(Cmd, cmdp + 1, 0, 10);
cmdp += 2;
break;
case 's':
verbose = false;
cmdp++;
break;
default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
errors = true;
@ -614,7 +629,7 @@ int CmdLFRead(const char *Cmd) {
//Validations
if (errors) return usage_lf_read();
return lf_read(silent, samples);
return lf_read(verbose, samples);
}
int CmdLFSniff(const char *Cmd) {
@ -627,7 +642,7 @@ int CmdLFSniff(const char *Cmd) {
clearCommandBuffer();
SendCommandNG(CMD_LF_SNIFF_RAW_ADC, NULL, 0);
WaitForResponse(CMD_ACK, NULL);
getSamples(0, false);
getSamples(0, true);
return PM3_SUCCESS;
}
@ -1183,7 +1198,7 @@ int CmdLFfind(const char *Cmd) {
bool isOnline = (session.pm3_present && (cmdp != '1'));
if (isOnline)
lf_read(true, 30000);
lf_read(false, 30000);
if (GraphTraceLen < minLength) {
PrintAndLogEx(FAILED, "Data in Graphbuffer was too small.");
@ -1334,13 +1349,14 @@ static command_t CommandTable[] = {
{"visa2000", CmdLFVisa2k, AlwaysAvailable, "{ Visa2000 RFIDs... }"},
{"", CmdHelp, AlwaysAvailable, ""},
{"config", CmdLFConfig, IfPm3Lf, "Get/Set config for LF sampling, bit/sample, decimation, frequency"},
{"cmdread", CmdLFCommandRead, IfPm3Lf, "<off period> <'0' period> <'1' period> <command> ['h' 134] \n\t\t-- Modulate LF reader field to send command before read (all periods in microseconds)"},
{"read", CmdLFRead, IfPm3Lf, "['s' silent] Read 125/134 kHz LF ID-only tag. Do 'lf read h' for help"},
{"search", CmdLFfind, AlwaysAvailable, "[offline] ['u'] Read and Search for valid known tag (in offline mode it you can load first then search) \n\t\t-- 'u' to search for unknown tags"},
{"sim", CmdLFSim, IfPm3Lf, "[GAP] -- Simulate LF tag from buffer with optional GAP (in microseconds)"},
{"simask", CmdLFaskSim, IfPm3Lf, "[clock] [invert <1|0>] [biphase/manchester/raw <'b'|'m'|'r'>] [msg separator 's'] [d <hexdata>] \n\t\t-- Simulate LF ASK tag from demodbuffer or input"},
{"simfsk", CmdLFfskSim, IfPm3Lf, "[c <clock>] [i] [H <fcHigh>] [L <fcLow>] [d <hexdata>] \n\t\t-- Simulate LF FSK tag from demodbuffer or input"},
{"simpsk", CmdLFpskSim, IfPm3Lf, "[1|2|3] [c <clock>] [i] [r <carrier>] [d <raw hex to sim>] \n\t\t-- Simulate LF PSK tag from demodbuffer or input"},
{"cmdread", CmdLFCommandRead, IfPm3Lf, "Modulate LF reader field to send command before read (all periods in microseconds)"},
{"read", CmdLFRead, IfPm3Lf, "Read LF tag"},
{"search", CmdLFfind, AlwaysAvailable, "Read and Search for valid known tag (in offline mode it you can load first then search)"},
{"sim", CmdLFSim, IfPm3Lf, "Simulate LF tag from buffer with optional GAP (in microseconds)"},
{"simask", CmdLFaskSim, IfPm3Lf, "Simulate LF ASK tag from demodbuffer or input"},
{"simfsk", CmdLFfskSim, IfPm3Lf, "Simulate LF FSK tag from demodbuffer or input"},
{"simpsk", CmdLFpskSim, IfPm3Lf, "Simulate LF PSK tag from demodbuffer or input"},
// {"simpsk", CmdLFnrzSim, IfPm3Lf, "Simulate LF NRZ tag from demodbuffer or input"},
{"simbidir", CmdLFSimBidir, IfPm3Lf, "Simulate LF tag (with bidirectional data transmission between reader and tag)"},
{"sniff", CmdLFSniff, IfPm3Lf, "Sniff LF traffic between reader and tag"},
{"tune", CmdLFTune, IfPm3Lf, "Continuously measure LF antenna tuning"},

View file

@ -32,7 +32,7 @@ int CmdLFSniff(const char *Cmd);
int CmdVchDemod(const char *Cmd);
int CmdLFfind(const char *Cmd);
int lf_read(bool silent, uint32_t samples);
int lf_read(bool verbose, uint32_t samples);
int lf_config(sample_config *config);
#endif

View file

@ -333,7 +333,7 @@ static int CmdAWIDDemod(const char *Cmd) {
// this read is the "normal" read, which download lf signal and tries to demod here.
static int CmdAWIDRead(const char *Cmd) {
lf_read(true, 12000);
lf_read(false, 12000);
return CmdAWIDDemod(Cmd);
}

View file

@ -96,7 +96,7 @@ static int CmdCOTAGRead(const char *Cmd) {
case 2: {
CmdPlot("");
CmdGrid("384");
getSamples(0, true);
getSamples(0, false);
break;
}
case 1: {

View file

@ -258,7 +258,7 @@ static int CmdFdxDemod(const char *Cmd) {
}
static int CmdFdxRead(const char *Cmd) {
lf_read(true, 10000);
lf_read(false, 10000);
return CmdFdxDemod(Cmd);
}

View file

@ -135,7 +135,7 @@ static int CmdGallagherDemod(const char *Cmd) {
}
static int CmdGallagherRead(const char *Cmd) {
lf_read(true, 4096 * 2 + 20);
lf_read(false, 4096 * 2 + 20);
return CmdGallagherDemod(Cmd);
}

View file

@ -147,7 +147,7 @@ static int CmdGuardDemod(const char *Cmd) {
}
static int CmdGuardRead(const char *Cmd) {
lf_read(true, 10000);
lf_read(false, 10000);
return CmdGuardDemod(Cmd);
}

View file

@ -255,7 +255,7 @@ static int CmdHIDDemod(const char *Cmd) {
// this read is the "normal" read, which download lf signal and tries to demod here.
static int CmdHIDRead(const char *Cmd) {
lf_read(true, 12000);
lf_read(false, 12000);
return CmdHIDDemod(Cmd);
}

View file

@ -58,16 +58,91 @@ static int usage_lf_indala_sim(void) {
PrintAndLogEx(NORMAL, "Enables simulation of Indala card with specified uid.");
PrintAndLogEx(NORMAL, "Simulation runs until the button is pressed or another USB command is issued.");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Usage: lf indala sim [h] <uid>");
PrintAndLogEx(NORMAL, "Usage: lf indala sim [h] <u uid> <c cardnum>");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : This help");
PrintAndLogEx(NORMAL, " <uid> : 64/224 UID");
PrintAndLogEx(NORMAL, " h : This help");
PrintAndLogEx(NORMAL, " u <uid> : 64/224 UID");
PrintAndLogEx(NORMAL, " c <cardnum> : Cardnumber for Heden 2L format (decimal)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf indala sim deadc0de");
return PM3_SUCCESS;
}
#define HEDEN2L_OFFSET 31
static void encodeHeden2L(uint8_t *dest, uint32_t cardnumber) {
uint8_t template[] = {
1,0,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,0,0,0,1,0,0,0,
1,0,0,0,0,0,0,0,
0,0,0,0,1,0,0,1,
0,0,0,0,0,0,1,0
};
uint8_t cardbits[32];
num_to_bytebits(cardnumber, sizeof(cardbits), cardbits);
if (cardbits[31] == 1) template[HEDEN2L_OFFSET + 8] = 0x1;
if (cardbits[30] == 1) template[HEDEN2L_OFFSET + 10] = 0x1;
if (cardbits[29] == 1) template[HEDEN2L_OFFSET + 14] = 0x1;
if (cardbits[28] == 1) template[HEDEN2L_OFFSET + 15] = 0x1;
if (cardbits[27] == 1) template[HEDEN2L_OFFSET + 12] = 0x1;
if (cardbits[26] == 1) template[HEDEN2L_OFFSET + 28] = 0x1;
if (cardbits[25] == 1) template[HEDEN2L_OFFSET + 3] = 0x1;
if (cardbits[24] == 1) template[HEDEN2L_OFFSET + 11] = 0x1;
if (cardbits[23] == 1) template[HEDEN2L_OFFSET + 19] = 0x1;
if (cardbits[22] == 1) template[HEDEN2L_OFFSET + 26] = 0x1;
if (cardbits[21] == 1) template[HEDEN2L_OFFSET + 17] = 0x1;
if (cardbits[20] == 1) template[HEDEN2L_OFFSET + 18] = 0x1;
if (cardbits[19] == 1) template[HEDEN2L_OFFSET + 20] = 0x1;
if (cardbits[18] == 1) template[HEDEN2L_OFFSET + 13] = 0x1;
if (cardbits[17] == 1) template[HEDEN2L_OFFSET + 7] = 0x1;
if (cardbits[16] == 1) template[HEDEN2L_OFFSET + 23] = 0x1;
// Parity
uint8_t counter = 0;
for (int i=0; i< sizeof(template) - HEDEN2L_OFFSET; i++) {
if (template[i])
counter++;
}
template[63] = (counter & 0x1);
for (int i = 0; i< sizeof(template); i += 8) {
dest[i/8] = bytebits_to_byte(template + i, 8);
}
PrintAndLogEx(INFO, "Heden-2L card number %u", cardnumber);
}
static void decodeHeden2L(uint8_t *bits) {
uint32_t cardnumber = 0;
uint8_t offset = HEDEN2L_OFFSET;
if ( bits[offset + 8] ) cardnumber += 1;
if ( bits[offset + 10] ) cardnumber += 2;
if ( bits[offset + 14] ) cardnumber += 4;
if ( bits[offset + 15] ) cardnumber += 8;
if ( bits[offset + 12] ) cardnumber += 16;
if ( bits[offset + 28] ) cardnumber += 32;
if ( bits[offset + 3] ) cardnumber += 64;
if ( bits[offset + 11] ) cardnumber += 128;
if ( bits[offset + 19] ) cardnumber += 256;
if ( bits[offset + 26] ) cardnumber += 512;
if ( bits[offset + 17] ) cardnumber += 1024;
if ( bits[offset + 18] ) cardnumber += 2048;
if ( bits[offset + 20] ) cardnumber += 4096;
if ( bits[offset + 13] ) cardnumber += 8192;
if ( bits[offset + 7] ) cardnumber += 16384;
if ( bits[offset + 23] ) cardnumber += 32768;
PrintAndLogEx(SUCCESS, "\tHeden-2L | %u", cardnumber);
}
// Indala 26 bit decode
// by marshmellow, martinbeier
// optional arguments - same as PSKDemod (clock & invert & maxerr)
@ -172,8 +247,11 @@ static int CmdIndalaDemod(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Possible de-scramble patterns");
PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", p1, p1);
PrintAndLogEx(SUCCESS, "\tInternal ID | %" PRIu64, foo);
decodeHeden2L(DemodBuffer);
PrintAndLogEx(SUCCESS, "Fmt 26 bit FC %u , CSN %u , checksum %1d%1d", fc, csn, checksum >> 1 & 0x01, checksum & 0x01);
} else {
uint32_t uid3 = bytebits_to_byte(DemodBuffer + 64, 32);
uint32_t uid4 = bytebits_to_byte(DemodBuffer + 96, 32);
@ -405,7 +483,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
// this read is the "normal" read, which download lf signal and tries to demod here.
static int CmdIndalaRead(const char *Cmd) {
lf_read(true, 30000);
lf_read(false, 30000);
return CmdIndalaDemod(Cmd);
}
@ -464,49 +542,55 @@ static int CmdIndalaSim(const char *Cmd) {
static int CmdIndalaClone(const char *Cmd) {
bool isLongUid = false;
bool is_long_uid = false, got_cn = false;
bool is_t5555 = false;
int32_t cardnumber;
uint32_t blocks[8] = {0};
uint8_t max = 0;
uint8_t data[7 * 4];
int datalen = 0;
CLIParserInit("lf indala clone",
"Enables cloning of Indala card with specified uid onto T55x7\n"
"defaults to 64.\n",
"\n"
"Samples:\n"
"\tlf indala clone a0000000a0002021\n"
"\tlf indala clone -l 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5");
"clone INDALA tag to T55x7 (or to q5/T5555)",
"Examples:\n"
"\tlf indala clone -c 888\n"
"\tlf indala clone -r a0000000a0002021\n"
"\tlf indala clone -l -r 80000001b23523a6c2e31eba3cbee4afb3c6ad1fcf649393928c14e5");
void *argtable[] = {
arg_param_begin,
arg_lit0("lL", "long", "long UID 224 bits"),
arg_strx1(NULL, NULL, "<uid (hex)>", NULL),
arg_lit0("lL", "long", "optional - long UID 224 bits"),
arg_int0("cC", "cn", "<decimal>", "Cardnumber for Heden 2L format"),
arg_strx0("rR", "raw", "<hex>", "raw bytes"),
arg_lit0("qQ", "Q5", "optional - specify write to Q5 (t5555 instead of t55x7)"),
arg_param_end
};
CLIExecWithReturn(Cmd, argtable, false);
isLongUid = arg_get_lit(1);
CLIGetHexWithReturn(2, data, &datalen);
is_long_uid = arg_get_lit(1);
if (is_long_uid == false) {
cardnumber = arg_get_int_def(2, -1);
got_cn = (cardnumber != -1);
}
if (got_cn == false) {
CLIGetHexWithReturn(3, data, &datalen);
}
is_t5555 = arg_get_lit(4);
CLIParserFree();
/*
//TODO add selection of chip for Q5 or T55x7
// data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK2 | 7 << T5555_MAXBLOCK_SHIFT;
//Alternative config for Indala (Extended mode;RF/32;PSK1 with RF/2;Maxblock=7;Inverse data)
// T5567WriteBlock(0x603E10E2,0);
// data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK1 | 2 << T5555_MAXBLOCK_SHIFT;
//Alternative config for Indala (Extended mode;RF/32;PSK1 with RF/2;Maxblock=2;Inverse data)
// T5567WriteBlock(0x603E1042,0);
*/
if (isLongUid) {
if (is_long_uid) {
// 224 BIT UID
// config for Indala (RF/32;PSK2 with RF/2;Maxblock=7)
PrintAndLogEx(INFO, "Preparing to clone Indala 224bit tag with RawID %s", sprint_hex(data, datalen));
blocks[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK2 | (7 << T55x7_MAXBLOCK_SHIFT);
if (is_t5555)
blocks[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_PSK2 | (7 << T5555_MAXBLOCK_SHIFT);
else
blocks[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK2 | (7 << T55x7_MAXBLOCK_SHIFT);
blocks[1] = bytes_to_num(data, 4);
blocks[2] = bytes_to_num(data + 4, 4);
blocks[3] = bytes_to_num(data + 8, 4);
@ -516,16 +600,26 @@ static int CmdIndalaClone(const char *Cmd) {
blocks[7] = bytes_to_num(data + 24, 4);
max = 8;
} else {
// 64 BIT UID
if (got_cn) {
encodeHeden2L(data, cardnumber);
datalen = 8;
}
// config for Indala 64 format (RF/32;PSK1 with RF/2;Maxblock=2)
PrintAndLogEx(INFO, "Preparing to clone Indala 64bit tag with RawID %s", sprint_hex(data, datalen));
blocks[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK1 | (2 << T55x7_MAXBLOCK_SHIFT);
if (is_t5555)
blocks[0] = T5555_SET_BITRATE(32) | T5555_MODULATION_PSK1 | (2 << T5555_MAXBLOCK_SHIFT);
else
blocks[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK1 | (2 << T55x7_MAXBLOCK_SHIFT);
blocks[1] = bytes_to_num(data, 4);
blocks[2] = bytes_to_num(data + 4, 4);
max = 3;
}
print_blocks(blocks, max);
return clone_t55xx_tag(blocks, max);
}

View file

@ -47,9 +47,9 @@ static int usage_lf_io_sim(void) {
PrintAndLogEx(NORMAL, "Usage: lf io sim [h] <version> <facility-code> <card-number>");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : This help");
PrintAndLogEx(NORMAL, " <version> : 8bit version");
PrintAndLogEx(NORMAL, " <facility-code> : 8bit value facility code");
PrintAndLogEx(NORMAL, " <card number> : 16bit value card number");
PrintAndLogEx(NORMAL, " <version> : 8bit version (decimal)");
PrintAndLogEx(NORMAL, " <facility-code> : 8bit value facility code (hex)");
PrintAndLogEx(NORMAL, " <card number> : 16bit value card number (decimal)");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf io sim 26 101 1337");
@ -63,9 +63,9 @@ static int usage_lf_io_clone(void) {
PrintAndLogEx(NORMAL, "Usage: lf io clone [h] <version> <facility-code> <card-number> [Q5]");
PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : This help");
PrintAndLogEx(NORMAL, " <version> : 8bit version");
PrintAndLogEx(NORMAL, " <facility-code> : 8bit value facility code");
PrintAndLogEx(NORMAL, " <card number> : 16bit value card number");
PrintAndLogEx(NORMAL, " <version> : 8bit version (decimal)");
PrintAndLogEx(NORMAL, " <facility-code> : 8bit value facility code (hex)");
PrintAndLogEx(NORMAL, " <card number> : 16bit value card number (decimal)");
PrintAndLogEx(NORMAL, " Q5 : optional - clone to Q5 (T5555) instead of T55x7 chip");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
@ -184,7 +184,7 @@ static int CmdIOProxDemod(const char *Cmd) {
// this read is the "normal" read, which download lf signal and tries to demod here.
static int CmdIOProxRead(const char *Cmd) {
lf_read(true, 12000);
lf_read(false, 12000);
return CmdIOProxDemod(Cmd);
}
static int CmdIOProxSim(const char *Cmd) {
@ -197,7 +197,7 @@ static int CmdIOProxSim(const char *Cmd) {
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_io_sim();
version = param_get8(Cmd, 0);
fc = param_get8(Cmd, 1);
fc = param_get8ex(Cmd, 1, 0, 16);
cn = param_get32ex(Cmd, 2, 0, 10);
if (!version || !fc || !cn) return usage_lf_io_sim();
@ -249,7 +249,7 @@ static int CmdIOProxClone(const char *Cmd) {
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_io_clone();
version = param_get8(Cmd, 0);
fc = param_get8(Cmd, 1);
fc = param_get8ex(Cmd, 1, 0, 16);
cn = param_get32ex(Cmd, 2, 0, 10);
if (!version || !fc || !cn) return usage_lf_io_clone();

View file

@ -115,7 +115,7 @@ static int CmdKeriDemod(const char *Cmd) {
}
static int CmdKeriRead(const char *Cmd) {
lf_read(true, 10000);
lf_read(false, 10000);
return CmdKeriDemod(Cmd);
}

View file

@ -124,8 +124,8 @@ static int CmdMotorolaRead(const char *Cmd) {
// Motorola Flexpass seem to work at 74 kHz
// and take about 4400 samples to befor modulating
sample_config sc = {
.decimation = 0,
.bits_per_sample = 0,
.decimation = -1,
.bits_per_sample = -1,
.averaging = false,
.divisor = LF_FREQ2DIV(74),
.trigger_threshold = -1,
@ -135,7 +135,7 @@ static int CmdMotorolaRead(const char *Cmd) {
lf_config(&sc);
// 64 * 32 * 2 * n-ish
lf_read(true, 5000);
lf_read(false, 5000);
// reset back to 125 kHz
sc.divisor = LF_DIVISOR_125;

View file

@ -299,7 +299,7 @@ lf t55xx wr b 4 d 4c0003ff
*/
static int CmdLFNedapRead(const char *Cmd) {
lf_read(true, 16000);
lf_read(false, 16000);
return CmdLFNedapDemod(Cmd);
}

View file

@ -133,7 +133,7 @@ static int CmdNoralsyDemod(const char *Cmd) {
}
static int CmdNoralsyRead(const char *Cmd) {
lf_read(true, 8000);
lf_read(false, 8000);
return CmdNoralsyDemod(Cmd);
}

View file

@ -51,7 +51,7 @@ static int usage_lf_pac_sim(void) {
PrintAndLogEx(NORMAL, " <Card ID> : 8 byte PAC/Stanley card id");
PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf pac sim 1A337");
PrintAndLogEx(NORMAL, " lf pac sim 12345678");
return PM3_SUCCESS;
}
// by danshuk
@ -181,7 +181,7 @@ static int CmdPacDemod(const char *Cmd) {
}
static int CmdPacRead(const char *Cmd) {
lf_read(true, 4096 * 2 + 20);
lf_read(false, 4096 * 2 + 20);
return CmdPacDemod(Cmd);
}
@ -245,20 +245,23 @@ static int CmdPacClone(const char *Cmd) {
static int CmdPacSim(const char *Cmd) {
// NRZ sim.
uint32_t id = 0;
uint64_t rawID = 0;
char cardid[9] = { 0 };
uint8_t rawBytes[16] = { 0 };
uint32_t rawBlocks[4];
char cmdp = tolower(param_getchar(Cmd, 0));
if (strlen(Cmd) == 0 || cmdp == 'h') return usage_lf_pac_sim();
id = param_get32ex(Cmd, 0, 0, 16);
if (id == 0) return usage_lf_pac_sim();
//rawID = pacCardIdToRaw(id);
PrintAndLogEx(SUCCESS, "Simulating PAC/Stanley - ID " _YELLOW_("%08X")" raw "_YELLOW_("%08X%08X"), id, (uint32_t)(rawID >> 32), (uint32_t)(rawID & 0xFFFFFFFF));
int res = param_getstr(Cmd, 0, cardid, sizeof(cardid));
if (res < 8) return usage_lf_pac_sim();
uint8_t bs[128];
num_to_bytebits(rawID, sizeof(bs), bs);
pacCardIdToRaw(rawBytes, cardid);
for (size_t i = 0; i < ARRAYLEN(rawBlocks); i++) {
rawBlocks[i] = bytes_to_num(rawBytes + (i * sizeof(uint32_t)), sizeof(uint32_t));
num_to_bytebits(rawBlocks[i], sizeof(uint32_t) * 8, bs + (i * sizeof(uint32_t) * 8));
}
PrintAndLogEx(SUCCESS, "Simulating PAC/Stanley - ID " _YELLOW_("%s")" raw "_YELLOW_("%08X%08X%08X%08X"), cardid, rawBlocks[0], rawBlocks[1], rawBlocks[2], rawBlocks[3]);
lf_nrzsim_t *payload = calloc(1, sizeof(lf_nrzsim_t) + sizeof(bs));
payload->invert = 0;

View file

@ -126,7 +126,7 @@ static int CmdParadoxDemod(const char *Cmd) {
//by marshmellow
//see ASKDemod for what args are accepted
static int CmdParadoxRead(const char *Cmd) {
lf_read(true, 10000);
lf_read(false, 10000);
return CmdParadoxDemod(Cmd);
}

View file

@ -100,7 +100,7 @@ static int CmdPrescoDemod(const char *Cmd) {
//see ASKDemod for what args are accepted
static int CmdPrescoRead(const char *Cmd) {
// Presco Number: 123456789 --> Sitecode 30 | usercode 8665
lf_read(true, 12000);
lf_read(false, 12000);
return CmdPrescoDemod(Cmd);
}

View file

@ -209,7 +209,7 @@ static int CmdPyramidDemod(const char *Cmd) {
}
static int CmdPyramidRead(const char *Cmd) {
lf_read(true, 15000);
lf_read(false, 15000);
return CmdPyramidDemod(Cmd);
}

View file

@ -125,7 +125,7 @@ static int CmdSecurakeyDemod(const char *Cmd) {
}
static int CmdSecurakeyRead(const char *Cmd) {
lf_read(true, 8000);
lf_read(false, 8000);
return CmdSecurakeyDemod(Cmd);
}

View file

@ -2528,7 +2528,7 @@ bool AcquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password, u
return false;
}
getSamples(12000, true);
getSamples(12000, false);
return !getSignalProperties()->isnoise;
}
@ -3485,7 +3485,7 @@ static int CmdT55xxDetectPage1(const char *Cmd) {
found = AcquireData(T55x7_PAGE1, T55x7_TRACE_BLOCK1, usepwd, password, dl_mode);
if (found == false)
continue;
if (tryDetectP1(false)) {
found = true;
found_mode = dl_mode;

View file

@ -79,7 +79,7 @@ static int CmdVikingDemod(const char *Cmd) {
//by marshmellow
//see ASKDemod for what args are accepted
static int CmdVikingRead(const char *Cmd) {
lf_read(true, 10000);
lf_read(false, 10000);
return CmdVikingDemod(Cmd);
}

View file

@ -159,7 +159,7 @@ static int CmdVisa2kDemod(const char *Cmd) {
// 64*96*2=12288 samples just in case we just missed the first preamble we can still catch 2 of them
static int CmdVisa2kRead(const char *Cmd) {
lf_read(true, 20000);
lf_read(false, 20000);
return CmdVisa2kDemod(Cmd);
}

View file

@ -94,7 +94,7 @@ static int CmdAuto(const char *Cmd) {
PrintAndLogEx(INFO, "Trying 'lf read' and save a trace for you...");
CmdPlot("");
lf_read(true, 40000);
lf_read(false, 40000);
char *fname = calloc(100, sizeof(uint8_t));
AppendDate(fname, 100, "f lf_unknown_%Y-%m-%d_%H:%M");
CmdSave(fname);

View file

@ -178,7 +178,7 @@ int CmdsParse(const command_t Commands[], const char *Cmd) {
char cmd_name[128];
memset(cmd_name, 0, sizeof(cmd_name));
int len = 0;
int len = 0;
// %n == receives an integer of value equal to the number of chars read so far.
// len = max 127
sscanf(Cmd, "%127s%n", cmd_name, &len);
@ -248,10 +248,10 @@ void dumpCommandsRecursive(const command_t cmds[], int markdown) {
}
while (cmds[i].Name) {
if ((cmds[i].Name[0] == '-' || strlen(cmds[i].Name) == 0) && ++i) continue;
if (cmds[i].Help[0] == '{' && ++i) continue;
const char *cmd_offline = "N";
if (cmds[i].IsAvailable())

View file

@ -1041,4 +1041,38 @@ bb2c0007d022 # Hotel Berlin Classic room B KEY
b62307b62307
#
a2a3cca2a3cc
#
# Granada, ES Transport Card
000000270000
0172066b2f03
0172066b2f33
066b2f230172
0b0172066b2f
0f385ffb6529
172066b2f2f0
2066b2f27017
29173860fc76
2f130172066b
2fca8492f386
385efa542907
3864fcba5937
3b0172066b2f
3f3865fccb69
5c8ff9990da2
6291b3860fc8
63fca9492f38
66b2f1f01720
6b2f1b017206
70172066b2f0
70172066b2f3
72066b2f2b01
863fcb959373
87291f3861fc
913385ffb752
b2f170172066
b385efa64290
c9739233861f
f0f0172066b2
f3864fcca693
f3f0172066b2
fc9839273862

View file

@ -136,7 +136,7 @@ static struct crypto_pk *crypto_pk_polarssl_open_priv_rsa(va_list vl) {
mbedtls_mpi_read_binary(&cp->ctx.Q, (const unsigned char *)q, qlen);
mbedtls_mpi_read_binary(&cp->ctx.DP, (const unsigned char *)dp, dplen);
mbedtls_mpi_read_binary(&cp->ctx.DQ, (const unsigned char *)dq, dqlen);
int res = mbedtls_mpi_inv_mod(&cp->ctx.QP, &cp->ctx.Q, &cp->ctx.P);
if (res != 0) {
fprintf(stderr, "PolarSSL private key error res=%x exp=%d mod=%d.\n", res * -1, explen, modlen);

View file

@ -490,7 +490,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
for (uint8_t ui = 0x01; ui <= 0x10; ui++) {
if (sfidatalen[ui]) {
struct tlvdb *tsfi_a = tlvdb_parse_multi(sfidata[ui], sfidatalen[ui]);
if (tsfi_a) {
struct tlvdb *tsfitmp = tlvdb_find_path(tsfi_a, (tlv_tag_t[]) {0x70, 0x61, 0x00});

View file

@ -204,7 +204,7 @@ int saveFileEML(const char *preferredName, uint8_t *data, size_t datalen, size_t
}
fflush(f);
fclose(f);
PrintAndLogEx(SUCCESS, "saved " _YELLOW_("%" PRId32 )" blocks to text file " _YELLOW_("%s"), blocks, fileName);
PrintAndLogEx(SUCCESS, "saved " _YELLOW_("%" PRId32)" blocks to text file " _YELLOW_("%s"), blocks, fileName);
out:
free(fileName);
@ -618,7 +618,7 @@ int loadFile_safe(const char *preferredName, const char *suffix, void **pdata, s
int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
if (data == NULL) return PM3_EINVARG;
char *fileName = filenamemcopy(preferredName, ".eml");
if (fileName == NULL) return PM3_EMALLOC;
@ -637,7 +637,7 @@ int loadFileEML(const char *preferredName, void *data, size_t *datalen) {
memset(line, 0, sizeof(line));
uint8_t buf[64] = {0x00};
uint8_t *udata = (uint8_t*)data;
uint8_t *udata = (uint8_t *)data;
while (!feof(f)) {
@ -861,15 +861,15 @@ int loadFileDICTIONARYEx(const char *preferredName, void *data, size_t maxdatale
}
if (startFilePosition) {
if (fseek(f, startFilePosition, SEEK_SET) < 0){
if (fseek(f, startFilePosition, SEEK_SET) < 0) {
fclose(f);
retval = PM3_EFILE;
goto out;
}
}
uint8_t *udata = (uint8_t*)data;
uint8_t *udata = (uint8_t *)data;
// read file
while (!feof(f)) {
size_t filepos = ftell(f);

View file

@ -75,9 +75,9 @@ local function dumptofile(uid, keys)
dbg('dumping keys to file')
if utils.confirm('Do you wish to save the keys to dumpfile?') then
local filename = ('hf-mf-%s-key.bin'):format(uid);
local destination = utils.input('Select a filename to store to', filename)
local file = io.open(destination, 'wb')
if file == nil then

View file

@ -137,19 +137,19 @@ static const bmp_t b40c[] = {
# else /* BMP_BIT */
static const bmp_t b40[] = {
BMP_C(0x00048200) << (BMP_BIT - 32) | BMP_C(0x04) >> (39 - BMP_BIT),
BMP_C(0x09) << (BMP_BIT * 2 - 40),
BMP_C(0x09) << (BMP_BIT * 2 - 40),
};
static const bmp_t b40a[] = {
BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT),
BMP_C(0xff) << (BMP_BIT * 2 - 40),
BMP_C(0xff) << (BMP_BIT * 2 - 40),
};
static const bmp_t b40b[] = {
BMP_C(0xd4164fc6) << (BMP_BIT - 32) | BMP_C(0x23) >> (39 - BMP_BIT),
BMP_C(0x46) << (BMP_BIT * 2 - 40),
BMP_C(0x46) << (BMP_BIT * 2 - 40),
};
static const bmp_t b40c[] = {
BMP_C(0xc4ff8071) << (BMP_BIT - 32) | BMP_C(0x7f) >> (39 - BMP_BIT),
BMP_C(0xff) << (BMP_BIT * 2 - 40),
BMP_C(0xff) << (BMP_BIT * 2 - 40),
};
# endif /* BMP_BIT */
@ -187,43 +187,43 @@ static const bmp_t b64i[] = {
# else /* BMP_BIT */
static const bmp_t b64[] = {
BMP_C(0x00000000) << (BMP_BIT - 32) | BMP_C(0x0000000d) >> (63 - BMP_BIT),
BMP_C(0x0000001b) << (BMP_BIT * 2 - 64),
BMP_C(0x0000001b) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64a[] = {
BMP_C(0xffffffff) << (BMP_BIT - 32) | BMP_C(0x7fffffff) >> (63 - BMP_BIT),
BMP_C(0xffffffff) << (BMP_BIT * 2 - 64),
BMP_C(0xffffffff) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64b[] = {
BMP_C(0xb90956c7) << (BMP_BIT - 32) | BMP_C(0x3ad20800) >> (63 - BMP_BIT),
BMP_C(0x75a41001) << (BMP_BIT * 2 - 64),
BMP_C(0x75a41001) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64c[] = {
BMP_C(0x53000000) << (BMP_BIT - 32) | BMP_C(0x00000000) >> (63 - BMP_BIT),
BMP_C(0x00000000) << (BMP_BIT * 2 - 64),
BMP_C(0x00000000) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64d[] = {
BMP_C(0x42f0e1eb) << (BMP_BIT - 32) | BMP_C(0x54f51b49) >> (63 - BMP_BIT),
BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64),
BMP_C(0xa9ea3693) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64e[] = {
BMP_C(0x6c40df5f) << (BMP_BIT - 32) | BMP_C(0x05a4b9a3) >> (63 - BMP_BIT),
BMP_C(0x0b497347) << (BMP_BIT * 2 - 64),
BMP_C(0x0b497347) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64f[] = {
BMP_C(0x62ec59e3) << (BMP_BIT - 32) | BMP_C(0x78d27805) >> (63 - BMP_BIT),
BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64),
BMP_C(0xf1a4f00a) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64g[] = {
BMP_C(0xfcacbebd) << (BMP_BIT - 32) | BMP_C(0x2c98d4c9) >> (63 - BMP_BIT),
BMP_C(0x5931a992) << (BMP_BIT * 2 - 64),
BMP_C(0x5931a992) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64h[] = {
BMP_C(0x995dc9bb) << (BMP_BIT - 32) | BMP_C(0x6f8c9cfd) >> (63 - BMP_BIT),
BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64),
BMP_C(0xdf1939fa) << (BMP_BIT * 2 - 64),
};
static const bmp_t b64i[] = {
BMP_C(0x49958c9a) << (BMP_BIT - 32) | BMP_C(0x5ebe9a9f) >> (63 - BMP_BIT),
BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64),
BMP_C(0xbd7d353f) << (BMP_BIT * 2 - 64),
};
# endif /* BMP_BIT */
@ -237,22 +237,22 @@ static const bmp_t b82a[] = {
# elif BMP_BIT >= 41
static const bmp_t b82[] = {
BMP_C(0x01846008880) << (BMP_BIT - 41) | BMP_C(0x08a00a20208) >> (81 - BMP_BIT),
BMP_C(0x11401440411) << (BMP_BIT * 2 - 82),
BMP_C(0x11401440411) << (BMP_BIT * 2 - 82),
};
static const bmp_t b82a[] = {
BMP_C(0x04f541fb128) << (BMP_BIT - 41) | BMP_C(0x011c00feb09) >> (81 - BMP_BIT),
BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82),
BMP_C(0x023801fd612) << (BMP_BIT * 2 - 82),
};
# else /* BMP_BIT */
static const bmp_t b82[] = {
BMP_C(0x0c230044) << (BMP_BIT - 32) | BMP_C(0x040) >> (40 - BMP_BIT),
BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2),
BMP_C(0x00411) << (BMP_BIT * 3 - 82),
BMP_C(0x40450051) << (BMP_BIT * 2 - 64) | BMP_C(0x00104) >> (80 - BMP_BIT * 2),
BMP_C(0x00411) << (BMP_BIT * 3 - 82),
};
static const bmp_t b82a[] = {
BMP_C(0x27aa0fd8) << (BMP_BIT - 32) | BMP_C(0x094) >> (40 - BMP_BIT),
BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2),
BMP_C(0x3d612) << (BMP_BIT * 3 - 82),
BMP_C(0x9408e007) << (BMP_BIT * 2 - 64) | BMP_C(0x0f584) >> (80 - BMP_BIT * 2),
BMP_C(0x3d612) << (BMP_BIT * 3 - 82),
};
# endif /* BMP_BIT */
@ -262,215 +262,215 @@ static const bmp_t b82a[] = {
/* Array of the polynomial bitmaps used in the model table. */
static const bmp_t b32[] = {
BMP_C(0x000000af) << (BMP_BIT - 32), /* 0 -- 32,000000af */
BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */
BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */
BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */
BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */
BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */
BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */
BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */
BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */
BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */
BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */
BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */
BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */
BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */
BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */
BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */
BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */
BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */
BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */
BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */
BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */
BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */
BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */
BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */
BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */
BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */
BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */
BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */
BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */
BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */
BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */
BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */
BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */
BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */
BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */
BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */
BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */
BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */
BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */
BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */
BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */
BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */
BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */
BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */
BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */
BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */
BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */
BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */
BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */
BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */
BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */
BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */
BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */
BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */
BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */
BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */
BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */
BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */
BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */
BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */
BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */
BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */
BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */
BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */
BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */
BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */
BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */
BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */
BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */
BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */
BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */
BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */
BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */
BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */
BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */
BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */
BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */
BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */
BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */
BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */
BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */
BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */
BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */
BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */
BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */
BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */
BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */
BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */
BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */
BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */
BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */
BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */
BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */
BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */
BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */
BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */
BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */
BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */
BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */
BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */
BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */
BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */
BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */
BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */
BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */
BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */
BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */
BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */
BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */
BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */
BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */
BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */
BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */
BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */
BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */
BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */
BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */
BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */
BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */
BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */
BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */
BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */
BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */
BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */
BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */
BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */
BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */
BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */
BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */
BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */
BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */
BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */
BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */
BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */
BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */
BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */
BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */
BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */
BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */
BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */
BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */
BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */
BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */
BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */
BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */
BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */
BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */
BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */
BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */
BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */
BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */
BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */
BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */
BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */
BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */
BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */
BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */
BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */
BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */
BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */
BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */
BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */
BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */
BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */
BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */
BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */
BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */
BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */
BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */
BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */
BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */
BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */
BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */
BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */
BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */
BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */
BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */
BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */
BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */
BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */
BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */
BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */
BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */
BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */
BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */
BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */
BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */
BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */
BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */
BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */
BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */
BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */
BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */
BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */
BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */
BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */
BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */
BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */
BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */
BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */
BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */
BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */
BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */
BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */
BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */
BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */
BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */
BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */
BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */
BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */
BMP_C(0x00010000) << (BMP_BIT - 32), /* 1 -- 16, 0001 */
BMP_C(0x00020000) << (BMP_BIT - 32), /* 2 -- 15, 0001 */
BMP_C(0x00065b00) << (BMP_BIT - 32), /* 3 -- 24, 00065b */
BMP_C(0x007e0000) << (BMP_BIT - 32), /* 4 -- 16, 007e */
BMP_C(0x007f0000) << (BMP_BIT - 32), /* 5 -- 16, 007f */
BMP_C(0x03400000) << (BMP_BIT - 32), /* 6 -- 11, 01a */
BMP_C(0x0376e6e7) << (BMP_BIT - 32), /* 7 -- 32,0376e6e7 */
BMP_C(0x04c11db7) << (BMP_BIT - 32), /* 8 -- 32,04c11db7 */
BMP_C(0x05890000) << (BMP_BIT - 32), /* 9 -- 16, 0589 */
BMP_C(0x07000000) << (BMP_BIT - 32), /* 10 -- 8, 07 */
BMP_C(0x080b0000) << (BMP_BIT - 32), /* 11 -- 16, 080b */
BMP_C(0x09823b6e) << (BMP_BIT - 32), /* 12 -- 31,04c11db7 */
BMP_C(0x0b3c0000) << (BMP_BIT - 32), /* 13 -- 15, 059e */
BMP_C(0x0c000000) << (BMP_BIT - 32), /* 14 -- 6, 03 */
BMP_C(0x0c200000) << (BMP_BIT - 32), /* 15 -- 11, 061 */
BMP_C(0x0c780000) << (BMP_BIT - 32), /* 16 -- 14, 031e */
BMP_C(0x0fb30000) << (BMP_BIT - 32), /* 17 -- 16, 0fb3 */
BMP_C(0x10210000) << (BMP_BIT - 32), /* 18 -- 16, 1021 */
BMP_C(0x12000000) << (BMP_BIT - 32), /* 19 -- 7, 09 */
BMP_C(0x130d2afc) << (BMP_BIT - 32), /* 20 -- 30,04c34abf */
BMP_C(0x144e6300) << (BMP_BIT - 32), /* 21 -- 24, 144e63 */
BMP_C(0x15000000) << (BMP_BIT - 32), /* 22 -- 8, 15 */
BMP_C(0x1697d06a) << (BMP_BIT - 32), /* 23 -- 32,1697d06a */
BMP_C(0x17800000) << (BMP_BIT - 32), /* 24 -- 12, 178 */
BMP_C(0x18000000) << (BMP_BIT - 32), /* 25 -- 6, 06 */
BMP_C(0x19d3c8d8) << (BMP_BIT - 32), /* 26 -- 31,0ce9e46c */
BMP_C(0x1c000000) << (BMP_BIT - 32), /* 27 -- 6, 07 */
BMP_C(0x1d000000) << (BMP_BIT - 32), /* 28 -- 8, 1d */
BMP_C(0x1d0f0000) << (BMP_BIT - 32), /* 29 -- 16, 1d0f */
BMP_C(0x1dcf0000) << (BMP_BIT - 32), /* 30 -- 16, 1dcf */
BMP_C(0x1edc6f41) << (BMP_BIT - 32), /* 31 -- 32,1edc6f41 */
BMP_C(0x1f23b800) << (BMP_BIT - 32), /* 32 -- 24, 1f23b8 */
BMP_C(0x20000000) << (BMP_BIT - 32), /* 33 -- 4, 2 */
BMP_C(0x200fa500) << (BMP_BIT - 32), /* 34 -- 24, 200fa5 */
BMP_C(0x20140000) << (BMP_BIT - 32), /* 35 -- 14, 0805 */
BMP_C(0x20b40000) << (BMP_BIT - 32), /* 36 -- 14, 082d */
BMP_C(0x20fe0000) << (BMP_BIT - 32), /* 37 -- 16, 20fe */
BMP_C(0x21890000) << (BMP_BIT - 32), /* 38 -- 16, 2189 */
BMP_C(0x21cf0200) << (BMP_BIT - 32), /* 39 -- 24, 21cf02 */
BMP_C(0x23ef5200) << (BMP_BIT - 32), /* 40 -- 24, 23ef52 */
BMP_C(0x25000000) << (BMP_BIT - 32), /* 41 -- 8, 25 */
BMP_C(0x26000000) << (BMP_BIT - 32), /* 42 -- 8, 26 */
BMP_C(0x26b10000) << (BMP_BIT - 32), /* 43 -- 16, 26b1 */
BMP_C(0x27818000) << (BMP_BIT - 32), /* 44 -- 17, 04f03 */
BMP_C(0x27d00000) << (BMP_BIT - 32), /* 45 -- 13, 04fa */
BMP_C(0x28000000) << (BMP_BIT - 32), /* 46 -- 5, 05 */
BMP_C(0x29b10000) << (BMP_BIT - 32), /* 47 -- 16, 29b1 */
BMP_C(0x2f000000) << (BMP_BIT - 32), /* 48 -- 8, 2f */
BMP_C(0x30000000) << (BMP_BIT - 32), /* 49 -- 4, 3/ 5, 6 */
BMP_C(0x3010bf7f) << (BMP_BIT - 32), /* 50 -- 32,3010bf7f */
BMP_C(0x31000000) << (BMP_BIT - 32), /* 51 -- 8, 31 */
BMP_C(0x31800000) << (BMP_BIT - 32), /* 52 -- 10, 0c6 */
BMP_C(0x31c30000) << (BMP_BIT - 32), /* 53 -- 16, 31c3 */
BMP_C(0x328b6300) << (BMP_BIT - 32), /* 54 -- 24, 328b63 */
BMP_C(0x34000000) << (BMP_BIT - 32), /* 55 -- 6, 0d */
BMP_C(0x340bc6d9) << (BMP_BIT - 32), /* 56 -- 32,340bc6d9 */
BMP_C(0x37000000) << (BMP_BIT - 32), /* 57 -- 8, 37 */
BMP_C(0x38000000) << (BMP_BIT - 32), /* 58 -- 5, 07 */
BMP_C(0x39000000) << (BMP_BIT - 32), /* 59 -- 8, 39 */
BMP_C(0x3d650000) << (BMP_BIT - 32), /* 60 -- 16, 3d65 */
BMP_C(0x3e000000) << (BMP_BIT - 32), /* 61 -- 8, 3e */
BMP_C(0x40000000) << (BMP_BIT - 32), /* 62 -- 3, 2 */
BMP_C(0x42000000) << (BMP_BIT - 32), /* 63 -- 8, 42 */
BMP_C(0x44c20000) << (BMP_BIT - 32), /* 64 -- 16, 44c2 */
BMP_C(0x45270551) << (BMP_BIT - 32), /* 65 -- 32,45270551 */
BMP_C(0x48000000) << (BMP_BIT - 32), /* 66 -- 5, 09 */
BMP_C(0x49000000) << (BMP_BIT - 32), /* 67 -- 8, 49 */
BMP_C(0x4a800000) << (BMP_BIT - 32), /* 68 -- 10, 12a */
BMP_C(0x4acc0000) << (BMP_BIT - 32), /* 69 -- 15, 2566 */
BMP_C(0x4b000000) << (BMP_BIT - 32), /* 70 -- 8, 4b */
BMP_C(0x4b370000) << (BMP_BIT - 32), /* 71 -- 16, 4b37 */
BMP_C(0x4c000000) << (BMP_BIT - 32), /* 72 -- 6, 13 */
BMP_C(0x4c060000) << (BMP_BIT - 32), /* 73 -- 16, 4c06 */
BMP_C(0x53000000) << (BMP_BIT - 32), /* 74 -- 8, 53 */
BMP_C(0x55000000) << (BMP_BIT - 32), /* 75 -- 8, 55 */
BMP_C(0x55555500) << (BMP_BIT - 32), /* 76 -- 24, 555555 */
BMP_C(0x59350000) << (BMP_BIT - 32), /* 77 -- 16, 5935 */
BMP_C(0x5d380000) << (BMP_BIT - 32), /* 78 -- 16, 5d38 */
BMP_C(0x5d400000) << (BMP_BIT - 32), /* 79 -- 10, 175 */
BMP_C(0x5d6dcb00) << (BMP_BIT - 32), /* 80 -- 24, 5d6dcb */
BMP_C(0x60000000) << (BMP_BIT - 32), /* 81 -- 3, 3 */
BMP_C(0x60e00000) << (BMP_BIT - 32), /* 82 -- 11, 307 */
BMP_C(0x63d00000) << (BMP_BIT - 32), /* 83 -- 16, 63d0 */
BMP_C(0x64000000) << (BMP_BIT - 32), /* 84 -- 6, 19 */
BMP_C(0x66400000) << (BMP_BIT - 32), /* 85 -- 10, 199 */
BMP_C(0x66c50000) << (BMP_BIT - 32), /* 86 -- 16, 66c5 */
BMP_C(0x6f630000) << (BMP_BIT - 32), /* 87 -- 16, 6f63 */
BMP_C(0x6f910000) << (BMP_BIT - 32), /* 88 -- 16, 6f91 */
BMP_C(0x70000000) << (BMP_BIT - 32), /* 89 -- 4, 7 */
BMP_C(0x70a00000) << (BMP_BIT - 32), /* 90 -- 11, 385 */
BMP_C(0x755b0000) << (BMP_BIT - 32), /* 91 -- 16, 755b */
BMP_C(0x765e7680) << (BMP_BIT - 32), /* 92 -- 32,765e7680 */
BMP_C(0x76c20800) << (BMP_BIT - 32), /* 93 -- 32, 0ed841 */
BMP_C(0x7979bd00) << (BMP_BIT - 32), /* 94 -- 24, 7979bd */
BMP_C(0x7e000000) << (BMP_BIT - 32), /* 95 -- 8, 7e */
BMP_C(0x80000000) << (BMP_BIT - 32), /* 96 -- 3, 4 */
BMP_C(0x80006300) << (BMP_BIT - 32), /* 97 -- 24, 800063 */
BMP_C(0x80050000) << (BMP_BIT - 32), /* 98 -- 16, 8005 */
BMP_C(0x800d0000) << (BMP_BIT - 32), /* 99 -- 16, 800d */
BMP_C(0x800fe300) << (BMP_BIT - 32), /* 100 -- 24, 800fe3 */
BMP_C(0x80b40000) << (BMP_BIT - 32), /* 101 -- 14, 202d */
BMP_C(0x80c2e71c) << (BMP_BIT - 32), /* 102 -- 30,2030b9c7 */
BMP_C(0x80f00000) << (BMP_BIT - 32), /* 103 -- 12, 80f */
BMP_C(0x814141ab) << (BMP_BIT - 32), /* 104 -- 32,814141ab */
BMP_C(0x8144c800) << (BMP_BIT - 32), /* 105 -- 21, 102899 */
BMP_C(0x864cfb00) << (BMP_BIT - 32), /* 106 -- 24, 864cfb */
BMP_C(0x87315576) << (BMP_BIT - 32), /* 107 -- 32,87315576 */
BMP_C(0x89ec0000) << (BMP_BIT - 32), /* 108 -- 16, 89ec */
BMP_C(0x8a000000) << (BMP_BIT - 32), /* 109 -- 7, 45 */
BMP_C(0x8b320000) << (BMP_BIT - 32), /* 110 -- 15, 4599 */
BMP_C(0x8bb70000) << (BMP_BIT - 32), /* 111 -- 16, 8bb7 */
BMP_C(0x8cc00000) << (BMP_BIT - 32), /* 112 -- 10, 233 */
BMP_C(0x904cddbf) << (BMP_BIT - 32), /* 113 -- 32,904cddbf */
BMP_C(0x906e0000) << (BMP_BIT - 32), /* 114 -- 16, 906e */
BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */
BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */
BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */
BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */
BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */
BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */
BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */
BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */
BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */
BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */
BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */
BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */
BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */
BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */
BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */
BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */
BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */
BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */
BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */
BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */
BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */
BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */
BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */
BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */
BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */
BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */
BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */
BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */
BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */
BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */
BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */
BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */
BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */
BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */
BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */
BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */
BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */
BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */
BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */
BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */
BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */
BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */
BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */
BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */
BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */
BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */
BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */
BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */
BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */
BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */
BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */
BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */
BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */
BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */
BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */
BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */
BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */
BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */
BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */
BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */
BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */
BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */
BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */
BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */
BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */
BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */
BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */
BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */
BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */
BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */
BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */
BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */
BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */
BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */
BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */
BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */
BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */
BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */
BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */
BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */
BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */
BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */
BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */
BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */
BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */
BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */
BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */
BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */
BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */
BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */
BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */
BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */
BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */
BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */
BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */
};
static const struct malias aliases[];

View file

@ -26,7 +26,7 @@
//------------------------------------
// MFU/NTAG PWD/PACK generation stuff
// Italian transport system
// Italian transport system
// Amiibo
// Lego Dimension
// XYZ 3D printing
@ -225,9 +225,9 @@ int mfc_algo_mizip_one(uint8_t *uid, uint8_t sector, uint64_t *key) {
}
// returns all Mifare Mini (MFM) 10 keys.
// keys must have 5*2*6 = 60bytes space
int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys) {
int mfc_algo_mizip_all(uint8_t *uid, uint8_t *keys) {
if (keys == NULL) return PM3_EINVARG;
uint64_t xor_tbl[] = {
0x09125a2589e5ULL, 0xF12C8453D821ULL,
0xAB75C937922FULL, 0x73E799FE3241ULL,

View file

@ -217,16 +217,16 @@ static const signed char indexes[2][4][20] = {
}, /* KL -> RK */
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}, /* KR -> RK */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
}, /* KR -> RK */
{
4, 5, 6, 7, 12, 13, 14, 15, 16, 17,
18, 19, -1, 24, 25, -1, 31, 28, 29, 30
}, /* KA -> RK */
{
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
} /* KB -> RK */
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1
} /* KB -> RK */
},
{
{
@ -235,12 +235,12 @@ static const signed char indexes[2][4][20] = {
}, /* KL -> RK */
{
-1, -1, -1, -1, 8, 9, 10, 11, 16, 17,
18, 19, -1, -1, -1, -1, 39, 36, 37, 38
}, /* KR -> RK */
18, 19, -1, -1, -1, -1, 39, 36, 37, 38
}, /* KR -> RK */
{
-1, -1, -1, -1, 12, 13, 14, 15, 58, 59,
56, 57, 31, 28, 29, 30, -1, -1, -1, -1
}, /* KA -> RK */
56, 57, 31, 28, 29, 30, -1, -1, -1, -1
}, /* KA -> RK */
{
4, 5, 6, 7, 65, 66, 67, 64, 20, 21,
22, 23, -1, -1, -1, -1, 43, 40, 41, 42

View file

@ -1060,7 +1060,7 @@ int flush;
last = here;
for (;;) {
here = state->lencode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
(BITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}
@ -1110,7 +1110,7 @@ int flush;
last = here;
for (;;) {
here = state->distcode[last.val +
(BITS(last.bits + last.op) >> last.bits)];
(BITS(last.bits + last.op) >> last.bits)];
if ((unsigned)(last.bits + here.bits) <= bits) break;
PULLBYTE();
}

View file

@ -113,12 +113,12 @@ typedef struct {
// A struct used to send sample-configs over USB
typedef struct {
uint8_t decimation;
uint8_t bits_per_sample;
bool averaging;
int divisor;
int trigger_threshold;
uint32_t samples_to_skip;
int8_t decimation;
int8_t bits_per_sample;
int8_t averaging;
int16_t divisor;
int16_t trigger_threshold;
int32_t samples_to_skip;
bool verbose;
} PACKED sample_config;
/*