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

This commit is contained in:
vratiskol 2019-04-03 01:48:46 +02:00
commit 1c77185fb9
50 changed files with 1182 additions and 863 deletions

9
.gitattributes vendored
View file

@ -1,6 +1,15 @@
# .gitattributes # .gitattributes
# prevent binary files from CRLF handling, diff and merge: # prevent binary files from CRLF handling, diff and merge:
fpga/fpga.bit -crlf -diff fpga/fpga.bit -crlf -diff
*.bin -crlf -diff *.bin -crlf -diff
*.z -crlf -diff *.z -crlf -diff
# Force LF
*.c text=auto eol=lf
*.cpp text=auto eol=lf
*.h text=auto eol=lf
*.lua text=auto eol=lf
*.py text=auto eol=lf
*.pl text=auto eol=lf
Makefile text=auto eol=lf

1
.gitignore vendored
View file

@ -20,6 +20,7 @@
*.exe *.exe
*.dsym *.dsym
version.c version.c
*.json
!client/hardnested/*.bin !client/hardnested/*.bin
!client/hardnested/tables/*.z !client/hardnested/tables/*.z

View file

@ -3,6 +3,29 @@ 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... 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] ## [unreleased][unreleased]
- *WIP* Add FPC usart with pm3 client: WITH_FPC_HOST. (@doegox)
- Add '-b baudrate' option to the pm3 client. (@doegox)
- Change 'lf t55xx info': tell if known configuration block0. (@iceman)
- Fix/Add FPC usart: fix TX, bring RX, full speed. (@doegox)
- Change 'lf t55xx config' options: allow to toggle on/off i/q5/st
- Change 'lf t55xx info': support offline block0, Q5, fix extended, add warns. (@doegox)
- Avoid race condition when flasher finds the not yet closed pm3 port. (@doegox)
- Fix 'lf t55xx trace': read the proper block. (@doegox)
- Fix Indala 64 on T55xx: use PSK1. (@doegox)
- Force proper Linefeed (LF) handling in ProxSpace. (@vratiskol)
- Fix Makefiles race conditions to allow parallel compilation, e.g. 'make -j8'. (@doegox)
- Add - dictionary key file for MFU. (not in use at the moment) (@mazodude)
- Change 'lf fdx demod - better biphase maxerrors. (@MalteHillmann)
- Change 'hf mf sim' - now works better against android (@mceloff)
- Fix 'lf t55xx brute' - now works after aquiredata adaptations (@iceman)
- Fix 'lf t55xx chk' - now works after aquiredata adaptations (@iceman)
- Fix 'lf t55xx recoverpwd' - now works after aquiredata adaptations (@iceman)
- Fix 'data detect p' - reverted bad clock detection (@iceman)
- Change 'data detect a' - better clock detection (@iceman)
- Add 'hf 14a info' - now detects some magic card Gen2 (@iceman)
- Removed 'LCD' code in armsrc compilation (@iceman)
- Change - Generic fixes of codestyle (@doegox) (@iceman)
- Change 'lf indala demod' - refactoring (@iceman)
- Change - handling fault bit markers (7) and partial nibbles in hex printing (@doegox) - Change - handling fault bit markers (7) and partial nibbles in hex printing (@doegox)
- Change - printing of fault bit markers (7) using a dot (@doegox) - Change - printing of fault bit markers (7) using a dot (@doegox)
- Change 'sc upgrade' - firmware file integrity check (@piwi) - Change 'sc upgrade' - firmware file integrity check (@piwi)

View file

@ -128,7 +128,7 @@ style:
@which astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 ) @which astyle >/dev/null || ( echo "Please install 'astyle' package first" ; exit 1 )
# Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile # Remove spaces & tabs at EOL, add LF at EOF if needed on *.c, *.h, *.cpp. *.lua, *.py, *.pl, Makefile
find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \ find . \( -name "*.[ch]" -or -name "*.cpp" -or -name "*.lua" -or -name "*.py" -or -name "*.pl" -or -name "Makefile" \) \
-exec perl -pi -e 's/[ \t\r]+$$//' {} \; \ -exec perl -pi -e 's/[ \t]+$$//' {} \; \
-exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \ -exec sh -c "tail -c1 {} | xxd -p | tail -1 | grep -q -v 0a$$" \; \
-exec sh -c "echo >> {}" \; -exec sh -c "echo >> {}" \;
# Apply astyle on *.c, *.h, *.cpp # Apply astyle on *.c, *.h, *.cpp

View file

@ -632,7 +632,6 @@ void ListenReaderField(int limit) {
void UsbPacketReceived(uint8_t *packet, int len) { void UsbPacketReceived(uint8_t *packet, int len) {
UsbCommand *c = (UsbCommand *)packet; UsbCommand *c = (UsbCommand *)packet;
//Dbprintf("received %d bytes, with command: 0x%04x and args: %d %d %d", len, c->cmd, c->arg[0], c->arg[1], c->arg[2]); //Dbprintf("received %d bytes, with command: 0x%04x and args: %d %d %d", len, c->cmd, c->arg[0], c->arg[1], c->arg[2]);
switch (c->cmd) { switch (c->cmd) {
@ -1105,29 +1104,32 @@ void UsbPacketReceived(uint8_t *packet, int len) {
*/ */
char dest[USB_CMD_DATA_SIZE] = { '\0' }; char dest[USB_CMD_DATA_SIZE] = {'\0'};
static const char *welcome = "Proxmark3 Serial interface via FPC ready\n"; if (usart_dataavailable()) {
strncat(dest, welcome, sizeof(dest) - strlen(dest) - 1); Dbprintf("RX DATA!");
sprintf(dest + strlen(dest) - 1, "| bytes 0x%02x 0x%02x 0x%02x 0x%02x \n" uint16_t len = usart_readbuffer((uint8_t *)dest);
dest[len] = '\0';
Dbprintf("RX: %d | %02X %02X %02X %02X %02X %02X %02X %02X ", len, dest[0], dest[1], dest[2], dest[3], dest[4], dest[5], dest[6], dest[7]);
}
static const char *welcome = "Proxmark3 Serial interface via FPC ready\r\n";
usart_writebuffer((uint8_t *)welcome, strlen(welcome));
sprintf(dest, "| bytes 0x%02x 0x%02x 0x%02x 0x%02x\r\n"
, c->d.asBytes[0] , c->d.asBytes[0]
, c->d.asBytes[1] , c->d.asBytes[1]
, c->d.asBytes[2] , c->d.asBytes[2]
, c->d.asBytes[3] , c->d.asBytes[3]
); );
usart_writebuffer((uint8_t *)dest, strlen(dest));
UsbCommand txcmd = { CMD_DEBUG_PRINT_STRING, { strlen(dest), 0, 0 } };
memcpy(txcmd.d.asBytes, dest, sizeof(dest));
LED_A_ON(); LED_A_ON();
usart_init();
usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommand));
//usb //usb
cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest)); cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
LED_A_OFF(); LED_A_OFF();
/* /*
uint8_t my_rx[sizeof(UsbCommand)]; uint8_t my_rx[sizeof(UsbCommand)];
while (!BUTTON_PRESS() && !usb_poll_validate_length()) { while (!BUTTON_PRESS() && !usb_poll_validate_length()) {
@ -1136,13 +1138,12 @@ void UsbPacketReceived(uint8_t *packet, int len) {
//UsbPacketReceived(my_rx, sizeof(my_rx)); //UsbPacketReceived(my_rx, sizeof(my_rx));
UsbCommand *my = (UsbCommand *)my_rx; UsbCommand *my = (UsbCommand *)my_rx;
if (mc->cmd > 0 ) { if (my->cmd > 0 ) {
Dbprintf("received command: 0x%04x and args: %d %d %d", my->cmd, my->arg[0], my->arg[1], my->arg[2]); Dbprintf("received command: 0x%04x and args: %d %d %d", my->cmd, my->arg[0], my->arg[1], my->arg[2]);
} }
} }
} }
*/ */
//cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest)); //cmd_send(CMD_DEBUG_PRINT_STRING, strlen(dest), 0, 0, dest, strlen(dest));
cmd_send(CMD_ACK, 0, 0, 0, 0, 0); cmd_send(CMD_ACK, 0, 0, 0, 0, 0);
@ -1558,17 +1559,19 @@ void __attribute__((noreturn)) AppMain(void) {
// Check if there is a usb packet available // Check if there is a usb packet available
if (usb_poll_validate_length()) { if (usb_poll_validate_length()) {
if (usb_read(rx, sizeof(rx))) if (usb_read(rx, sizeof(rx))) {
#ifdef WITH_FPC_HOST
reply_via_fpc = 0;
#endif
UsbPacketReceived(rx, sizeof(rx)); UsbPacketReceived(rx, sizeof(rx));
}
}
#ifdef WITH_FPC_HOST
// Check if there is a FPC packet available
if (usart_readcommand(rx) > 0) {
reply_via_fpc = 1;
UsbPacketReceived(rx, sizeof(rx));
} }
#ifdef WITH_FPC
// Check is there is FPC package available
/*
usart_init();
if (usart_readbuffer(rx, sizeof(rx)) )
UsbPacketReceived(rx, sizeof(rx) );
*/
#endif #endif
// Press button for one second to enter a possible standalone mode // Press button for one second to enter a possible standalone mode

View file

@ -138,7 +138,7 @@ static void hitag_send_bit(int bit) {
static void hitag_send_frame(const uint8_t *frame, size_t frame_len) { static void hitag_send_frame(const uint8_t *frame, size_t frame_len) {
// SOF - send start of frame // SOF - send start of frame
hitag_send_bit(1); hitag_send_bit(1);
hitag_send_bit(1); hitag_send_bit(1);
hitag_send_bit(1); hitag_send_bit(1);
hitag_send_bit(1); hitag_send_bit(1);
@ -399,9 +399,9 @@ static bool hitag2_write_page(uint8_t *rx, const size_t rxlen, uint8_t *tx, size
break; break;
case WRITE_STATE_PAGENUM_WRITTEN: case WRITE_STATE_PAGENUM_WRITTEN:
// Check if page number was received correctly // Check if page number was received correctly
if ( (rxlen == 10) if ((rxlen == 10)
&& (rx[0] == (0x82 | (blocknr << 3) | ((blocknr ^ 7) >> 2))) && (rx[0] == (0x82 | (blocknr << 3) | ((blocknr ^ 7) >> 2)))
&& (rx[1] == (((blocknr & 0x3) ^ 0x3) << 6))) { && (rx[1] == (((blocknr & 0x3) ^ 0x3) << 6))) {
*txlen = 32; *txlen = 32;
memset(tx, 0, HITAG_FRAME_LEN); memset(tx, 0, HITAG_FRAME_LEN);

View file

@ -1529,7 +1529,7 @@ void T55xxReadBlock(uint16_t arg0, uint8_t Block, uint32_t Pwd) {
// Turn field on to read the response // Turn field on to read the response
// 137*8 seems to get to the start of data pretty well... // 137*8 seems to get to the start of data pretty well...
// but we want to go past the start and let the repeating data settle in... // but we want to go past the start and let the repeating data settle in...
TurnReadLFOn(200 * 8); TurnReadLFOn(150 * 8);
// Acquisition // Acquisition
// Now do the acquisition // Now do the acquisition
@ -1731,14 +1731,15 @@ void CopyIOtoT55x7(uint32_t hi, uint32_t lo) {
// Clone Indala 64-bit tag by UID to T55x7 // Clone Indala 64-bit tag by UID to T55x7
void CopyIndala64toT55x7(uint32_t hi, uint32_t lo) { void CopyIndala64toT55x7(uint32_t hi, uint32_t lo) {
//Program the 2 data blocks for supplied 64bit UID //Program the 2 data blocks for supplied 64bit UID
// and the Config for Indala 64 format (RF/32;PSK2 with RF/2;Maxblock=2) // and the Config for Indala 64 format (RF/32;PSK1 with RF/2;Maxblock=2)
uint32_t data[] = { T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK2 | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo}; uint32_t data[] = { T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK1 | (2 << T55x7_MAXBLOCK_SHIFT), hi, lo};
//TODO add selection of chip for Q5 or T55x7 //TODO add selection of chip for Q5 or T55x7
// data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK2 | 2 << T5555_MAXBLOCK_SHIFT; // data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK1 | 2 << T5555_MAXBLOCK_SHIFT;
LED_D_ON();
WriteT55xx(data, 0, 3); WriteT55xx(data, 0, 3);
//Alternative config for Indala (Extended mode;RF/32;PSK2 with RF/2;Maxblock=2;Inverse data) //Alternative config for Indala (Extended mode;RF/32;PSK1 with RF/2;Maxblock=2;Inverse data)
// T5567WriteBlock(0x603E1042,0); // T5567WriteBlock(0x603E1042,0);
LED_D_OFF();
} }
// Clone Indala 224-bit tag by UID to T55x7 // Clone Indala 224-bit tag by UID to T55x7
void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7) { void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t uid4, uint32_t uid5, uint32_t uid6, uint32_t uid7) {
@ -1749,9 +1750,11 @@ void CopyIndala224toT55x7(uint32_t uid1, uint32_t uid2, uint32_t uid3, uint32_t
data[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK2 | (7 << T55x7_MAXBLOCK_SHIFT); data[0] = T55x7_BITRATE_RF_32 | T55x7_MODULATION_PSK2 | (7 << T55x7_MAXBLOCK_SHIFT);
//TODO add selection of chip for Q5 or T55x7 //TODO add selection of chip for Q5 or T55x7
// data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK2 | 7 << T5555_MAXBLOCK_SHIFT; // data[0] = T5555_SET_BITRATE(32 | T5555_MODULATION_PSK2 | 7 << T5555_MAXBLOCK_SHIFT;
LED_D_ON();
WriteT55xx(data, 0, 8); WriteT55xx(data, 0, 8);
//Alternative config for Indala (Extended mode;RF/32;PSK2 with RF/2;Maxblock=7;Inverse data) //Alternative config for Indala (Extended mode;RF/32;PSK1 with RF/2;Maxblock=7;Inverse data)
// T5567WriteBlock(0x603E10E2,0); // T5567WriteBlock(0x603E10E2,0);
LED_D_OFF();
} }
// clone viking tag to T55xx // clone viking tag to T55xx
void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) { void CopyVikingtoT55xx(uint32_t block1, uint32_t block2, uint8_t Q5) {

View file

@ -1962,7 +1962,7 @@ TEST2:
iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN); iso14443a_setup(FPGA_HF_ISO14443A_READER_LISTEN);
int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true); int res = iso14443a_select_card(uid, NULL, &cuid, true, 0, true);
if ( res == 2 ) { if (res == 2) {
ReaderTransmit(rats, sizeof(rats), NULL); ReaderTransmit(rats, sizeof(rats), NULL);
res = ReaderReceive(buf, par); res = ReaderReceive(buf, par);
if (memcmp(buf, "\x09\x78\x00\x91\x02\xDA\xBC\x19\x10\xF0\x05", 11) == 0) { if (memcmp(buf, "\x09\x78\x00\x91\x02\xDA\xBC\x19\x10\xF0\x05", 11) == 0) {

View file

@ -137,15 +137,15 @@ bool IsBlock0PCF7931(uint8_t *block) {
bool IsBlock1PCF7931(uint8_t *block) { bool IsBlock1PCF7931(uint8_t *block) {
// assuming all RFU bits are set to 0 // assuming all RFU bits are set to 0
if (block[10] == 0 if (block[10] == 0
&& block[11] == 0 && block[11] == 0
&& block[12] == 0 && block[12] == 0
&& block[13] == 0) { && block[13] == 0) {
if ( (block[14] & 0x7f) <= 9 if ((block[14] & 0x7f) <= 9
&& block[15] <= 9) { && block[15] <= 9) {
return true; return true;
}
} }
}
return false; return false;
} }

View file

@ -282,8 +282,7 @@ ifeq "$(SUPPORTS_AVX512)" "True"
endif endif
BINS = proxmark3 flasher fpga_compress BINS = proxmark3 flasher fpga_compress
WINBINS = $(patsubst %, %.exe, $(BINS)) CLEAN = $(BINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/usb_cmd.lua lualibs/mf_default_keys.lua
CLEAN = $(BINS) $(WINBINS) $(COREOBJS) $(CMDOBJS) $(OBJCOBJS) $(ZLIBOBJS) $(QTGUIOBJS) $(MULTIARCHOBJS) $(OBJDIR)/*.o *.moc.cpp ui/ui_overlays.h lualibs/usb_cmd.lua lualibs/mf_default_keys.lua
# need to assign dependancies to build these first... # need to assign dependancies to build these first...
all: lua_build jansson_build mbedtls_build cbor_build $(BINS) all: lua_build jansson_build mbedtls_build cbor_build $(BINS)
@ -347,28 +346,28 @@ cbor_build:
print-%: ; @echo $* = $($*) print-%: ; @echo $* = $($*)
$(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%_NOSIMD.d $(OBJDIR)/%_NOSIMD.o : %.c $(OBJDIR)/%_NOSIMD.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_NOSIMD.Td) $(CFLAGS) $(HARD_SWITCH_NOSIMD) -c -o $@ $<
$(POSTCOMPILE:%.d=%_NOSIMD.d) $(MV) -f $(OBJDIR)/$*_NOSIMD.Td $(OBJDIR)/$*_NOSIMD.d
$(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%_MMX.d $(OBJDIR)/%_MMX.o : %.c $(OBJDIR)/%_MMX.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_MMX.Td) $(CFLAGS) $(HARD_SWITCH_MMX) -c -o $@ $<
$(POSTCOMPILE:%.d=%_MMX.d) $(MV) -f $(OBJDIR)/$*_MMX.Td $(OBJDIR)/$*_MMX.d
$(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%_SSE2.d $(OBJDIR)/%_SSE2.o : %.c $(OBJDIR)/%_SSE2.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_SSE2.Td) $(CFLAGS) $(HARD_SWITCH_SSE2) -c -o $@ $<
$(POSTCOMPILE:%.d=%_SSE2.d) $(MV) -f $(OBJDIR)/$*_SSE2.Td $(OBJDIR)/$*_SSE2.d
$(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%_AVX.d $(OBJDIR)/%_AVX.o : %.c $(OBJDIR)/%_AVX.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_AVX.Td) $(CFLAGS) $(HARD_SWITCH_AVX) -c -o $@ $<
$(POSTCOMPILE:%.d=%_AVX.d) $(MV) -f $(OBJDIR)/$*_AVX.Td $(OBJDIR)/$*_AVX.d
$(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%_AVX2.d $(OBJDIR)/%_AVX2.o : %.c $(OBJDIR)/%_AVX2.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_AVX2.Td) $(CFLAGS) $(HARD_SWITCH_AVX2) -c -o $@ $<
$(POSTCOMPILE:%.d=%_AVX2.d) $(MV) -f $(OBJDIR)/$*_AVX2.Td $(OBJDIR)/$*_AVX2.d
$(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%_AVX512.d $(OBJDIR)/%_AVX512.o : %.c $(OBJDIR)/%_AVX512.d
$(CC) $(DEPFLAGS) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $< $(CC) $(DEPFLAGS:%.Td=%_AVX512.Td) $(CFLAGS) $(HARD_SWITCH_AVX512) -c -o $@ $<
$(POSTCOMPILE:%.d=%_AVX512.d) $(MV) -f $(OBJDIR)/$*_AVX512.Td $(OBJDIR)/$*_AVX512.d
%.o: %.c %.o: %.c
$(OBJDIR)/%.o : %.c $(OBJDIR)/%.d $(OBJDIR)/%.o : %.c $(OBJDIR)/%.d

View file

@ -93,7 +93,7 @@ int GetModels(char *Models[], int *count, uint8_t *width) {
PrintAndLogEx(WARNING, "out of memory?"); PrintAndLogEx(WARNING, "out of memory?");
return 0; return 0;
} }
if ( model.name != NULL ) { if (model.name != NULL) {
memcpy(tmp, model.name, size); memcpy(tmp, model.name, size);
Models[mode] = tmp; Models[mode] = tmp;
width[mode] = plen(model.spoly); width[mode] = plen(model.spoly);

View file

@ -491,8 +491,8 @@ int ASKDemod_ext(const char *Cmd, bool verbose, bool emSearch, uint8_t askType,
// if (*stCheck) // if (*stCheck)
bool st = DetectST(bits, &BitLen, &foundclk, &ststart, &stend); bool st = DetectST(bits, &BitLen, &foundclk, &ststart, &stend);
if ( clk == 0 ) { if (clk == 0) {
if ( foundclk == 32 || foundclk == 64 ) { if (foundclk == 32 || foundclk == 64) {
clk = foundclk; clk = foundclk;
} }
} }
@ -615,12 +615,15 @@ int Cmdmandecoderaw(const char *Cmd) {
return 1; return 1;
} }
//by marshmellow /*
//biphase decode * @author marshmellow
//take 01 or 10 = 0 and 11 or 00 = 1 * biphase decode
//takes 2 arguments "offset" default = 0 if 1 it will shift the decode by one bit * decodes 01 or 10 -> ZERO
// and "invert" default = 0 if 1 it will invert output * 11 or 00 -> ONE
// the argument offset allows us to manually shift if the output is incorrect - [EDIT: now auto detects] * param offset adjust start position
* param invert invert output
* param masxErr maximum tolerated errors
*/
int CmdBiphaseDecodeRaw(const char *Cmd) { int CmdBiphaseDecodeRaw(const char *Cmd) {
size_t size = 0; size_t size = 0;
int offset = 0, invert = 0, maxErr = 20, errCnt = 0; int offset = 0, invert = 0, maxErr = 20, errCnt = 0;
@ -1317,7 +1320,7 @@ int CmdRawDemod(const char *Cmd) {
void setClockGrid(int clk, int offset) { void setClockGrid(int clk, int offset) {
g_DemodStartIdx = offset; g_DemodStartIdx = offset;
g_DemodClock = clk; g_DemodClock = clk;
if ( clk == 0 && offset == 0) if (clk == 0 && offset == 0)
PrintAndLogEx(DEBUG, "DEBUG: (setClockGrid) clear settings"); PrintAndLogEx(DEBUG, "DEBUG: (setClockGrid) clear settings");
else else
PrintAndLogEx(DEBUG, "DEBUG: (setClockGrid) demodoffset %d, clk %d", offset, clk); PrintAndLogEx(DEBUG, "DEBUG: (setClockGrid) demodoffset %d, clk %d", offset, clk);

View file

@ -524,7 +524,7 @@ int CmdHF14AInfo(const char *Cmd) {
(tb1 ? "" : " NOT"), (tb1 ? "" : " NOT"),
(tc1 ? "" : " NOT"), (tc1 ? "" : " NOT"),
fsci, fsci,
fsci < sizeof(atsFSC)/sizeof(atsFSC[0]) ? atsFSC[fsci] : -1 fsci < sizeof(atsFSC) / sizeof(atsFSC[0]) ? atsFSC[fsci] : -1
); );
} }
pos = 2; pos = 2;
@ -544,7 +544,7 @@ int CmdHF14AInfo(const char *Cmd) {
((card.ats[pos] & 0x80) ? " NOT" : ""), ((card.ats[pos] & 0x80) ? " NOT" : ""),
dr, dr,
ds ds
); );
pos++; pos++;
} }
@ -959,7 +959,7 @@ int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
// get frame length from ATS in data field // get frame length from ATS in data field
if (resp.arg[0] > 1) { if (resp.arg[0] > 1) {
uint8_t fsci = resp.d.asBytes[1] & 0x0f; uint8_t fsci = resp.d.asBytes[1] & 0x0f;
if (fsci < sizeof(atsFSC)/sizeof(atsFSC[0])) if (fsci < sizeof(atsFSC) / sizeof(atsFSC[0]))
frameLength = atsFSC[fsci]; frameLength = atsFSC[fsci];
} }
} else { } else {
@ -967,7 +967,7 @@ int SelectCard14443_4(bool disconnect, iso14a_card_select_t *card) {
iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.d.asBytes; iso14a_card_select_t *vcard = (iso14a_card_select_t *) resp.d.asBytes;
if (vcard->ats_len > 1) { if (vcard->ats_len > 1) {
uint8_t fsci = vcard->ats[1] & 0x0f; uint8_t fsci = vcard->ats[1] & 0x0f;
if (fsci < sizeof(atsFSC)/sizeof(atsFSC[0])) if (fsci < sizeof(atsFSC) / sizeof(atsFSC[0]))
frameLength = atsFSC[fsci]; frameLength = atsFSC[fsci];
} }
@ -1001,7 +1001,7 @@ int CmdExchangeAPDU(bool chainingin, uint8_t *datain, int datainlen, bool activa
// timeout must be authomatically set by "get ATS" // timeout must be authomatically set by "get ATS"
UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}}; UsbCommand c = {CMD_READER_ISO_14443a, {ISO14A_APDU | ISO14A_NO_DISCONNECT | cmdc, (datainlen & 0xFFFF), 0}};
if ( datain ) if (datain)
memcpy(c.d.asBytes, datain, datainlen); memcpy(c.d.asBytes, datain, datainlen);
SendCommand(&c); SendCommand(&c);

View file

@ -169,7 +169,7 @@ int CmdLegicInfo(const char *Cmd) {
int crc = 0, wrp = 0, wrc = 0; int crc = 0, wrp = 0, wrc = 0;
uint8_t stamp_len = 0; uint8_t stamp_len = 0;
uint16_t datalen = 0; uint16_t datalen = 0;
char token_type[5] = {0, 0, 0, 0, 0}; char token_type[6] = {0, 0, 0, 0, 0, 0};
int dcf = 0; int dcf = 0;
int bIsSegmented = 0; int bIsSegmented = 0;

View file

@ -423,7 +423,7 @@ int CmdVersion(const char *Cmd) {
#else #else
PrintAndLogEx(NORMAL, "\n\e[34m [ Proxmark3 RFID instrument ]\e[0m\n"); PrintAndLogEx(NORMAL, "\n\e[34m [ Proxmark3 RFID instrument ]\e[0m\n");
#endif #endif
char s[50] = {0}; char s[60] = {0};
#if defined(WITH_FLASH) || defined(WITH_SMARTCARD) || defined(WITH_FPC) #if defined(WITH_FLASH) || defined(WITH_SMARTCARD) || defined(WITH_FPC)
strncat(s, "build for RDV40 with ", sizeof(s) - strlen(s) - 1); strncat(s, "build for RDV40 with ", sizeof(s) - strlen(s) - 1);
#endif #endif
@ -434,7 +434,11 @@ int CmdVersion(const char *Cmd) {
strncat(s, "smartcard; ", sizeof(s) - strlen(s) - 1); strncat(s, "smartcard; ", sizeof(s) - strlen(s) - 1);
#endif #endif
#ifdef WITH_FPC #ifdef WITH_FPC
#ifdef WITH_FPC_HOST
strncat(s, "fpc-host; ", sizeof(s) - strlen(s) - 1);
#else
strncat(s, "fpc; ", sizeof(s) - strlen(s) - 1); strncat(s, "fpc; ", sizeof(s) - strlen(s) - 1);
#endif
#endif #endif
PrintAndLogEx(NORMAL, "\n [ CLIENT ]"); PrintAndLogEx(NORMAL, "\n [ CLIENT ]");
PrintAndLogEx(NORMAL, " client: iceman %s \n", s); PrintAndLogEx(NORMAL, " client: iceman %s \n", s);

View file

@ -839,7 +839,7 @@ bool CheckChipType(bool getDeviceData) {
//check for t55xx chip... //check for t55xx chip...
if (tryDetectP1(true)) { if (tryDetectP1(true)) {
PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("Atmel T55xx") " found"); PrintAndLogEx(SUCCESS, "\nChipset detection : " _GREEN_("T55xx") " found");
PrintAndLogEx(SUCCESS, "Try " _YELLOW_("`lf t55xx`")" commands"); PrintAndLogEx(SUCCESS, "Try " _YELLOW_("`lf t55xx`")" commands");
retval = true; retval = true;
goto out; goto out;

View file

@ -467,7 +467,7 @@ static bool getHitagUid(uint32_t *uid) {
return false; return false;
} }
if ( uid ) if (uid)
*uid = bytes_to_num(resp.d.asBytes, 4); *uid = bytes_to_num(resp.d.asBytes, 4);
return true; return true;
@ -485,7 +485,7 @@ int CmdLFHitagInfo(const char *Cmd) {
// read UID // read UID
uint32_t uid = 0; uint32_t uid = 0;
if ( getHitagUid( &uid ) == false ) if (getHitagUid(&uid) == false)
return 1; return 1;
PrintAndLogEx(SUCCESS, "UID: %08X", uid); PrintAndLogEx(SUCCESS, "UID: %08X", uid);
@ -569,7 +569,7 @@ int CmdLFHitagReader(const char *Cmd) {
PrintAndLogEx(SUCCESS, "Valid Hitag2 tag found - UID: %08x", id); PrintAndLogEx(SUCCESS, "Valid Hitag2 tag found - UID: %08x", id);
if (htf != RHT2F_UID_ONLY) { if (htf != RHT2F_UID_ONLY) {
PrintAndLogEx(SUCCESS, "Dumping tag memory..." ); PrintAndLogEx(SUCCESS, "Dumping tag memory...");
uint8_t *data = resp.d.asBytes; uint8_t *data = resp.d.asBytes;
char filename[FILE_PATH_SIZE]; char filename[FILE_PATH_SIZE];
@ -582,7 +582,7 @@ int CmdLFHitagReader(const char *Cmd) {
saveFileJSON(filename, "json", jsfHitag, data, 48); saveFileJSON(filename, "json", jsfHitag, data, 48);
// block3, 1 byte // block3, 1 byte
printHitagConfiguration(data[4*3] ); printHitagConfiguration(data[4 * 3]);
} }
return 0; return 0;
} }

View file

@ -47,7 +47,7 @@ int usage_lf_indala_sim(void) {
int usage_lf_indala_clone(void) { int usage_lf_indala_clone(void) {
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Usage: lf indala clone [h]<l> <uid> [Q5]"); PrintAndLogEx(NORMAL, "Usage: lf indala clone [h]<l> <uid> [Q5]");
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h : This help"); PrintAndLogEx(NORMAL, " h : This help");
@ -73,14 +73,14 @@ int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
// PSK1 // PSK1
bool res = preambleSearch(dest, preamble64, sizeof(preamble64), &found_size, &idx); bool res = preambleSearch(dest, preamble64, sizeof(preamble64), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK1 found 64"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK1 found 64");
goto out; goto out;
} }
idx = 0; idx = 0;
found_size = *size; found_size = *size;
res = preambleSearch(dest, preamble64_i, sizeof(preamble64_i), &found_size, &idx); res = preambleSearch(dest, preamble64_i, sizeof(preamble64_i), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK1 found 64 inverted preamble"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK1 found 64 inverted preamble");
goto inv; goto inv;
} }
@ -110,7 +110,7 @@ int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
idx = 0; idx = 0;
found_size = *size; found_size = *size;
res = preambleSearch(dest, preamble64, sizeof(preamble64), &found_size, &idx); res = preambleSearch(dest, preamble64, sizeof(preamble64), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 64 preamble"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 64 preamble");
goto out; goto out;
} }
@ -118,7 +118,7 @@ int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
idx = 0; idx = 0;
found_size = *size; found_size = *size;
res = preambleSearch(dest, preamble224, sizeof(preamble224), &found_size, &idx); res = preambleSearch(dest, preamble224, sizeof(preamble224), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 224 preamble"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 224 preamble");
goto out; goto out;
} }
@ -126,7 +126,7 @@ int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
idx = 0; idx = 0;
found_size = *size; found_size = *size;
res = preambleSearch(dest, preamble64_i, sizeof(preamble64_i), &found_size, &idx); res = preambleSearch(dest, preamble64_i, sizeof(preamble64_i), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 64 inverted preamble"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 64 inverted preamble");
goto inv; goto inv;
} }
@ -134,13 +134,13 @@ int detectIndala(uint8_t *dest, size_t *size, uint8_t *invert) {
idx = 0; idx = 0;
found_size = *size; found_size = *size;
res = preambleSearch(dest, preamble224_i, sizeof(preamble224_i), &found_size, &idx); res = preambleSearch(dest, preamble224_i, sizeof(preamble224_i), &found_size, &idx);
if ( res ) { if (res) {
PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 224 inverted preamble"); PrintAndLogEx(DEBUG, "DEBUG: detectindala PSK2 found 224 inverted preamble");
goto inv; goto inv;
} }
inv: inv:
if ( res == 0 ) { if (res == 0) {
return -4; return -4;
} }
@ -215,7 +215,7 @@ int CmdIndalaDemod(const char *Cmd) {
uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7; uint32_t uid1, uid2, uid3, uid4, uid5, uid6, uid7;
uid1 = bytebits_to_byte(DemodBuffer, 32); uid1 = bytebits_to_byte(DemodBuffer, 32);
uid2 = bytebits_to_byte(DemodBuffer + 32, 32); uid2 = bytebits_to_byte(DemodBuffer + 32, 32);
uint64_t foo = (((uint64_t)uid1 << 32) & 0x1FFFFFFF ) | (uid2 & 0x7FFFFFFF ); uint64_t foo = (((uint64_t)uid1 << 32) & 0x1FFFFFFF) | (uid2 & 0x7FFFFFFF);
if (DemodBufferLen == 64) { if (DemodBufferLen == 64) {
PrintAndLogEx( PrintAndLogEx(
@ -227,36 +227,36 @@ int CmdIndalaDemod(const char *Cmd) {
); );
uint16_t p1 = 0; uint16_t p1 = 0;
p1 |= DemodBuffer[32+ 3] << 8; p1 |= DemodBuffer[32 + 3] << 8;
p1 |= DemodBuffer[32+ 6] << 5; p1 |= DemodBuffer[32 + 6] << 5;
p1 |= DemodBuffer[32+ 8] << 4; p1 |= DemodBuffer[32 + 8] << 4;
p1 |= DemodBuffer[32+ 9] << 3; p1 |= DemodBuffer[32 + 9] << 3;
p1 |= DemodBuffer[32+11] << 1; p1 |= DemodBuffer[32 + 11] << 1;
p1 |= DemodBuffer[32+16] << 6; p1 |= DemodBuffer[32 + 16] << 6;
p1 |= DemodBuffer[32+19] << 7; p1 |= DemodBuffer[32 + 19] << 7;
p1 |= DemodBuffer[32+20] << 10; p1 |= DemodBuffer[32 + 20] << 10;
p1 |= DemodBuffer[32+21] << 2; p1 |= DemodBuffer[32 + 21] << 2;
p1 |= DemodBuffer[32+22] << 0; p1 |= DemodBuffer[32 + 22] << 0;
p1 |= DemodBuffer[32+24] << 9; p1 |= DemodBuffer[32 + 24] << 9;
/* /*
uint16_t fc = 0; uint16_t fc = 0;
fc |= DemodBuffer[32+ 1] << 0; fc |= DemodBuffer[32+ 1] << 0;
fc |= DemodBuffer[32+ 2] << 1; fc |= DemodBuffer[32+ 2] << 1;
fc |= DemodBuffer[32+ 4] << 2; fc |= DemodBuffer[32+ 4] << 2;
fc |= DemodBuffer[32+ 5] << 3; fc |= DemodBuffer[32+ 5] << 3;
fc |= DemodBuffer[32+ 7] << 4; fc |= DemodBuffer[32+ 7] << 4;
fc |= DemodBuffer[32+10] << 5; fc |= DemodBuffer[32+10] << 5;
fc |= DemodBuffer[32+14] << 6; fc |= DemodBuffer[32+14] << 6;
fc |= DemodBuffer[32+15] << 7; fc |= DemodBuffer[32+15] << 7;
fc |= DemodBuffer[32+17] << 8; fc |= DemodBuffer[32+17] << 8;
*/ */
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(SUCCESS, "Possible de-scramble patterns"); PrintAndLogEx(SUCCESS, "Possible de-scramble patterns");
PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", p1, p1); PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", p1, p1);
//PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", fc, fc); //PrintAndLogEx(SUCCESS, "\tPrinted | __%04d__ [0x%X]", fc, fc);
PrintAndLogEx(SUCCESS, "\tInternal ID | %" PRIu64 , foo); PrintAndLogEx(SUCCESS, "\tInternal ID | %" PRIu64, foo);
} else { } else {
@ -266,15 +266,15 @@ int CmdIndalaDemod(const char *Cmd) {
uid6 = bytebits_to_byte(DemodBuffer + 160, 32); uid6 = bytebits_to_byte(DemodBuffer + 160, 32);
uid7 = bytebits_to_byte(DemodBuffer + 192, 32); uid7 = bytebits_to_byte(DemodBuffer + 192, 32);
PrintAndLogEx(SUCCESS, "Indala Found - bitlength %d, UID = 0x%x%08x%08x%08x%08x%08x%08x" PrintAndLogEx(SUCCESS, "Indala Found - bitlength %d, UID = 0x%x%08x%08x%08x%08x%08x%08x"
, DemodBufferLen , DemodBufferLen
, uid1 , uid1
, uid2 , uid2
, uid3 , uid3
, uid4 , uid4
, uid5 , uid5
, uid6 , uid6
, uid7 , uid7
); );
} }
if (g_debugMode) { if (g_debugMode) {
@ -532,7 +532,7 @@ int CmdIndalaSim(const char *Cmd) {
int CmdIndalaClone(const char *Cmd) { int CmdIndalaClone(const char *Cmd) {
bool isLongUid = false; bool isLongUid = false;
uint8_t data[7*4]; uint8_t data[7 * 4];
int datalen = 0; int datalen = 0;
CLIParserInit("lf indala clone", CLIParserInit("lf indala clone",
@ -555,7 +555,7 @@ int CmdIndalaClone(const char *Cmd) {
CLIGetHexWithReturn(2, data, &datalen); CLIGetHexWithReturn(2, data, &datalen);
CLIParserFree(); CLIParserFree();
UsbCommand c = {0, {0,0,0}}; UsbCommand c = {0, {0, 0, 0}};
if (isLongUid) { if (isLongUid) {
PrintAndLogEx(INFO, "Preparing to clone Indala 224bit tag with UID %s", sprint_hex(data, datalen)); PrintAndLogEx(INFO, "Preparing to clone Indala 224bit tag with UID %s", sprint_hex(data, datalen));

View file

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

View file

@ -237,10 +237,10 @@ int CmdPyramidDemod(const char *Cmd) {
} }
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - %02X - %s" PrintAndLogEx(DEBUG, "DEBUG: Pyramid: checksum : 0x%02X - %02X - %s"
, checksum , checksum
, checkCS , checkCS
, (checksum == checkCS) ? _GREEN_("Passed") : _RED_("Failed") , (checksum == checkCS) ? _GREEN_("Passed") : _RED_("Failed")
); );
PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128); PrintAndLogEx(DEBUG, "DEBUG: Pyramid: idx: %d, Len: %d, Printing Demod Buffer:", idx, 128);
if (g_debugMode) if (g_debugMode)

View file

@ -19,15 +19,15 @@ void Set_t55xx_Config(t55xx_conf_block_t conf) {
} }
int usage_t55xx_config() { int usage_t55xx_config() {
PrintAndLogEx(NORMAL, "Usage: lf t55xx config [d <demodulation>] [i 1] [o <offset>] [Q5]"); PrintAndLogEx(NORMAL, "Usage: lf t55xx config [d <demodulation>] [i [0/1]] [o <offset>] [Q5 [0/1]] [ST [0/1]]");
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " h - This help"); PrintAndLogEx(NORMAL, " h - This help");
PrintAndLogEx(NORMAL, " b <8|16|32|40|50|64|100|128> - Set bitrate"); PrintAndLogEx(NORMAL, " b <8|16|32|40|50|64|100|128> - Set bitrate");
PrintAndLogEx(NORMAL, " d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa> - Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A"); PrintAndLogEx(NORMAL, " d <FSK|FSK1|FSK1a|FSK2|FSK2a|ASK|PSK1|PSK2|NRZ|BI|BIa> - Set demodulation FSK / ASK / PSK / NRZ / Biphase / Biphase A");
PrintAndLogEx(NORMAL, " i [1] - Invert data signal, defaults to normal"); PrintAndLogEx(NORMAL, " i [0/1] - Set/reset data signal inversion");
PrintAndLogEx(NORMAL, " o [offset] - Set offset, where data should start decode in bitstream"); PrintAndLogEx(NORMAL, " o [offset] - Set offset, where data should start decode in bitstream");
PrintAndLogEx(NORMAL, " Q5 - Set as Q5(T5555) chip instead of T55x7"); PrintAndLogEx(NORMAL, " Q5 [0/1] - Set/reset as Q5(T5555) chip instead of T55x7");
PrintAndLogEx(NORMAL, " ST - Set Sequence Terminator on"); PrintAndLogEx(NORMAL, " ST [0/1] - Set/reset Sequence Terminator on");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf t55xx config d FSK - FSK demodulation"); PrintAndLogEx(NORMAL, " lf t55xx config d FSK - FSK demodulation");
@ -81,13 +81,19 @@ int usage_t55xx_trace() {
return 0; return 0;
} }
int usage_t55xx_info() { int usage_t55xx_info() {
PrintAndLogEx(NORMAL, "Usage: lf t55xx info [1]"); PrintAndLogEx(NORMAL, "Usage: lf t55xx info [1] [d <data> [q]]");
PrintAndLogEx(NORMAL, "Options:"); PrintAndLogEx(NORMAL, "Options:");
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer otherwise read data from tag."); PrintAndLogEx(NORMAL, " (default) - read data from tag.");
PrintAndLogEx(NORMAL, " 1 - if set, use Graphbuffer instead of reading tag.");
PrintAndLogEx(NORMAL, " d <data> - 4 bytes of data (8 hex characters)");
PrintAndLogEx(NORMAL, " if set, use these data instead of reading tag.");
PrintAndLogEx(NORMAL, " q - if set, provided data are interpreted as Q5 config.");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "Examples:"); PrintAndLogEx(NORMAL, "Examples:");
PrintAndLogEx(NORMAL, " lf t55xx info"); PrintAndLogEx(NORMAL, " lf t55xx info");
PrintAndLogEx(NORMAL, " lf t55xx info 1"); PrintAndLogEx(NORMAL, " lf t55xx info 1");
PrintAndLogEx(NORMAL, " lf t55xx info d 00083040");
PrintAndLogEx(NORMAL, " lf t55xx info d 6001805A q");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
return 0; return 0;
} }
@ -300,8 +306,13 @@ int CmdT55xxSetConfig(const char *Cmd) {
} }
break; break;
case 'i': case 'i':
config.inverted = param_getchar(Cmd, cmdp + 1) == '1'; if ((param_getchar(Cmd, cmdp + 1) == '0') || (param_getchar(Cmd, cmdp + 1) == '1')) {
cmdp += 2; config.inverted = param_getchar(Cmd, cmdp + 1) == '1';
cmdp += 2;
} else {
config.inverted = true;
cmdp += 1;
}
break; break;
case 'o': case 'o':
errors |= param_getdec(Cmd, cmdp + 1, &offset); errors |= param_getdec(Cmd, cmdp + 1, &offset);
@ -310,12 +321,22 @@ int CmdT55xxSetConfig(const char *Cmd) {
cmdp += 2; cmdp += 2;
break; break;
case 'q': case 'q':
config.Q5 = true; if ((param_getchar(Cmd, cmdp + 1) == '0') || (param_getchar(Cmd, cmdp + 1) == '1')) {
cmdp++; config.Q5 = param_getchar(Cmd, cmdp + 1) == '1';
cmdp += 2;
} else {
config.Q5 = true;
cmdp += 1;
}
break; break;
case 's': case 's':
config.ST = true; if ((param_getchar(Cmd, cmdp + 1) == '0') || (param_getchar(Cmd, cmdp + 1) == '1')) {
cmdp++; config.ST = param_getchar(Cmd, cmdp + 1) == '1';
cmdp += 2;
} else {
config.ST = true;
cmdp += 1;
}
break; break;
default: default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp)); PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
@ -1079,7 +1100,7 @@ int CmdT55xxReadTrace(const char *Cmd) {
// sanity check. // sanity check.
if (!SanityOfflineCheck(false)) return 1; if (!SanityOfflineCheck(false)) return 1;
if (!AquireData(T55x7_PAGE1, REGULAR_READ_MODE_BLOCK, pwdmode, password)) if (!AquireData(T55x7_PAGE1, T55x7_TRACE_BLOCK1, pwdmode, password))
return 1; return 1;
} }
@ -1251,7 +1272,72 @@ void printT5555Trace(t5555_tracedata_t data, uint8_t repeat) {
*/ */
} }
//need to add Q5 info... static void printT5x7KnownBlock0(uint32_t b0) {
char s[40];
memset(s, 0, sizeof(s));
switch (b0) {
case T55X7_DEFAULT_CONFIG_BLOCK:
snprintf(s, sizeof(s) - strlen(s), "T55x7 Default ");
break;
case T55X7_RAW_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "T55x7 Raw ");
break;
case T55X7_EM_UNIQUE_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "EM Unique ");
break;
/*
case T55X7_EM_PAXTON_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s)-strlen(s), "EM Paxton ");
break;
*/
case T55X7_FDXB_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "FDXB ");
break;
case T55X7_HID_26_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "HID 26b ");
break;
case T55X7_PYRAMID_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Pyramid ");
break;
case T55X7_INDALA_64_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 64");
break;
case T55X7_INDALA_224_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Indala 224 ");
break;
case T55X7_GUARDPROXII_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Guard Prox II ");
break;
case T55X7_VIKING_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Viking ");
break;
case T55X7_NORALYS_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Noralys ");
break;
case T55X7_IOPROX_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "IO Prox ");
break;
case T55X7_PRESCO_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Presco ");
break;
case T55X7_NEDAP_64_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Nedap 64 ");
break;
case T55X7_NEDAP_128_CONFIG_BLOCK:
snprintf(s + strlen(s), sizeof(s) - strlen(s), "Nedap 128 ");
break;
default:
break;
}
if (strlen(s) > 0) {
PrintAndLogEx(NORMAL, " Known T55x7 Config block found : " _YELLOW_("%s"), s);
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
}
}
int CmdT55xxInfo(const char *Cmd) { int CmdT55xxInfo(const char *Cmd) {
/* /*
Page 0 Block 0 Configuration data. Page 0 Block 0 Configuration data.
@ -1259,82 +1345,133 @@ int CmdT55xxInfo(const char *Cmd) {
Extended mode Extended mode
*/ */
bool pwdmode = false; bool pwdmode = false;
bool frombuff = false;
bool gotdata = false;
bool dataasq5 = false;
uint32_t password = 0; uint32_t password = 0;
char cmdp = tolower(param_getchar(Cmd, 0)); uint32_t block0 = 0;
uint8_t cmdp = 0;
if (strlen(Cmd) > 1 || cmdp == 'h') return usage_t55xx_info(); while (param_getchar(Cmd, cmdp) != 0x00) {
switch (tolower(param_getchar(Cmd, cmdp))) {
case 'h':
return usage_t55xx_info();
case 'd':
block0 = param_get32ex(Cmd, cmdp + 1, 0, 16);
gotdata = true;
cmdp += 2;
break;
case '1':
frombuff = true;
cmdp += 2;
break;
case 'q':
dataasq5 = true;
cmdp += 2;
break;
default:
PrintAndLogEx(WARNING, "Unknown parameter '%c'", param_getchar(Cmd, cmdp));
return usage_t55xx_info();
}
}
if (strlen(Cmd) == 0) { if (gotdata && frombuff)
return usage_t55xx_info();
if (dataasq5 && !gotdata)
return usage_t55xx_info();
if (!frombuff && !gotdata) {
// sanity check. // sanity check.
if (!SanityOfflineCheck(false)) return 1; if (!SanityOfflineCheck(false)) return 1;
if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, pwdmode, password)) if (!AquireData(T55x7_PAGE0, T55x7_CONFIGURATION_BLOCK, pwdmode, password))
return 1; return 1;
} }
if (!gotdata) {
if (!DecodeT55xxBlock()) return 1;
if (!DecodeT55xxBlock()) return 1; // too little space to start with
if (DemodBufferLen < 32 + config.offset) return 1;
// too little space to start with //PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, DemodBufferLen);
if (DemodBufferLen < 32) return 1; block0 = PackBits(config.offset, 32, DemodBuffer);
}
//
//PrintAndLogEx(NORMAL, "Offset+32 ==%d\n DemodLen == %d", config.offset + 32, DemodBufferLen);
uint8_t si = config.offset;
uint32_t block0 = PackBits(si, 32, DemodBuffer);
uint32_t safer = PackBits(si, 4, DemodBuffer);
si += 4;
uint32_t resv = PackBits(si, 7, DemodBuffer);
si += 7;
uint32_t dbr = PackBits(si, 3, DemodBuffer);
si += 3;
uint32_t extend = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t datamod = PackBits(si, 5, DemodBuffer);
si += 5;
uint32_t pskcf = PackBits(si, 2, DemodBuffer);
si += 2;
uint32_t aor = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t otp = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t maxblk = PackBits(si, 3, DemodBuffer);
si += 3;
uint32_t pwd = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t sst = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t fw = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t inv = PackBits(si, 1, DemodBuffer);
si += 1;
uint32_t por = PackBits(si, 1, DemodBuffer);
si += 1;
if (config.Q5)
PrintAndLogEx(NORMAL, _RED_("* **Warning ***") " Config Info read off a Q5 will not display as expected");
PrintAndLogEx(NORMAL, ""); PrintAndLogEx(NORMAL, "");
PrintAndLogEx(NORMAL, "-- T55x7 Configuration & Tag Information --------------------"); if (((!gotdata) && config.Q5) || (gotdata && dataasq5)) {
PrintAndLogEx(NORMAL, "-------------------------------------------------------------"); uint32_t header = (block0 >> (32 - 12)) & 0xFFF;
PrintAndLogEx(NORMAL, " Safer key : %s", GetSaferStr(safer)); uint32_t ps = (block0 >> (32 - 13)) & 0x01;
PrintAndLogEx(NORMAL, " reserved : %d", resv); uint32_t fw = (block0 >> (32 - 14)) & 0x01;
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, extend)); uint32_t dbr = (block0 >> (32 - 20)) & 0x3F;
PrintAndLogEx(NORMAL, " eXtended mode : %s", (extend) ? _YELLOW_("Yes - Warning") : "No"); uint32_t aor = (block0 >> (32 - 21)) & 0x01;
PrintAndLogEx(NORMAL, " Modulation : %s", GetModulationStr(datamod)); uint32_t pwd = (block0 >> (32 - 22)) & 0x01;
PrintAndLogEx(NORMAL, " PSK clock frequency : %d", pskcf); uint32_t pskcf = (block0 >> (32 - 24)) & 0x03;
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No"); uint32_t inv = (block0 >> (32 - 25)) & 0x01;
PrintAndLogEx(NORMAL, " OTP - One Time Pad : %s", (otp) ? _YELLOW_("Yes - Warning") : "No"); uint32_t datamod = (block0 >> (32 - 28)) & 0x07;
PrintAndLogEx(NORMAL, " Max block : %d", maxblk); uint32_t maxblk = (block0 >> (32 - 31)) & 0x07;
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No"); uint32_t st = (block0 >> (32 - 32)) & 0x01;
PrintAndLogEx(NORMAL, " Sequence Start Terminator : %s", (sst) ? _GREEN_("Yes") : "No"); PrintAndLogEx(NORMAL, "-- Q5 Configuration & Tag Information -----------------------");
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? _GREEN_("Yes") : "No"); PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? _GREEN_("Yes") : "No"); PrintAndLogEx(NORMAL, " Header : 0x%03X%s", header, (header != 0x600) ? _RED_(" - Warning") : "");
PrintAndLogEx(NORMAL, " POR-Delay : %s", (por) ? _GREEN_("Yes") : "No"); PrintAndLogEx(NORMAL, " Page select : %d", ps);
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, 1));
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " PSK clock frequency : %s", GetPskCfStr(pskcf, 1));
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Modulation : %s", GetQ5ModulationStr(datamod));
PrintAndLogEx(NORMAL, " Max block : %d", maxblk);
PrintAndLogEx(NORMAL, " Sequence Terminator : %s", (st) ? _GREEN_("Yes") : "No");
} else {
uint32_t safer = (block0 >> (32 - 4)) & 0x0F;
uint32_t extend = (block0 >> (32 - 15)) & 0x01;
uint32_t resv, dbr;
if (extend) {
resv = (block0 >> (32 - 8)) & 0x0F;
dbr = (block0 >> (32 - 14)) & 0x3F;
} else {
resv = (block0 >> (32 - 11)) & 0x7F;
dbr = (block0 >> (32 - 14)) & 0x07;
}
uint32_t datamod = (block0 >> (32 - 20)) & 0x1F;
uint32_t pskcf = (block0 >> (32 - 22)) & 0x03;
uint32_t aor = (block0 >> (32 - 23)) & 0x01;
uint32_t otp = (block0 >> (32 - 24)) & 0x01;
uint32_t maxblk = (block0 >> (32 - 27)) & 0x07;
uint32_t pwd = (block0 >> (32 - 28)) & 0x01;
uint32_t sst = (block0 >> (32 - 29)) & 0x01;
uint32_t fw = (block0 >> (32 - 30)) & 0x01;
uint32_t inv = (block0 >> (32 - 31)) & 0x01;
uint32_t por = (block0 >> (32 - 32)) & 0x01;
PrintAndLogEx(NORMAL, "-- T55x7 Configuration & Tag Information --------------------");
PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
PrintAndLogEx(NORMAL, " Safer key : %s", GetSaferStr(safer));
PrintAndLogEx(NORMAL, " reserved : %d", resv);
PrintAndLogEx(NORMAL, " Data bit rate : %s", GetBitRateStr(dbr, extend));
PrintAndLogEx(NORMAL, " eXtended mode : %s", (extend) ? _YELLOW_("Yes - Warning") : "No");
PrintAndLogEx(NORMAL, " Modulation : %s", GetModulationStr(datamod, extend));
PrintAndLogEx(NORMAL, " PSK clock frequency : %s", GetPskCfStr(pskcf, 0));
PrintAndLogEx(NORMAL, " AOR - Answer on Request : %s", (aor) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " OTP - One Time Pad : %s", (otp) ? ((extend) ? _YELLOW_("Yes - Warning") : _RED_("Yes - Warning")) : "No");
PrintAndLogEx(NORMAL, " Max block : %d", maxblk);
PrintAndLogEx(NORMAL, " Password mode : %s", (pwd) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Sequence %-12s : %s", (extend) ? "Start Marker" : "Terminator", (sst) ? _GREEN_("Yes") : "No");
PrintAndLogEx(NORMAL, " Fast Write : %s", (fw) ? ((extend) ? _GREEN_("Yes") : _RED_("Yes - Warning")) : "No");
PrintAndLogEx(NORMAL, " Inverse data : %s", (inv) ? ((extend) ? _GREEN_("Yes") : _RED_("Yes - Warning")) : "No");
PrintAndLogEx(NORMAL, " POR-Delay : %s", (por) ? _GREEN_("Yes") : "No");
}
PrintAndLogEx(NORMAL, "-------------------------------------------------------------"); PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
PrintAndLogEx(NORMAL, " Raw Data - Page 0"); PrintAndLogEx(NORMAL, " Raw Data - Page 0");
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X %s", block0, sprint_bin(DemodBuffer + config.offset, 32)); if (gotdata)
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X", block0);
else
PrintAndLogEx(NORMAL, " Block 0 : 0x%08X %s", block0, sprint_bin(DemodBuffer + config.offset, 32));
PrintAndLogEx(NORMAL, "-------------------------------------------------------------"); PrintAndLogEx(NORMAL, "-------------------------------------------------------------");
if (((!gotdata) && (!config.Q5)) || (gotdata && (!dataasq5)))
printT5x7KnownBlock0(block0);
return 0; return 0;
} }
@ -1369,7 +1506,7 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
// bit1 = page to read from // bit1 = page to read from
// arg1: which block to read // arg1: which block to read
// arg2: password // arg2: password
uint8_t arg0 = ( page << 1 | (pwdmode) ); uint8_t arg0 = (page << 1 | (pwdmode));
UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}}; UsbCommand c = {CMD_T55XX_READ_BLOCK, {arg0, block, password}};
clearCommandBuffer(); clearCommandBuffer();
SendCommand(&c); SendCommand(&c);
@ -1383,6 +1520,32 @@ bool AquireData(uint8_t page, uint8_t block, bool pwdmode, uint32_t password) {
return !getSignalProperties()->isnoise; return !getSignalProperties()->isnoise;
} }
char *GetPskCfStr(uint32_t id, bool q5) {
static char buf[25];
char *retStr = buf;
switch (id) {
case 0:
snprintf(retStr, sizeof(buf), "%u - RF/2", id);
break;
case 1:
snprintf(retStr, sizeof(buf), "%u - RF/4", id);
break;
case 2:
snprintf(retStr, sizeof(buf), "%u - RF/8", id);
break;
case 3:
if (q5)
snprintf(retStr, sizeof(buf), "%u - RF/8", id);
else
snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
break;
default:
snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
break;
}
return buf;
}
char *GetBitRateStr(uint32_t id, bool xmode) { char *GetBitRateStr(uint32_t id, bool xmode) {
static char buf[25]; static char buf[25];
@ -1416,7 +1579,7 @@ char *GetBitRateStr(uint32_t id, bool xmode) {
snprintf(retStr, sizeof(buf), "%u - RF/128", id); snprintf(retStr, sizeof(buf), "%u - RF/128", id);
break; break;
default: default:
snprintf(retStr, sizeof(buf), "%u - (Unknown)", id); snprintf(retStr, sizeof(buf), "%u - " _RED_("(Unknown)"), id);
break; break;
} }
} }
@ -1438,7 +1601,7 @@ char *GetSaferStr(uint32_t id) {
return buf; return buf;
} }
char *GetModulationStr(uint32_t id) { char *GetModulationStr(uint32_t id, bool xmode) {
static char buf[60]; static char buf[60];
char *retStr = buf; char *retStr = buf;
@ -1462,10 +1625,10 @@ char *GetModulationStr(uint32_t id) {
snprintf(retStr, sizeof(buf), "%u - FSK 2 RF/8 RF/10", id); snprintf(retStr, sizeof(buf), "%u - FSK 2 RF/8 RF/10", id);
break; break;
case 6: case 6:
snprintf(retStr, sizeof(buf), "%u - FSK 1a RF/5 RF/8", id); snprintf(retStr, sizeof(buf), "%u - %s RF/5 RF/8", id, (xmode) ? "FSK 1a" : _YELLOW_("FSK 1a"));
break; break;
case 7: case 7:
snprintf(retStr, sizeof(buf), "%u - FSK 2a RF/10 RF/8", id); snprintf(retStr, sizeof(buf), "%u - %s RF/10 RF/8", id, (xmode) ? "FSK 2a" : _YELLOW_("FSK 2a"));
break; break;
case 8: case 8:
snprintf(retStr, sizeof(buf), "%u - Manchester", id); snprintf(retStr, sizeof(buf), "%u - Manchester", id);
@ -1473,14 +1636,44 @@ char *GetModulationStr(uint32_t id) {
case 16: case 16:
snprintf(retStr, sizeof(buf), "%u - Biphase", id); snprintf(retStr, sizeof(buf), "%u - Biphase", id);
break; break;
case 0x18: case 24:
snprintf(retStr, sizeof(buf), "%u - Biphase a - AKA Conditional Dephase Encoding(CDP)", id); snprintf(retStr, sizeof(buf), "%u - %s", id, (xmode) ? "Biphase a - AKA Conditional Dephase Encoding(CDP)" : _YELLOW_("Reserved"));
break;
case 17:
snprintf(retStr, sizeof(buf), "%u - Reserved", id);
break; break;
default: default:
snprintf(retStr, sizeof(buf), "0x%02X (Unknown)", id); snprintf(retStr, sizeof(buf), "0x%02X " _RED_("(Unknown)"), id);
break;
}
return buf;
}
char *GetQ5ModulationStr(uint32_t id) {
static char buf[60];
char *retStr = buf;
switch (id) {
case 0:
snprintf(retStr, sizeof(buf), "%u - Manchester", id);
break;
case 1:
snprintf(retStr, sizeof(buf), "%u - PSK 1 phase change when input changes", id);
break;
case 2:
snprintf(retStr, sizeof(buf), "%u - PSK 2 phase change on bitclk if input high", id);
break;
case 3:
snprintf(retStr, sizeof(buf), "%u - PSK 3 phase change on rising edge of input", id);
break;
case 4:
snprintf(retStr, sizeof(buf), "%u - FSK 1a RF/5 RF/8", id);
break;
case 5:
snprintf(retStr, sizeof(buf), "%u - FSK 2a RF/10 RF/8", id);
break;
case 6:
snprintf(retStr, sizeof(buf), "%u - Biphase", id);
break;
case 7:
snprintf(retStr, sizeof(buf), "%u - NRZ / Direct", id);
break; break;
} }
return buf; return buf;
@ -1539,7 +1732,7 @@ char *GetSelectedModulationStr(uint8_t id) {
snprintf(retStr, sizeof(buf), "BIPHASEa - (CDP)"); snprintf(retStr, sizeof(buf), "BIPHASEa - (CDP)");
break; break;
default: default:
snprintf(retStr, sizeof(buf), "(Unknown)"); snprintf(retStr, sizeof(buf), _RED_("(Unknown)"));
break; break;
} }
return buf; return buf;
@ -1697,13 +1890,13 @@ int CmdT55xxChkPwds(const char *Cmd) {
size_t datalen = 0; size_t datalen = 0;
// TODO, a way of reallocating memory if file was larger // TODO, a way of reallocating memory if file was larger
keyBlock = calloc(4*200, sizeof(uint8_t)); keyBlock = calloc(4 * 200, sizeof(uint8_t));
if ( keyBlock == NULL ) { if (keyBlock == NULL) {
PrintAndLogDevice(WARNING, "error, cannot allocate memory "); PrintAndLogDevice(WARNING, "error, cannot allocate memory ");
return 1; return 1;
} }
int res = loadFileDICTIONARY(filename, "dic", keyBlock, &datalen, 4, &keycount ); int res = loadFileDICTIONARY(filename, "dic", keyBlock, &datalen, 4, &keycount);
if (res || keycount == 0) { if (res || keycount == 0) {
PrintAndLogEx(WARNING, "No keys found in file"); PrintAndLogEx(WARNING, "No keys found in file");
free(keyBlock); free(keyBlock);
@ -1834,7 +2027,7 @@ int CmdT55xxRecoverPW(const char *Cmd) {
while (bit < 32) { while (bit < 32) {
curr_password = orig_password ^ (1u << bit); curr_password = orig_password ^ (1u << bit);
found = tryOnePassword(curr_password); found = tryOnePassword(curr_password);
if ( found == 1) if (found == 1)
goto out; goto out;
bit++; bit++;
@ -1859,7 +2052,7 @@ int CmdT55xxRecoverPW(const char *Cmd) {
} }
found = tryOnePassword(curr_password); found = tryOnePassword(curr_password);
if ( found == 1 ) if (found == 1)
goto out; goto out;
bit++; bit++;
@ -1881,7 +2074,7 @@ int CmdT55xxRecoverPW(const char *Cmd) {
continue; continue;
} }
found = tryOnePassword(curr_password); found = tryOnePassword(curr_password);
if ( found == 1 ) if (found == 1)
goto out; goto out;
bit++; bit++;
@ -1914,7 +2107,7 @@ bool tryDetectP1(bool getData) {
bool st = true; bool st = true;
if (getData) { if (getData) {
if (!AquireData(T55x7_PAGE1, 1, false, 0)) if (!AquireData(T55x7_PAGE1, T55x7_TRACE_BLOCK1, false, 0))
return false; return false;
} }
@ -2043,7 +2236,7 @@ int CmdT55xxDetectPage1(const char *Cmd) {
if (errors) return usage_t55xx_detectP1(); if (errors) return usage_t55xx_detectP1();
if (!useGB) { if (!useGB) {
if (!AquireData(T55x7_PAGE1, 1, usepwd, password)) if (!AquireData(T55x7_PAGE1, T55x7_TRACE_BLOCK1, usepwd, password))
return false; return false;
} }
bool success = tryDetectP1(false); bool success = tryDetectP1(false);

View file

@ -29,6 +29,8 @@
#define T55x7_CONFIGURATION_BLOCK 0x00 #define T55x7_CONFIGURATION_BLOCK 0x00
#define T55x7_TRACE_BLOCK1 0x01
#define T55x7_TRACE_BLOCK2 0x02
#define T55x7_PAGE0 0x00 #define T55x7_PAGE0 0x00
#define T55x7_PAGE1 0x01 #define T55x7_PAGE1 0x01
#define T55x7_PWD 0x00000010 #define T55x7_PWD 0x00000010
@ -147,9 +149,11 @@ extern int CmdT55xxDetect(const char *Cmd);
extern int CmdResetRead(const char *Cmd); extern int CmdResetRead(const char *Cmd);
extern int CmdT55xxWipe(const char *Cmd); extern int CmdT55xxWipe(const char *Cmd);
char *GetPskCfStr(uint32_t id, bool q5);
char *GetBitRateStr(uint32_t id, bool xmode); char *GetBitRateStr(uint32_t id, bool xmode);
char *GetSaferStr(uint32_t id); char *GetSaferStr(uint32_t id);
char *GetModulationStr(uint32_t id); char *GetQ5ModulationStr(uint32_t id);
char *GetModulationStr(uint32_t id, bool xmode);
char *GetModelStrFromCID(uint32_t cid); char *GetModelStrFromCID(uint32_t cid);
char *GetSelectedModulationStr(uint8_t id); char *GetSelectedModulationStr(uint8_t id);
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bitstream); uint32_t PackBits(uint8_t start, uint8_t len, uint8_t *bitstream);

View file

@ -194,7 +194,7 @@ static void UsbCommandReceived(UsbCommand *c) {
/* /*
bool hookUpPM3() { bool hookUpPM3() {
bool ret = false; bool ret = false;
sp = uart_open( comport ); sp = uart_open( comport, speed );
if (sp == INVALID_SERIAL_PORT) { if (sp == INVALID_SERIAL_PORT) {
PrintAndLogEx(WARNING, "Reconnect failed, retrying... (reason: invalid serial port)\n"); PrintAndLogEx(WARNING, "Reconnect failed, retrying... (reason: invalid serial port)\n");
@ -298,17 +298,17 @@ __attribute__((force_align_arg_pointer))
return NULL; return NULL;
} }
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode) { bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed) {
char *portname = (char *)port; char *portname = (char *)port;
if (!wait_for_port) { if (!wait_for_port) {
sp = uart_open(portname); sp = uart_open(portname, speed);
} else { } else {
PrintAndLogEx(SUCCESS, "Waiting for Proxmark to appear on " _YELLOW_("%s"), portname); PrintAndLogEx(SUCCESS, "Waiting for Proxmark to appear on " _YELLOW_("%s"), portname);
fflush(stdout); fflush(stdout);
int openCount = 0; int openCount = 0;
do { do {
sp = uart_open(portname); sp = uart_open(portname, speed);
msleep(500); msleep(500);
printf("."); printf(".");
fflush(stdout); fflush(stdout);

View file

@ -54,7 +54,8 @@ void *uart_receiver(void *targ);
void SendCommand(UsbCommand *c); void SendCommand(UsbCommand *c);
void clearCommandBuffer(); void clearCommandBuffer();
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode); #define FLASHMODE_SPEED 460800
bool OpenProxmark(void *port, bool wait_for_port, int timeout, bool flash_mode, uint32_t speed);
void CloseProxmark(void); void CloseProxmark(void);
bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand *response, size_t ms_timeout, bool show_warning); bool WaitForResponseTimeoutW(uint32_t cmd, UsbCommand *response, size_t ms_timeout, bool show_warning);

View file

@ -318,8 +318,10 @@ static int enter_bootloader(char *serial_port_name) {
} }
msleep(100); msleep(100);
CloseProxmark(); CloseProxmark();
// Let time to OS to make the port disappear
msleep(1000);
bool opened = OpenProxmark(serial_port_name, true, 60, true); bool opened = OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED);
if (opened) { if (opened) {
fprintf(stdout, " " _GREEN_("Found") "\n"); fprintf(stdout, " " _GREEN_("Found") "\n");
return 0; return 0;

View file

@ -81,7 +81,7 @@ int main(int argc, char **argv) {
char *serial_port_name = argv[1]; char *serial_port_name = argv[1];
if (!OpenProxmark(serial_port_name, true, 60, true)) { if (!OpenProxmark(serial_port_name, true, 60, true, FLASHMODE_SPEED)) {
fprintf(stderr, "Could not find Proxmark on " _RED_("%s") ".\n\n", serial_port_name); fprintf(stderr, "Could not find Proxmark on " _RED_("%s") ".\n\n", serial_port_name);
return -1; return -1;
} else { } else {

View file

@ -259,6 +259,9 @@ int main(int argc, char *argv[]) {
bool addLuaExec = false; bool addLuaExec = false;
char *script_cmds_file = NULL; char *script_cmds_file = NULL;
char *script_cmd = NULL; char *script_cmd = NULL;
char *lastarg = NULL;
char *port = NULL;
uint32_t speed = 0;
/* initialize history */ /* initialize history */
using_history(); using_history();
@ -272,7 +275,9 @@ int main(int argc, char *argv[]) {
return 1; return 1;
} }
for (int i = 1; i < argc; i++) { uint32_t i = 1;
port = argv[i++];
for (; i < argc; i++) {
// helptext // helptext
if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) { if (strcmp(argv[i], "-h") == 0 || strcmp(argv[i], "-help") == 0) {
@ -291,29 +296,58 @@ int main(int argc, char *argv[]) {
if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-flush") == 0) { if (strcmp(argv[i], "-f") == 0 || strcmp(argv[i], "-flush") == 0) {
SetFlushAfterWrite(true); SetFlushAfterWrite(true);
PrintAndLogEx(INFO, "Output will be flushed after every print.\n"); PrintAndLogEx(INFO, "Output will be flushed after every print.\n");
continue;
}
// set baudrate
if (strcmp(argv[i], "-b") == 0 || strcmp(argv[i], "-baud") == 0) {
uint32_t tmpspeed = strtoul(argv[i + 1], NULL, 10);
if ((tmpspeed == ULONG_MAX) || (tmpspeed == 0)) {
PrintAndLogEx(WARNING, "ERROR: invalid baudrate: %s %s\n", argv[i], argv[i + 1]);
return 1;
}
speed = tmpspeed;
i++;
continue;
} }
// wait for comport // wait for comport
if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "-wait") == 0) { if (strcmp(argv[i], "-w") == 0 || strcmp(argv[i], "-wait") == 0) {
waitCOMPort = true; waitCOMPort = true;
continue;
} }
// execute pm3 command // execute pm3 command
if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "-command") == 0) { if (strcmp(argv[i], "-c") == 0 || strcmp(argv[i], "-command") == 0) {
executeCommand = true; executeCommand = true;
continue;
} }
// execute lua script // execute lua script
if (strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "-lua") == 0) { if (strcmp(argv[i], "-l") == 0 || strcmp(argv[i], "-lua") == 0) {
executeCommand = true; executeCommand = true;
addLuaExec = true; addLuaExec = true;
continue;
}
if (i < argc - 1) {
// We got an unknown parameter
PrintAndLogEx(WARNING, "WARNING: ignoring invalid parameter: %s\n", argv[i]);
}
if (i == argc - 1) {
// We got presumably a command or a filename
lastarg = argv[argc - 1];
} }
} }
if (speed == 0)
speed = 460800;
// If the user passed the filename of the 'script' to execute, get it from last parameter // If the user passed the filename of the 'script' to execute, get it from last parameter
if (argc > 2 && argv[argc - 1] && argv[argc - 1][0] != '-') { if (lastarg) {
if (executeCommand) { if (executeCommand) {
script_cmd = argv[argc - 1]; script_cmd = lastarg;
while (script_cmd[strlen(script_cmd) - 1] == ' ') while (script_cmd[strlen(script_cmd) - 1] == ' ')
script_cmd[strlen(script_cmd) - 1] = 0x00; script_cmd[strlen(script_cmd) - 1] = 0x00;
@ -336,7 +370,7 @@ int main(int argc, char *argv[]) {
PrintAndLogEx(SUCCESS, "execute command from commandline: %s\n", script_cmd); PrintAndLogEx(SUCCESS, "execute command from commandline: %s\n", script_cmd);
} }
} else { } else {
script_cmds_file = argv[argc - 1]; script_cmds_file = lastarg;
} }
} }
@ -358,7 +392,7 @@ int main(int argc, char *argv[]) {
set_my_executable_path(); set_my_executable_path();
// try to open USB connection to Proxmark // try to open USB connection to Proxmark
usb_present = OpenProxmark(argv[1], waitCOMPort, 20, false); usb_present = OpenProxmark(port, waitCOMPort, 20, false, speed);
#ifdef HAVE_GUI #ifdef HAVE_GUI

View file

@ -630,7 +630,7 @@ usage(void) {
"\t preset values\n" "\t preset values\n"
"\n" "\n"
"Copyright (C)\n" "Copyright (C)\n"
"2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Gregory Cook\n" "2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Gregory Cook\n"
"This is free software; see the source for copying conditions. There is NO\n" "This is free software; see the source for copying conditions. There is NO\n"
"warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n" "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n"
"Version " "Version "

View file

@ -989,7 +989,7 @@ pcrc(const poly_t message, const poly_t divisor, const poly_t init, const poly_t
pshift(&result, result, 0UL, ofs, (init.length > max + divisor.length ? init.length - max - divisor.length : 0UL) + divisor.length + ofs, 0UL); pshift(&result, result, 0UL, ofs, (init.length > max + divisor.length ? init.length - max - divisor.length : 0UL) + divisor.length + ofs, 0UL);
} }
if ( result.bitmap != NULL ) if (result.bitmap != NULL)
psum(&result, xorout, 0UL); psum(&result, xorout, 0UL);
return (result); return (result);

View file

@ -379,98 +379,98 @@ static const bmp_t b32[] = {
BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */ BMP_C(0x94000000) << (BMP_BIT - 32), /* 115 -- 8, 94 */
BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */ BMP_C(0x97000000) << (BMP_BIT - 32), /* 116 -- 8, 97 */
BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */ BMP_C(0x98000000) << (BMP_BIT - 32), /* 117 -- 6, 26 */
BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */ BMP_C(0x99000000) << (BMP_BIT - 32), /* 118 -- 8, 99 */
BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */ BMP_C(0x9b000000) << (BMP_BIT - 32), /* 119 -- 8, 9b */
BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */ BMP_C(0x9c000000) << (BMP_BIT - 32), /* 120 -- 6, 27 */
BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */ BMP_C(0x9d5e4de2) << (BMP_BIT - 32), /* 121 -- 31,4eaf26f1 */
BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */ BMP_C(0x9e000000) << (BMP_BIT - 32), /* 122 -- 7, 4f */
BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */ BMP_C(0x9ecf0000) << (BMP_BIT - 32), /* 123 -- 16, 9ecf */
BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */ BMP_C(0xa0660000) << (BMP_BIT - 32), /* 124 -- 16, a066 */
BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */ BMP_C(0xa0970000) << (BMP_BIT - 32), /* 125 -- 16, a097 */
BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */ BMP_C(0xa1000000) << (BMP_BIT - 32), /* 126 -- 8, a1 */
BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */ BMP_C(0xa3660000) << (BMP_BIT - 32), /* 127 -- 16, a366 */
BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */ BMP_C(0xa6000000) << (BMP_BIT - 32), /* 128 -- 7, 53 */
BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */ BMP_C(0xa7000000) << (BMP_BIT - 32), /* 129 -- 8, a7 */
BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */ BMP_C(0xa8000000) << (BMP_BIT - 32), /* 130 -- 5, 15 */
BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */ BMP_C(0xa8190000) << (BMP_BIT - 32), /* 131 -- 16, a819 */
BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */ BMP_C(0xa833982b) << (BMP_BIT - 32), /* 132 -- 32,a833982b */
BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */ BMP_C(0xabcdef00) << (BMP_BIT - 32), /* 133 -- 24, abcdef */
BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */ BMP_C(0xac000000) << (BMP_BIT - 32), /* 134 -- 8, ac */
BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */ BMP_C(0xaee70000) << (BMP_BIT - 32), /* 135 -- 16, aee7 */
BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */ BMP_C(0xb0000000) << (BMP_BIT - 32), /* 136 -- 4, b */
BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */ BMP_C(0xb0010000) << (BMP_BIT - 32), /* 137 -- 16, b001 */
BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */ BMP_C(0xb2aa0000) << (BMP_BIT - 32), /* 138 -- 16, b2aa */
BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */ BMP_C(0xb3400000) << (BMP_BIT - 32), /* 139 -- 12, b34 */
BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */ BMP_C(0xb42d8000) << (BMP_BIT - 32), /* 140 -- 17, 1685b */
BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */ BMP_C(0xb4600000) << (BMP_BIT - 32), /* 141 -- 11, 5a3 */
BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */ BMP_C(0xb4c80000) << (BMP_BIT - 32), /* 142 -- 16, b4c8 */
BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */ BMP_C(0xb4f3e600) << (BMP_BIT - 32), /* 143 -- 24, b4f3e6 */
BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */ BMP_C(0xb704ce00) << (BMP_BIT - 32), /* 144 -- 24, b704ce */
BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */ BMP_C(0xb798b438) << (BMP_BIT - 32), /* 145 -- 32,b798b438 */
BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */ BMP_C(0xbb3d0000) << (BMP_BIT - 32), /* 146 -- 16, bb3d */
BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */ BMP_C(0xbc000000) << (BMP_BIT - 32), /* 147 -- 6,2f/ 8,bc */
BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */ BMP_C(0xbd0be338) << (BMP_BIT - 32), /* 148 -- 32,bd0be338 */
BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */ BMP_C(0xbdf40000) << (BMP_BIT - 32), /* 149 -- 16, bdf4 */
BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */ BMP_C(0xbf050000) << (BMP_BIT - 32), /* 150 -- 16, bf05 */
BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */ BMP_C(0xc0000000) << (BMP_BIT - 32), /* 151 -- 3, 6 */
BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */ BMP_C(0xc2000000) << (BMP_BIT - 32), /* 152 -- 7, 61 */
BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */ BMP_C(0xc25a5600) << (BMP_BIT - 32), /* 153 -- 24, c25a56 */
BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */ BMP_C(0xc2b70000) << (BMP_BIT - 32), /* 154 -- 16, c2b7 */
BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */ BMP_C(0xc2b80000) << (BMP_BIT - 32), /* 155 -- 14, 30ae */
BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */ BMP_C(0xc4000000) << (BMP_BIT - 32), /* 156 -- 8, c4 */
BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */ BMP_C(0xc6c60000) << (BMP_BIT - 32), /* 157 -- 16, c6c6 */
BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */ BMP_C(0xc7000000) << (BMP_BIT - 32), /* 158 -- 8, c7 */
BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */ BMP_C(0xc704dd7b) << (BMP_BIT - 32), /* 159 -- 32,c704dd7b */
BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */ BMP_C(0xc8000000) << (BMP_BIT - 32), /* 160 -- 5, 19 */
BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */ BMP_C(0xc8670000) << (BMP_BIT - 32), /* 161 -- 16, c867 */
BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */ BMP_C(0xcbf43926) << (BMP_BIT - 32), /* 162 -- 32,cbf43926 */
BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */ BMP_C(0xcde70300) << (BMP_BIT - 32), /* 163 -- 24, cde703 */
BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */ BMP_C(0xce3c0000) << (BMP_BIT - 32), /* 164 -- 16, ce3c */
BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */ BMP_C(0xd0000000) << (BMP_BIT - 32), /* 165 -- 8, d0 */
BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */ BMP_C(0xd02a0000) << (BMP_BIT - 32), /* 166 -- 15, 6815 */
BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */ BMP_C(0xd0db0000) << (BMP_BIT - 32), /* 167 -- 16, d0db */
BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */ BMP_C(0xd3100000) << (BMP_BIT - 32), /* 168 -- 12, d31 */
BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */ BMP_C(0xd3be9568) << (BMP_BIT - 32), /* 169 -- 30,34efa55a */
BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */ BMP_C(0xd4d00000) << (BMP_BIT - 32), /* 170 -- 12, d4d */
BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */ BMP_C(0xd5000000) << (BMP_BIT - 32), /* 171 -- 8, d5 */
BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */ BMP_C(0xd64e0000) << (BMP_BIT - 32), /* 172 -- 16, d64e */
BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */ BMP_C(0xda000000) << (BMP_BIT - 32), /* 173 -- 8, da */
BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */ BMP_C(0xdaf00000) << (BMP_BIT - 32), /* 174 -- 12, daf */
BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */ BMP_C(0xdebb20e3) << (BMP_BIT - 32), /* 175 -- 32,debb20e3 */
BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */ BMP_C(0xdf000000) << (BMP_BIT - 32), /* 176 -- 8, df */
BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */ BMP_C(0xe0000000) << (BMP_BIT - 32), /* 177 -- 3, 7 */
BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */ BMP_C(0xe3069283) << (BMP_BIT - 32), /* 178 -- 32,e3069283 */
BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */ BMP_C(0xe3940000) << (BMP_BIT - 32), /* 179 -- 16, e394 */
BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */ BMP_C(0xe5cc0000) << (BMP_BIT - 32), /* 180 -- 16, e5cc */
BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */ BMP_C(0xe7a80000) << (BMP_BIT - 32), /* 181 -- 13, 1cf5 */
BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */ BMP_C(0xe8000000) << (BMP_BIT - 32), /* 182 -- 6, 3a */
BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */ BMP_C(0xea000000) << (BMP_BIT - 32), /* 183 -- 7, 75 */
BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */ BMP_C(0xea820000) << (BMP_BIT - 32), /* 184 -- 16, ea82 */
BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */ BMP_C(0xec000000) << (BMP_BIT - 32), /* 185 -- 6, 3b */
BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */ BMP_C(0xf0000000) << (BMP_BIT - 32), /* 186 -- 4, f */
BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */ BMP_C(0xf0b80000) << (BMP_BIT - 32), /* 187 -- 16, f0b8 */
BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */ BMP_C(0xf1300000) << (BMP_BIT - 32), /* 188 -- 12, f13 */
BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */ BMP_C(0xf4000000) << (BMP_BIT - 32), /* 189 -- 8, f4 */
BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */ BMP_C(0xf4acfb13) << (BMP_BIT - 32), /* 190 -- 32,f4acfb13 */
BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */ BMP_C(0xf5b00000) << (BMP_BIT - 32), /* 191 -- 12, f5b */
BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */ BMP_C(0xf6400000) << (BMP_BIT - 32), /* 192 -- 10, 3d9 */
BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */ BMP_C(0xf7000000) << (BMP_BIT - 32), /* 193 -- 8, f7 */
BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */ BMP_C(0xf8000000) << (BMP_BIT - 32), /* 194 -- 5, 1f */
BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */ BMP_C(0xfc000000) << (BMP_BIT - 32), /* 195 -- 6, 3f */
BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */ BMP_C(0xfc891918) << (BMP_BIT - 32), /* 196 -- 32,fc891918 */
BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */ BMP_C(0xfd000000) << (BMP_BIT - 32), /* 197 -- 8, fd */
BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */ BMP_C(0xfe000000) << (BMP_BIT - 32), /* 198 -- 7, 7f */
BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */ BMP_C(0xfedcba00) << (BMP_BIT - 32), /* 199 -- 24, fedcba */
BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */ BMP_C(0xfee80000) << (BMP_BIT - 32), /* 200 -- 16, fee8 */
BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */ BMP_C(0xff000000) << (BMP_BIT - 32), /* 201 -- 8, ff */
BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */ BMP_C(0xffc00000) << (BMP_BIT - 32), /* 202 -- 10, 3ff */
BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */ BMP_C(0xfff00000) << (BMP_BIT - 32), /* 203 -- 12, fff */
BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */ BMP_C(0xfffc0000) << (BMP_BIT - 32), /* 204 -- 14, 3fff */
BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */ BMP_C(0xffff0000) << (BMP_BIT - 32), /* 205 -- 16, ffff */
BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */ BMP_C(0xffffff00) << (BMP_BIT - 32), /* 206 -- 24, ffffff */
BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */ BMP_C(0xfffffffc) << (BMP_BIT - 32), /* 207 -- 30,3fffffff */
BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */ BMP_C(0xfffffffe) << (BMP_BIT - 32), /* 208 -- 31,7fffffff */
BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */ BMP_C(0xffffffff) << (BMP_BIT - 32), /* 209 -- 32,ffffffff */
}; };
static const struct malias aliases[]; static const struct malias aliases[];
@ -479,297 +479,297 @@ static const struct malias aliases[];
* Sorted by left-justified polynomial for bsearch(). * Sorted by left-justified polynomial for bsearch().
*/ */
static const struct mpreset models[] = { static const struct mpreset models[] = {
{64UL, b64, b64a, P_LE | P_CONFIR, b64a, b64b, b64c, aliases + 130}, /* 0 */ {64UL, b64, b64a, P_LE | P_CONFIR, b64a, b64b, b64c, aliases + 130}, /* 0 */
{32UL, b32+ 0, 0, P_BE | P_CONFIR, 0, b32+148, 0, aliases+107}, /* 1 */ {32UL, b32 + 0, 0, P_BE | P_CONFIR, 0, b32 + 148, 0, aliases + 107}, /* 1 */
{40UL, b40, 0, P_BE | P_ACADEM, b40a, b40b, b40c, aliases + 115}, /* 2 */ {40UL, b40, 0, P_BE | P_ACADEM, b40a, b40b, b40c, aliases + 115}, /* 2 */
{24UL, b32+ 3, b32+ 76, P_LE | P_ATTEST, 0, b32+153, 0, aliases+ 77}, /* 3 */ {24UL, b32 + 3, b32 + 76, P_LE | P_ATTEST, 0, b32 + 153, 0, aliases + 77}, /* 3 */
{32UL, b32+ 8, 0, P_BE | P_ATTEST, b32+209, b32+ 92, b32+159, aliases+ 98}, /* 4 */ {32UL, b32 + 8, 0, P_BE | P_ATTEST, b32 + 209, b32 + 92, b32 + 159, aliases + 98}, /* 4 */
{32UL, b32+ 8, b32+209, P_BE | P_ATTEST, 0, b32+ 7, 0, aliases+104}, /* 5 */ {32UL, b32 + 8, b32 + 209, P_BE | P_ATTEST, 0, b32 + 7, 0, aliases + 104}, /* 5 */
{32UL, b32+ 8, b32+209, P_BE | P_ATTEST, b32+209, b32+196, b32+159, aliases+ 96}, /* 6 */ {32UL, b32 + 8, b32 + 209, P_BE | P_ATTEST, b32 + 209, b32 + 196, b32 + 159, aliases + 96}, /* 6 */
{32UL, b32+ 8, b32+209, P_LE | P_CONFIR, 0, b32+ 56, 0, aliases+103}, /* 7 */ {32UL, b32 + 8, b32 + 209, P_LE | P_CONFIR, 0, b32 + 56, 0, aliases + 103}, /* 7 */
{32UL, b32+ 8, b32+209, P_LE | P_ATTEST, b32+209, b32+162, b32+175, aliases+102}, /* 8 */ {32UL, b32 + 8, b32 + 209, P_LE | P_ATTEST, b32 + 209, b32 + 162, b32 + 175, aliases + 102}, /* 8 */
{16UL, b32 + 9, 0, P_BE | P_ATTEST, 0, b32 + 5, 0, aliases + 36}, /* 9 */ {16UL, b32 + 9, 0, P_BE | P_ATTEST, 0, b32 + 5, 0, aliases + 36}, /* 9 */
{16UL, b32 + 9, 0, P_BE | P_ATTEST, b32 + 1, b32 + 4, b32 + 9, aliases + 35}, /* 10 */ {16UL, b32 + 9, 0, P_BE | P_ATTEST, b32 + 1, b32 + 4, b32 + 9, aliases + 35}, /* 10 */
{ 8UL, b32+ 10, 0, P_BE | P_ATTEST, 0, b32+189, 0, aliases+158}, /* 11 */ { 8UL, b32 + 10, 0, P_BE | P_ATTEST, 0, b32 + 189, 0, aliases + 158}, /* 11 */
{ 8UL, b32+ 10, 0, P_BE | P_ACADEM, b32+ 75, b32+126, b32+134, aliases+147}, /* 12 */ { 8UL, b32 + 10, 0, P_BE | P_ACADEM, b32 + 75, b32 + 126, b32 + 134, aliases + 147}, /* 12 */
{ 8UL, b32+ 10, b32+201, P_LE | P_ACADEM, 0, b32+165, 0, aliases+156}, /* 13 */ { 8UL, b32 + 10, b32 + 201, P_LE | P_ACADEM, 0, b32 + 165, 0, aliases + 156}, /* 13 */
{16UL, b32+ 11, b32+205, P_LE | P_ATTEST, 0, b32+124, 0, aliases+ 58}, /* 14 */ {16UL, b32 + 11, b32 + 205, P_LE | P_ATTEST, 0, b32 + 124, 0, aliases + 58}, /* 14 */
{31UL, b32+ 12, b32+208, P_BE | P_CONFIR, b32+208, b32+ 26, b32+121, aliases+ 88}, /* 15 */ {31UL, b32 + 12, b32 + 208, P_BE | P_CONFIR, b32 + 208, b32 + 26, b32 + 121, aliases + 88}, /* 15 */
{ 6UL, b32 + 14, 0, P_LE | P_ACADEM, 0, b32 + 25, 0, aliases + 124}, /* 16 */ { 6UL, b32 + 14, 0, P_LE | P_ACADEM, 0, b32 + 25, 0, aliases + 124}, /* 16 */
{82UL, b82, 0, P_LE | P_ATTEST, 0, b82a, 0, aliases+161}, /* 17 */ {82UL, b82, 0, P_LE | P_ATTEST, 0, b82a, 0, aliases + 161}, /* 17 */
{16UL, b32 + 18, 0, P_BE | P_ATTEST, 0, b32 + 53, 0, aliases + 73}, /* 18 */ {16UL, b32 + 18, 0, P_BE | P_ATTEST, 0, b32 + 53, 0, aliases + 73}, /* 18 */
{16UL, b32+ 18, 0, P_BE | P_ACADEM, b32+205, b32+164, b32+ 29, aliases+ 42}, /* 19 */ {16UL, b32 + 18, 0, P_BE | P_ACADEM, b32 + 205, b32 + 164, b32 + 29, aliases + 42}, /* 19 */
{16UL, b32 + 18, 0, P_LE | P_ATTEST, 0, b32 + 38, 0, aliases + 50}, /* 20 */ {16UL, b32 + 18, 0, P_LE | P_ATTEST, 0, b32 + 38, 0, aliases + 50}, /* 20 */
{16UL, b32+ 18, b32+ 29, P_BE | P_ATTEST, 0, b32+180, 0, aliases+ 63}, /* 21 */ {16UL, b32 + 18, b32 + 29, P_BE | P_ATTEST, 0, b32 + 180, 0, aliases + 63}, /* 21 */
{16UL, b32 + 18, b32 + 108, P_LE | P_ATTEST, 0, b32 + 43, 0, aliases + 66}, /* 22 */ {16UL, b32 + 18, b32 + 108, P_LE | P_ATTEST, 0, b32 + 43, 0, aliases + 66}, /* 22 */
{16UL, b32+ 18, b32+138, P_LE | P_THIRDP, 0, b32+ 83, 0, aliases+ 62}, /* 23 */ {16UL, b32 + 18, b32 + 138, P_LE | P_THIRDP, 0, b32 + 83, 0, aliases + 62}, /* 23 */
{16UL, b32+ 18, b32+157, P_LE | P_ATTEST, 0, b32+150, 0, aliases+ 48}, /* 24 */ {16UL, b32 + 18, b32 + 157, P_LE | P_ATTEST, 0, b32 + 150, 0, aliases + 48}, /* 24 */
{16UL, b32+ 18, b32+205, P_BE | P_ATTEST, 0, b32+ 47, 0, aliases+ 44}, /* 25 */ {16UL, b32 + 18, b32 + 205, P_BE | P_ATTEST, 0, b32 + 47, 0, aliases + 44}, /* 25 */
{16UL, b32+ 18, b32+205, P_BE | P_ATTEST, b32+205, b32+172, b32+ 29, aliases+ 41}, /* 26 */ {16UL, b32 + 18, b32 + 205, P_BE | P_ATTEST, b32 + 205, b32 + 172, b32 + 29, aliases + 41}, /* 26 */
{16UL, b32+ 18, b32+205, P_LE | P_ATTEST, 0, b32+ 88, 0, aliases+ 56}, /* 27 */ {16UL, b32 + 18, b32 + 205, P_LE | P_ATTEST, 0, b32 + 88, 0, aliases + 56}, /* 27 */
{16UL, b32+ 18, b32+205, P_LE | P_ATTEST, b32+205, b32+114, b32+187, aliases+ 45}, /* 28 */ {16UL, b32 + 18, b32 + 205, P_LE | P_ATTEST, b32 + 205, b32 + 114, b32 + 187, aliases + 45}, /* 28 */
{ 7UL, b32+ 19, 0, P_BE | P_ACADEM, 0, b32+183, 0, aliases+134}, /* 29 */ { 7UL, b32 + 19, 0, P_BE | P_ACADEM, 0, b32 + 183, 0, aliases + 134}, /* 29 */
{ 6UL, b32+ 27, b32+195, P_BE | P_ACADEM, 0, b32+185, 0, aliases+122}, /* 30 */ { 6UL, b32 + 27, b32 + 195, P_BE | P_ACADEM, 0, b32 + 185, 0, aliases + 122}, /* 30 */
{ 8UL, b32 + 28, 0, P_BE | P_ACADEM, 0, b32 + 57, 0, aliases + 145}, /* 31 */ { 8UL, b32 + 28, 0, P_BE | P_ACADEM, 0, b32 + 57, 0, aliases + 145}, /* 31 */
{ 8UL, b32+ 28, b32+158, P_BE | P_ATTEST, 0, b32+118, 0, aliases+153}, /* 32 */ { 8UL, b32 + 28, b32 + 158, P_BE | P_ATTEST, 0, b32 + 118, 0, aliases + 153}, /* 32 */
{ 8UL, b32+ 28, b32+197, P_BE | P_ATTEST, 0, b32+ 95, 0, aliases+148}, /* 33 */ { 8UL, b32 + 28, b32 + 197, P_BE | P_ATTEST, 0, b32 + 95, 0, aliases + 148}, /* 33 */
{ 8UL, b32+ 28, b32+201, P_BE | P_ATTEST, b32+201, b32+ 70, b32+156, aliases+157}, /* 34 */ { 8UL, b32 + 28, b32 + 201, P_BE | P_ATTEST, b32 + 201, b32 + 70, b32 + 156, aliases + 157}, /* 34 */
{ 8UL, b32+ 28, b32+201, P_LE | P_ATTEST, 0, b32+116, 0, aliases+159}, /* 35 */ { 8UL, b32 + 28, b32 + 201, P_LE | P_ATTEST, 0, b32 + 116, 0, aliases + 159}, /* 35 */
{16UL, b32+ 30, b32+205, P_BE | P_ATTEST, b32+205, b32+131, b32+179, aliases+ 61}, /* 36 */ {16UL, b32 + 30, b32 + 205, P_BE | P_ATTEST, b32 + 205, b32 + 131, b32 + 179, aliases + 61}, /* 36 */
{32UL, b32+ 31, b32+209, P_LE | P_ATTEST, b32+209, b32+178, b32+145, aliases+101}, /* 37 */ {32UL, b32 + 31, b32 + 209, P_LE | P_ATTEST, b32 + 209, b32 + 178, b32 + 145, aliases + 101}, /* 37 */
{14UL, b32+ 35, 0, P_LE | P_ATTEST, 0, b32+ 36, 0, aliases+ 17}, /* 38 */ {14UL, b32 + 35, 0, P_LE | P_ATTEST, 0, b32 + 36, 0, aliases + 17}, /* 38 */
{ 5UL, b32+ 46, b32+194, P_LE | P_THIRDP, b32+194, b32+160, b32+ 49, aliases+120}, /* 39 */ { 5UL, b32 + 46, b32 + 194, P_LE | P_THIRDP, b32 + 194, b32 + 160, b32 + 49, aliases + 120}, /* 39 */
{ 8UL, b32+ 48, 0, P_BE | P_ATTEST, 0, b32+ 61, 0, aliases+155}, /* 40 */ { 8UL, b32 + 48, 0, P_BE | P_ATTEST, 0, b32 + 61, 0, aliases + 155}, /* 40 */
{ 8UL, b32+ 48, b32+201, P_BE | P_ATTEST, b32+201, b32+176, b32+ 63, aliases+139}, /* 41 */ { 8UL, b32 + 48, b32 + 201, P_BE | P_ATTEST, b32 + 201, b32 + 176, b32 + 63, aliases + 139}, /* 41 */
{ 4UL, b32+ 49, 0, P_LE | P_ACADEM, 0, b32+ 89, 0, aliases+112}, /* 42 */ { 4UL, b32 + 49, 0, P_LE | P_ACADEM, 0, b32 + 89, 0, aliases + 112}, /* 42 */
{ 4UL, b32+ 49, b32+186, P_BE | P_ACADEM, b32+186, b32+136, b32+ 33, aliases+113}, /* 43 */ { 4UL, b32 + 49, b32 + 186, P_BE | P_ACADEM, b32 + 186, b32 + 136, b32 + 33, aliases + 113}, /* 43 */
{ 8UL, b32+ 51, 0, P_LE | P_ATTEST, 0, b32+126, 0, aliases+152}, /* 44 */ { 8UL, b32 + 51, 0, P_LE | P_ATTEST, 0, b32 + 126, 0, aliases + 152}, /* 44 */
{ 8UL, b32+ 51, b32+201, P_BE | P_ATTEST, 0, b32+193, 0, aliases+154}, /* 45 */ { 8UL, b32 + 51, b32 + 201, P_BE | P_ATTEST, 0, b32 + 193, 0, aliases + 154}, /* 45 */
{24UL, b32+ 54, b32+206, P_BE | P_ACADEM, b32+206, b32+143, b32+ 21, aliases+ 80}, /* 46 */ {24UL, b32 + 54, b32 + 206, P_BE | P_ACADEM, b32 + 206, b32 + 143, b32 + 21, aliases + 80}, /* 46 */
{ 8UL, b32+ 59, 0, P_LE | P_ATTEST, 0, b32+ 22, 0, aliases+142}, /* 47 */ { 8UL, b32 + 59, 0, P_LE | P_ATTEST, 0, b32 + 22, 0, aliases + 142}, /* 47 */
{16UL, b32+ 60, 0, P_BE | P_CONFIR, b32+205, b32+154, b32+127, aliases+ 38}, /* 48 */ {16UL, b32 + 60, 0, P_BE | P_CONFIR, b32 + 205, b32 + 154, b32 + 127, aliases + 38}, /* 48 */
{16UL, b32+ 60, 0, P_LE | P_CONFIR, b32+205, b32+184, b32+ 86, aliases+ 37}, /* 49 */ {16UL, b32 + 60, 0, P_LE | P_CONFIR, b32 + 205, b32 + 184, b32 + 86, aliases + 37}, /* 49 */
{64UL, b64d, 0, P_BE | P_ACADEM, 0, b64e, 0, aliases+128}, /* 50 */ {64UL, b64d, 0, P_BE | P_ACADEM, 0, b64e, 0, aliases + 128}, /* 50 */
{64UL, b64d, b64a, P_BE | P_CONFIR, b64a, b64f, b64g, aliases+131}, /* 51 */ {64UL, b64d, b64a, P_BE | P_CONFIR, b64a, b64f, b64g, aliases + 131}, /* 51 */
{64UL, b64d, b64a, P_LE | P_ATTEST, b64a, b64h, b64i, aliases+132}, /* 52 */ {64UL, b64d, b64a, P_LE | P_ATTEST, b64a, b64h, b64i, aliases + 132}, /* 52 */
{ 5UL, b32+ 66, b32+ 66, P_BE | P_ATTEST, 0, 0, 0, aliases+117}, /* 53 */ { 5UL, b32 + 66, b32 + 66, P_BE | P_ATTEST, 0, 0, 0, aliases + 117}, /* 53 */
{ 8UL, b32+ 67, 0, P_BE | P_ACADEM, b32+201, b32+115, b32+ 74, aliases+146}, /* 54 */ { 8UL, b32 + 67, 0, P_BE | P_ACADEM, b32 + 201, b32 + 115, b32 + 74, aliases + 146}, /* 54 */
{16UL, b32+ 77, 0, P_BE | P_ATTEST, 0, b32+ 78, 0, aliases+ 59}, /* 55 */ {16UL, b32 + 77, 0, P_BE | P_ATTEST, 0, b32 + 78, 0, aliases + 59}, /* 55 */
{10UL, b32+ 79, 0, P_BE | P_ACADEM, b32+202, b32+ 68, b32+ 52, aliases+ 6}, /* 56 */ {10UL, b32 + 79, 0, P_BE | P_ACADEM, b32 + 202, b32 + 68, b32 + 52, aliases + 6}, /* 56 */
{24UL, b32+ 80, b32+133, P_BE | P_ATTEST, 0, b32+ 32, 0, aliases+ 79}, /* 57 */ {24UL, b32 + 80, b32 + 133, P_BE | P_ATTEST, 0, b32 + 32, 0, aliases + 79}, /* 57 */
{24UL, b32+ 80, b32+199, P_BE | P_ATTEST, 0, b32+ 94, 0, aliases+ 78}, /* 58 */ {24UL, b32 + 80, b32 + 199, P_BE | P_ATTEST, 0, b32 + 94, 0, aliases + 78}, /* 58 */
{ 3UL, b32+ 81, 0, P_BE | P_ACADEM, b32+177, b32+ 96, b32+ 62, aliases+ 85}, /* 59 */ { 3UL, b32 + 81, 0, P_BE | P_ACADEM, b32 + 177, b32 + 96, b32 + 62, aliases + 85}, /* 59 */
{ 3UL, b32+ 81, b32+177, P_LE | P_ACADEM, 0, b32+151, 0, aliases+ 86}, /* 60 */ { 3UL, b32 + 81, b32 + 177, P_LE | P_ACADEM, 0, b32 + 151, 0, aliases + 86}, /* 60 */
{11UL, b32+ 82, 0, P_BE | P_ACADEM, 0, b32+ 15, 0, aliases+ 10}, /* 61 */ {11UL, b32 + 82, 0, P_BE | P_ACADEM, 0, b32 + 15, 0, aliases + 10}, /* 61 */
{ 6UL, b32+ 84, 0, P_LE | P_ATTEST, 0, b32+117, 0, aliases+123}, /* 62 */ { 6UL, b32 + 84, 0, P_LE | P_ATTEST, 0, b32 + 117, 0, aliases + 123}, /* 62 */
{16UL, b32+ 87, 0, P_BE | P_THIRDP, 0, b32+149, 0, aliases+ 52}, /* 63 */ {16UL, b32 + 87, 0, P_BE | P_THIRDP, 0, b32 + 149, 0, aliases + 52}, /* 63 */
{11UL, b32+ 90, b32+ 6, P_BE | P_ATTEST, 0, b32+141, 0, aliases+ 9}, /* 64 */ {11UL, b32 + 90, b32 + 6, P_BE | P_ATTEST, 0, b32 + 141, 0, aliases + 9}, /* 64 */
{16UL, b32+ 91, 0, P_BE | P_ATTEST, 0, b32+ 37, 0, aliases+ 60}, /* 65 */ {16UL, b32 + 91, 0, P_BE | P_ATTEST, 0, b32 + 37, 0, aliases + 60}, /* 65 */
{24UL, b32+ 97, 0, P_BE | P_ACADEM, 0, b32+ 40, 0, aliases+ 82}, /* 66 */ {24UL, b32 + 97, 0, P_BE | P_ACADEM, 0, b32 + 40, 0, aliases + 82}, /* 66 */
{24UL, b32+ 97, b32+206, P_BE | P_ATTEST, b32+206, b32+ 34, b32+100, aliases+ 84}, /* 67 */ {24UL, b32 + 97, b32 + 206, P_BE | P_ATTEST, b32 + 206, b32 + 34, b32 + 100, aliases + 84}, /* 67 */
{16UL, b32+ 98, 0, P_BE | P_ATTEST, 0, b32+200, 0, aliases+ 67}, /* 68 */ {16UL, b32 + 98, 0, P_BE | P_ATTEST, 0, b32 + 200, 0, aliases + 67}, /* 68 */
{16UL, b32+ 98, 0, P_LE | P_CONFIR, 0, b32+146, 0, aliases+ 24}, /* 69 */ {16UL, b32 + 98, 0, P_LE | P_CONFIR, 0, b32 + 146, 0, aliases + 24}, /* 69 */
{16UL, b32+ 98, 0, P_LE | P_ATTEST, b32+205, b32+ 64, b32+137, aliases+ 55}, /* 70 */ {16UL, b32 + 98, 0, P_LE | P_ATTEST, b32 + 205, b32 + 64, b32 + 137, aliases + 55}, /* 70 */
{16UL, b32+ 98, b32+ 99, P_BE | P_ATTEST, 0, b32+123, 0, aliases+ 34}, /* 71 */ {16UL, b32 + 98, b32 + 99, P_BE | P_ATTEST, 0, b32 + 123, 0, aliases + 34}, /* 71 */
{16UL, b32+ 98, b32+205, P_BE | P_THIRDP, 0, b32+135, 0, aliases+ 32}, /* 72 */ {16UL, b32 + 98, b32 + 205, P_BE | P_THIRDP, 0, b32 + 135, 0, aliases + 32}, /* 72 */
{16UL, b32+ 98, b32+205, P_LE | P_ATTEST, 0, b32+ 71, 0, aliases+ 57}, /* 73 */ {16UL, b32 + 98, b32 + 205, P_LE | P_ATTEST, 0, b32 + 71, 0, aliases + 57}, /* 73 */
{16UL, b32+ 98, b32+205, P_LE | P_THIRDP, b32+205, b32+142, b32+137, aliases+ 68}, /* 74 */ {16UL, b32 + 98, b32 + 205, P_LE | P_THIRDP, b32 + 205, b32 + 142, b32 + 137, aliases + 68}, /* 74 */
{14UL, b32+101, 0, P_BE | P_ACADEM, b32+204, b32+155, b32+ 16, aliases+ 18}, /* 75 */ {14UL, b32 + 101, 0, P_BE | P_ACADEM, b32 + 204, b32 + 155, b32 + 16, aliases + 18}, /* 75 */
{30UL, b32+102, b32+207, P_BE | P_ACADEM, b32+207, b32+ 20, b32+169, aliases+ 87}, /* 76 */ {30UL, b32 + 102, b32 + 207, P_BE | P_ACADEM, b32 + 207, b32 + 20, b32 + 169, aliases + 87}, /* 76 */
{12UL, b32+103, 0, P_BE | P_ACADEM, 0, b32+191, 0, aliases+ 13}, /* 77 */ {12UL, b32 + 103, 0, P_BE | P_ACADEM, 0, b32 + 191, 0, aliases + 13}, /* 77 */
{12UL, b32+103, 0, P_BELE | P_ACADEM, 0, b32+174, 0, aliases+ 15}, /* 78 */ {12UL, b32 + 103, 0, P_BELE | P_ACADEM, 0, b32 + 174, 0, aliases + 15}, /* 78 */
{32UL, b32+104, 0, P_BE | P_ATTEST, 0, b32+ 50, 0, aliases+ 92}, /* 79 */ {32UL, b32 + 104, 0, P_BE | P_ATTEST, 0, b32 + 50, 0, aliases + 92}, /* 79 */
{21UL, b32+105, 0, P_BE | P_ACADEM, 0, b32+ 93, 0, aliases+ 75}, /* 80 */ {21UL, b32 + 105, 0, P_BE | P_ACADEM, 0, b32 + 93, 0, aliases + 75}, /* 80 */
{24UL, b32+106, 0, P_BE | P_ACADEM, 0, b32+163, 0, aliases+ 81}, /* 81 */ {24UL, b32 + 106, 0, P_BE | P_ACADEM, 0, b32 + 163, 0, aliases + 81}, /* 81 */
{24UL, b32+106, b32+144, P_BE | P_ATTEST, 0, b32+ 39, 0, aliases+ 83}, /* 82 */ {24UL, b32 + 106, b32 + 144, P_BE | P_ATTEST, 0, b32 + 39, 0, aliases + 83}, /* 82 */
{ 7UL, b32+109, 0, P_BE | P_ACADEM, 0, b32+152, 0, aliases+136}, /* 83 */ { 7UL, b32 + 109, 0, P_BE | P_ACADEM, 0, b32 + 152, 0, aliases + 136}, /* 83 */
{15UL, b32+110, 0, P_BE | P_ACADEM, 0, b32+ 13, 0, aliases+ 20}, /* 84 */ {15UL, b32 + 110, 0, P_BE | P_ACADEM, 0, b32 + 13, 0, aliases + 20}, /* 84 */
{16UL, b32+111, 0, P_BE | P_ATTEST, 0, b32+167, 0, aliases+ 64}, /* 85 */ {16UL, b32 + 111, 0, P_BE | P_ATTEST, 0, b32 + 167, 0, aliases + 64}, /* 85 */
{10UL, b32+112, 0, P_BE | P_ATTEST, 0, b32+ 85, 0, aliases+ 4}, /* 86 */ {10UL, b32 + 112, 0, P_BE | P_ATTEST, 0, b32 + 85, 0, aliases + 4}, /* 86 */
{ 8UL, b32+119, 0, P_BE | P_ACADEM, 0, b32+183, 0, aliases+150}, /* 87 */ { 8UL, b32 + 119, 0, P_BE | P_ACADEM, 0, b32 + 183, 0, aliases + 150}, /* 87 */
{ 8UL, b32+119, 0, P_LE | P_THIRDP, 0, b32+ 41, 0, aliases+160}, /* 88 */ { 8UL, b32 + 119, 0, P_LE | P_THIRDP, 0, b32 + 41, 0, aliases + 160}, /* 88 */
{ 8UL, b32+119, b32+201, P_BE | P_ACADEM, 0, b32+173, 0, aliases+141}, /* 89 */ { 8UL, b32 + 119, b32 + 201, P_BE | P_ACADEM, 0, b32 + 173, 0, aliases + 141}, /* 89 */
{ 6UL, b32+120, b32+195, P_BE | P_ATTEST, 0, b32+ 55, 0, aliases+121}, /* 90 */ { 6UL, b32 + 120, b32 + 195, P_BE | P_ATTEST, 0, b32 + 55, 0, aliases + 121}, /* 90 */
{ 7UL, b32+122, b32+198, P_LE | P_ACADEM, 0, b32+128, 0, aliases+135}, /* 91 */ { 7UL, b32 + 122, b32 + 198, P_LE | P_ACADEM, 0, b32 + 128, 0, aliases + 135}, /* 91 */
{16UL, b32+125, 0, P_BE | P_CONFIR, 0, b32+ 17, 0, aliases+ 65}, /* 92 */ {16UL, b32 + 125, 0, P_BE | P_CONFIR, 0, b32 + 17, 0, aliases + 65}, /* 92 */
{ 8UL, b32+129, 0, P_LE | P_ATTEST, 0, b32+ 42, 0, aliases+140}, /* 93 */ { 8UL, b32 + 129, 0, P_LE | P_ATTEST, 0, b32 + 42, 0, aliases + 140}, /* 93 */
{ 5UL, b32+130, 0, P_LE | P_ACADEM, 0, b32+ 58, 0, aliases+118}, /* 94 */ { 5UL, b32 + 130, 0, P_LE | P_ACADEM, 0, b32 + 58, 0, aliases + 118}, /* 94 */
{32UL, b32+132, b32+209, P_LE | P_CONFIR, b32+209, b32+107, b32+ 65, aliases+ 95}, /* 95 */ {32UL, b32 + 132, b32 + 209, P_LE | P_CONFIR, b32 + 209, b32 + 107, b32 + 65, aliases + 95}, /* 95 */
{17UL, b32+140, 0, P_BE | P_ACADEM, 0, b32+ 44, 0, aliases+ 74}, /* 96 */ {17UL, b32 + 140, 0, P_BE | P_ACADEM, 0, b32 + 44, 0, aliases + 74}, /* 96 */
{ 6UL, b32+147, 0, P_BE | P_ACADEM, b32+195, b32+ 72, b32+182, aliases+125}, /* 97 */ { 6UL, b32 + 147, 0, P_BE | P_ACADEM, b32 + 195, b32 + 72, b32 + 182, aliases + 125}, /* 97 */
{16UL, b32+161, b32+205, P_BE | P_ACADEM, 0, b32+ 73, 0, aliases+ 31}, /* 98 */ {16UL, b32 + 161, b32 + 205, P_BE | P_ACADEM, 0, b32 + 73, 0, aliases + 31}, /* 98 */
{15UL, b32+166, 0, P_BE | P_ATTEST, b32+ 2, b32+ 69, b32+166, aliases+ 21}, /* 99 */ {15UL, b32 + 166, 0, P_BE | P_ATTEST, b32 + 2, b32 + 69, b32 + 166, aliases + 21}, /* 99 */
{12UL, b32+168, 0, P_BE | P_ACADEM, b32+203, b32+139, b32+ 24, aliases+ 14}, /* 100 */ {12UL, b32 + 168, 0, P_BE | P_ACADEM, b32 + 203, b32 + 139, b32 + 24, aliases + 14}, /* 100 */
{ 8UL, b32+171, 0, P_BE | P_ACADEM, 0, b32+147, 0, aliases+143}, /* 101 */ { 8UL, b32 + 171, 0, P_BE | P_ACADEM, 0, b32 + 147, 0, aliases + 143}, /* 101 */
{13UL, b32+181, 0, P_BE | P_ATTEST, 0, b32+ 45, 0, aliases+ 16}, /* 102 */ {13UL, b32 + 181, 0, P_BE | P_ATTEST, 0, b32 + 45, 0, aliases + 16}, /* 102 */
{12UL, b32+188, b32+203, P_BE | P_ACADEM, 0, b32+170, 0, aliases+ 12}, /* 103 */ {12UL, b32 + 188, b32 + 203, P_BE | P_ACADEM, 0, b32 + 170, 0, aliases + 12}, /* 103 */
{32UL, b32+190, b32+209, P_LE | P_ATTEST, b32+209, b32+ 23, b32+113, aliases+ 93}, /* 104 */ {32UL, b32 + 190, b32 + 209, P_LE | P_ATTEST, b32 + 209, b32 + 23, b32 + 113, aliases + 93}, /* 104 */
{10UL, b32+192, b32+202, P_BE | P_ACADEM, 0, b32+112, 0, aliases+ 5}, /* 105 */ {10UL, b32 + 192, b32 + 202, P_BE | P_ACADEM, 0, b32 + 112, 0, aliases + 5}, /* 105 */
{ 0UL, 0, 0, P_BE | P_UNDFCL, 0, 0, 0, NULL }, /* terminating entry */ { 0UL, 0, 0, P_BE | P_UNDFCL, 0, 0, 0, NULL }, /* terminating entry */
}; };
# define NPRESETS 106 # define NPRESETS 106
/* List of names with pointers to models, pre-sorted for use with bsearch() */ /* List of names with pointers to models, pre-sorted for use with bsearch() */
static const struct malias aliases[] = { static const struct malias aliases[] = {
{"ARC", models+ 69}, /* 0 */ {"ARC", models + 69}, /* 0 */
{"B-CRC-32", models + 6}, /* 1 */ {"B-CRC-32", models + 6}, /* 1 */
{"CKSUM", models + 4}, /* 2 */ {"CKSUM", models + 4}, /* 2 */
{"CRC-10", models+ 86}, /* 3 */ {"CRC-10", models + 86}, /* 3 */
{"CRC-10/ATM", models+ 86}, /* 4 */ {"CRC-10/ATM", models + 86}, /* 4 */
{"CRC-10/CDMA2000", models+105}, /* 5 */ {"CRC-10/CDMA2000", models + 105}, /* 5 */
{"CRC-10/GSM", models+ 56}, /* 6 */ {"CRC-10/GSM", models + 56}, /* 6 */
{"CRC-10/I-610", models+ 86}, /* 7 */ {"CRC-10/I-610", models + 86}, /* 7 */
{"CRC-11", models+ 64}, /* 8 */ {"CRC-11", models + 64}, /* 8 */
{"CRC-11/FLEXRAY", models+ 64}, /* 9 */ {"CRC-11/FLEXRAY", models + 64}, /* 9 */
{"CRC-11/UMTS", models+ 61}, /* 10 */ {"CRC-11/UMTS", models + 61}, /* 10 */
{"CRC-12/3GPP", models+ 78}, /* 11 */ {"CRC-12/3GPP", models + 78}, /* 11 */
{"CRC-12/CDMA2000", models+103}, /* 12 */ {"CRC-12/CDMA2000", models + 103}, /* 12 */
{"CRC-12/DECT", models+ 77}, /* 13 */ {"CRC-12/DECT", models + 77}, /* 13 */
{"CRC-12/GSM", models+100}, /* 14 */ {"CRC-12/GSM", models + 100}, /* 14 */
{"CRC-12/UMTS", models+ 78}, /* 15 */ {"CRC-12/UMTS", models + 78}, /* 15 */
{"CRC-13/BBC", models+102}, /* 16 */ {"CRC-13/BBC", models + 102}, /* 16 */
{"CRC-14/DARC", models+ 38}, /* 17 */ {"CRC-14/DARC", models + 38}, /* 17 */
{"CRC-14/GSM", models+ 75}, /* 18 */ {"CRC-14/GSM", models + 75}, /* 18 */
{"CRC-15", models+ 84}, /* 19 */ {"CRC-15", models + 84}, /* 19 */
{"CRC-15/CAN", models+ 84}, /* 20 */ {"CRC-15/CAN", models + 84}, /* 20 */
{"CRC-15/MPT1327", models+ 99}, /* 21 */ {"CRC-15/MPT1327", models + 99}, /* 21 */
{"CRC-16", models+ 69}, /* 22 */ {"CRC-16", models + 69}, /* 22 */
{"CRC-16/ACORN", models + 18}, /* 23 */ {"CRC-16/ACORN", models + 18}, /* 23 */
{"CRC-16/ARC", models+ 69}, /* 24 */ {"CRC-16/ARC", models + 69}, /* 24 */
{"CRC-16/AUG-CCITT", models + 21}, /* 25 */ {"CRC-16/AUG-CCITT", models + 21}, /* 25 */
{"CRC-16/AUTOSAR", models + 25}, /* 26 */ {"CRC-16/AUTOSAR", models + 25}, /* 26 */
{"CRC-16/BUYPASS", models+ 68}, /* 27 */ {"CRC-16/BUYPASS", models + 68}, /* 27 */
{"CRC-16/CCITT", models + 20}, /* 28 */ {"CRC-16/CCITT", models + 20}, /* 28 */
{"CRC-16/CCITT-FALSE", models + 25}, /* 29 */ {"CRC-16/CCITT-FALSE", models + 25}, /* 29 */
{"CRC-16/CCITT-TRUE", models + 20}, /* 30 */ {"CRC-16/CCITT-TRUE", models + 20}, /* 30 */
{"CRC-16/CDMA2000", models+ 98}, /* 31 */ {"CRC-16/CDMA2000", models + 98}, /* 31 */
{"CRC-16/CMS", models+ 72}, /* 32 */ {"CRC-16/CMS", models + 72}, /* 32 */
{"CRC-16/DARC", models + 26}, /* 33 */ {"CRC-16/DARC", models + 26}, /* 33 */
{"CRC-16/DDS-110", models+ 71}, /* 34 */ {"CRC-16/DDS-110", models + 71}, /* 34 */
{"CRC-16/DECT-R", models + 10}, /* 35 */ {"CRC-16/DECT-R", models + 10}, /* 35 */
{"CRC-16/DECT-X", models + 9}, /* 36 */ {"CRC-16/DECT-X", models + 9}, /* 36 */
{"CRC-16/DNP", models+ 49}, /* 37 */ {"CRC-16/DNP", models + 49}, /* 37 */
{"CRC-16/EN-13757", models+ 48}, /* 38 */ {"CRC-16/EN-13757", models + 48}, /* 38 */
{"CRC-16/EPC", models + 26}, /* 39 */ {"CRC-16/EPC", models + 26}, /* 39 */
{"CRC-16/EPC-C1G2", models + 26}, /* 40 */ {"CRC-16/EPC-C1G2", models + 26}, /* 40 */
{"CRC-16/GENIBUS", models + 26}, /* 41 */ {"CRC-16/GENIBUS", models + 26}, /* 41 */
{"CRC-16/GSM", models + 19}, /* 42 */ {"CRC-16/GSM", models + 19}, /* 42 */
{"CRC-16/I-CODE", models + 26}, /* 43 */ {"CRC-16/I-CODE", models + 26}, /* 43 */
{"CRC-16/IBM-3740", models + 25}, /* 44 */ {"CRC-16/IBM-3740", models + 25}, /* 44 */
{"CRC-16/IBM-SDLC", models + 28}, /* 45 */ {"CRC-16/IBM-SDLC", models + 28}, /* 45 */
{"CRC-16/IEC-61158-2", models+ 36}, /* 46 */ {"CRC-16/IEC-61158-2", models + 36}, /* 46 */
{"CRC-16/ISO-HDLC", models + 28}, /* 47 */ {"CRC-16/ISO-HDLC", models + 28}, /* 47 */
{"CRC-16/ISO-IEC-14443-3-A", models + 24}, /* 48 */ {"CRC-16/ISO-IEC-14443-3-A", models + 24}, /* 48 */
{"CRC-16/ISO-IEC-14443-3-B", models + 28}, /* 49 */ {"CRC-16/ISO-IEC-14443-3-B", models + 28}, /* 49 */
{"CRC-16/KERMIT", models + 20}, /* 50 */ {"CRC-16/KERMIT", models + 20}, /* 50 */
{"CRC-16/LHA", models+ 69}, /* 51 */ {"CRC-16/LHA", models + 69}, /* 51 */
{"CRC-16/LJ1200", models+ 63}, /* 52 */ {"CRC-16/LJ1200", models + 63}, /* 52 */
{"CRC-16/LTE", models + 18}, /* 53 */ {"CRC-16/LTE", models + 18}, /* 53 */
{"CRC-16/MAXIM", models+ 70}, /* 54 */ {"CRC-16/MAXIM", models + 70}, /* 54 */
{"CRC-16/MAXIM-DOW", models+ 70}, /* 55 */ {"CRC-16/MAXIM-DOW", models + 70}, /* 55 */
{"CRC-16/MCRF4XX", models + 27}, /* 56 */ {"CRC-16/MCRF4XX", models + 27}, /* 56 */
{"CRC-16/MODBUS", models+ 73}, /* 57 */ {"CRC-16/MODBUS", models + 73}, /* 57 */
{"CRC-16/NRSC-5", models + 14}, /* 58 */ {"CRC-16/NRSC-5", models + 14}, /* 58 */
{"CRC-16/OPENSAFETY-A", models+ 55}, /* 59 */ {"CRC-16/OPENSAFETY-A", models + 55}, /* 59 */
{"CRC-16/OPENSAFETY-B", models+ 65}, /* 60 */ {"CRC-16/OPENSAFETY-B", models + 65}, /* 60 */
{"CRC-16/PROFIBUS", models+ 36}, /* 61 */ {"CRC-16/PROFIBUS", models + 36}, /* 61 */
{"CRC-16/RIELLO", models + 23}, /* 62 */ {"CRC-16/RIELLO", models + 23}, /* 62 */
{"CRC-16/SPI-FUJITSU", models + 21}, /* 63 */ {"CRC-16/SPI-FUJITSU", models + 21}, /* 63 */
{"CRC-16/T10-DIF", models+ 85}, /* 64 */ {"CRC-16/T10-DIF", models + 85}, /* 64 */
{"CRC-16/TELEDISK", models+ 92}, /* 65 */ {"CRC-16/TELEDISK", models + 92}, /* 65 */
{"CRC-16/TMS37157", models + 22}, /* 66 */ {"CRC-16/TMS37157", models + 22}, /* 66 */
{"CRC-16/UMTS", models+ 68}, /* 67 */ {"CRC-16/UMTS", models + 68}, /* 67 */
{"CRC-16/USB", models+ 74}, /* 68 */ {"CRC-16/USB", models + 74}, /* 68 */
{"CRC-16/V-41-LSB", models + 20}, /* 69 */ {"CRC-16/V-41-LSB", models + 20}, /* 69 */
{"CRC-16/V-41-MSB", models + 18}, /* 70 */ {"CRC-16/V-41-MSB", models + 18}, /* 70 */
{"CRC-16/VERIFONE", models+ 68}, /* 71 */ {"CRC-16/VERIFONE", models + 68}, /* 71 */
{"CRC-16/X-25", models + 28}, /* 72 */ {"CRC-16/X-25", models + 28}, /* 72 */
{"CRC-16/XMODEM", models + 18}, /* 73 */ {"CRC-16/XMODEM", models + 18}, /* 73 */
{"CRC-17/CAN-FD", models+ 96}, /* 74 */ {"CRC-17/CAN-FD", models + 96}, /* 74 */
{"CRC-21/CAN-FD", models+ 80}, /* 75 */ {"CRC-21/CAN-FD", models + 80}, /* 75 */
{"CRC-24", models+ 82}, /* 76 */ {"CRC-24", models + 82}, /* 76 */
{"CRC-24/BLE", models + 3}, /* 77 */ {"CRC-24/BLE", models + 3}, /* 77 */
{"CRC-24/FLEXRAY-A", models+ 58}, /* 78 */ {"CRC-24/FLEXRAY-A", models + 58}, /* 78 */
{"CRC-24/FLEXRAY-B", models+ 57}, /* 79 */ {"CRC-24/FLEXRAY-B", models + 57}, /* 79 */
{"CRC-24/INTERLAKEN", models+ 46}, /* 80 */ {"CRC-24/INTERLAKEN", models + 46}, /* 80 */
{"CRC-24/LTE-A", models+ 81}, /* 81 */ {"CRC-24/LTE-A", models + 81}, /* 81 */
{"CRC-24/LTE-B", models+ 66}, /* 82 */ {"CRC-24/LTE-B", models + 66}, /* 82 */
{"CRC-24/OPENPGP", models+ 82}, /* 83 */ {"CRC-24/OPENPGP", models + 82}, /* 83 */
{"CRC-24/OS-9", models+ 67}, /* 84 */ {"CRC-24/OS-9", models + 67}, /* 84 */
{"CRC-3/GSM", models+ 59}, /* 85 */ {"CRC-3/GSM", models + 59}, /* 85 */
{"CRC-3/ROHC", models+ 60}, /* 86 */ {"CRC-3/ROHC", models + 60}, /* 86 */
{"CRC-30/CDMA", models+ 76}, /* 87 */ {"CRC-30/CDMA", models + 76}, /* 87 */
{"CRC-31/PHILIPS", models + 15}, /* 88 */ {"CRC-31/PHILIPS", models + 15}, /* 88 */
{"CRC-32", models + 8}, /* 89 */ {"CRC-32", models + 8}, /* 89 */
{"CRC-32/AAL5", models + 6}, /* 90 */ {"CRC-32/AAL5", models + 6}, /* 90 */
{"CRC-32/ADCCP", models + 8}, /* 91 */ {"CRC-32/ADCCP", models + 8}, /* 91 */
{"CRC-32/AIXM", models+ 79}, /* 92 */ {"CRC-32/AIXM", models + 79}, /* 92 */
{"CRC-32/AUTOSAR", models+104}, /* 93 */ {"CRC-32/AUTOSAR", models + 104}, /* 93 */
{"CRC-32/BASE91-C", models+ 37}, /* 94 */ {"CRC-32/BASE91-C", models + 37}, /* 94 */
{"CRC-32/BASE91-D", models+ 95}, /* 95 */ {"CRC-32/BASE91-D", models + 95}, /* 95 */
{"CRC-32/BZIP2", models + 6}, /* 96 */ {"CRC-32/BZIP2", models + 6}, /* 96 */
{"CRC-32/CASTAGNOLI", models+ 37}, /* 97 */ {"CRC-32/CASTAGNOLI", models + 37}, /* 97 */
{"CRC-32/CKSUM", models + 4}, /* 98 */ {"CRC-32/CKSUM", models + 4}, /* 98 */
{"CRC-32/DECT-B", models + 6}, /* 99 */ {"CRC-32/DECT-B", models + 6}, /* 99 */
{"CRC-32/INTERLAKEN", models+ 37}, /* 100 */ {"CRC-32/INTERLAKEN", models + 37}, /* 100 */
{"CRC-32/ISCSI", models+ 37}, /* 101 */ {"CRC-32/ISCSI", models + 37}, /* 101 */
{"CRC-32/ISO-HDLC", models + 8}, /* 102 */ {"CRC-32/ISO-HDLC", models + 8}, /* 102 */
{"CRC-32/JAMCRC", models + 7}, /* 103 */ {"CRC-32/JAMCRC", models + 7}, /* 103 */
{"CRC-32/MPEG-2", models + 5}, /* 104 */ {"CRC-32/MPEG-2", models + 5}, /* 104 */
{"CRC-32/POSIX", models + 4}, /* 105 */ {"CRC-32/POSIX", models + 4}, /* 105 */
{"CRC-32/V-42", models + 8}, /* 106 */ {"CRC-32/V-42", models + 8}, /* 106 */
{"CRC-32/XFER", models + 1}, /* 107 */ {"CRC-32/XFER", models + 1}, /* 107 */
{"CRC-32/XZ", models + 8}, /* 108 */ {"CRC-32/XZ", models + 8}, /* 108 */
{"CRC-32C", models+ 37}, /* 109 */ {"CRC-32C", models + 37}, /* 109 */
{"CRC-32D", models+ 95}, /* 110 */ {"CRC-32D", models + 95}, /* 110 */
{"CRC-32Q", models+ 79}, /* 111 */ {"CRC-32Q", models + 79}, /* 111 */
{"CRC-4/G-704", models+ 42}, /* 112 */ {"CRC-4/G-704", models + 42}, /* 112 */
{"CRC-4/INTERLAKEN", models+ 43}, /* 113 */ {"CRC-4/INTERLAKEN", models + 43}, /* 113 */
{"CRC-4/ITU", models+ 42}, /* 114 */ {"CRC-4/ITU", models + 42}, /* 114 */
{"CRC-40/GSM", models + 2}, /* 115 */ {"CRC-40/GSM", models + 2}, /* 115 */
{"CRC-5/EPC", models+ 53}, /* 116 */ {"CRC-5/EPC", models + 53}, /* 116 */
{"CRC-5/EPC-C1G2", models+ 53}, /* 117 */ {"CRC-5/EPC-C1G2", models + 53}, /* 117 */
{"CRC-5/G-704", models+ 94}, /* 118 */ {"CRC-5/G-704", models + 94}, /* 118 */
{"CRC-5/ITU", models+ 94}, /* 119 */ {"CRC-5/ITU", models + 94}, /* 119 */
{"CRC-5/USB", models+ 39}, /* 120 */ {"CRC-5/USB", models + 39}, /* 120 */
{"CRC-6/CDMA2000-A", models+ 90}, /* 121 */ {"CRC-6/CDMA2000-A", models + 90}, /* 121 */
{"CRC-6/CDMA2000-B", models + 30}, /* 122 */ {"CRC-6/CDMA2000-B", models + 30}, /* 122 */
{"CRC-6/DARC", models+ 62}, /* 123 */ {"CRC-6/DARC", models + 62}, /* 123 */
{"CRC-6/G-704", models + 16}, /* 124 */ {"CRC-6/G-704", models + 16}, /* 124 */
{"CRC-6/GSM", models+ 97}, /* 125 */ {"CRC-6/GSM", models + 97}, /* 125 */
{"CRC-6/ITU", models + 16}, /* 126 */ {"CRC-6/ITU", models + 16}, /* 126 */
{"CRC-64", models+ 50}, /* 127 */ {"CRC-64", models + 50}, /* 127 */
{"CRC-64/ECMA-182", models+ 50}, /* 128 */ {"CRC-64/ECMA-182", models + 50}, /* 128 */
{"CRC-64/GO-ECMA", models+ 52}, /* 129 */ {"CRC-64/GO-ECMA", models + 52}, /* 129 */
{"CRC-64/GO-ISO", models + 0}, /* 130 */ {"CRC-64/GO-ISO", models + 0}, /* 130 */
{"CRC-64/WE", models+ 51}, /* 131 */ {"CRC-64/WE", models + 51}, /* 131 */
{"CRC-64/XZ", models+ 52}, /* 132 */ {"CRC-64/XZ", models + 52}, /* 132 */
{"CRC-7", models + 29}, /* 133 */ {"CRC-7", models + 29}, /* 133 */
{"CRC-7/MMC", models + 29}, /* 134 */ {"CRC-7/MMC", models + 29}, /* 134 */
{"CRC-7/ROHC", models+ 91}, /* 135 */ {"CRC-7/ROHC", models + 91}, /* 135 */
{"CRC-7/UMTS", models+ 83}, /* 136 */ {"CRC-7/UMTS", models + 83}, /* 136 */
{"CRC-8", models + 11}, /* 137 */ {"CRC-8", models + 11}, /* 137 */
{"CRC-8/AES", models+ 35}, /* 138 */ {"CRC-8/AES", models + 35}, /* 138 */
{"CRC-8/AUTOSAR", models+ 41}, /* 139 */ {"CRC-8/AUTOSAR", models + 41}, /* 139 */
{"CRC-8/BLUETOOTH", models+ 93}, /* 140 */ {"CRC-8/BLUETOOTH", models + 93}, /* 140 */
{"CRC-8/CDMA2000", models+ 89}, /* 141 */ {"CRC-8/CDMA2000", models + 89}, /* 141 */
{"CRC-8/DARC", models+ 47}, /* 142 */ {"CRC-8/DARC", models + 47}, /* 142 */
{"CRC-8/DVB-S2", models+101}, /* 143 */ {"CRC-8/DVB-S2", models + 101}, /* 143 */
{"CRC-8/EBU", models+ 35}, /* 144 */ {"CRC-8/EBU", models + 35}, /* 144 */
{"CRC-8/GSM-A", models + 31}, /* 145 */ {"CRC-8/GSM-A", models + 31}, /* 145 */
{"CRC-8/GSM-B", models+ 54}, /* 146 */ {"CRC-8/GSM-B", models + 54}, /* 146 */
{"CRC-8/I-432-1", models + 12}, /* 147 */ {"CRC-8/I-432-1", models + 12}, /* 147 */
{"CRC-8/I-CODE", models+ 33}, /* 148 */ {"CRC-8/I-CODE", models + 33}, /* 148 */
{"CRC-8/ITU", models + 12}, /* 149 */ {"CRC-8/ITU", models + 12}, /* 149 */
{"CRC-8/LTE", models+ 87}, /* 150 */ {"CRC-8/LTE", models + 87}, /* 150 */
{"CRC-8/MAXIM", models+ 44}, /* 151 */ {"CRC-8/MAXIM", models + 44}, /* 151 */
{"CRC-8/MAXIM-DOW", models+ 44}, /* 152 */ {"CRC-8/MAXIM-DOW", models + 44}, /* 152 */
{"CRC-8/MIFARE-MAD", models+ 32}, /* 153 */ {"CRC-8/MIFARE-MAD", models + 32}, /* 153 */
{"CRC-8/NRSC-5", models+ 45}, /* 154 */ {"CRC-8/NRSC-5", models + 45}, /* 154 */
{"CRC-8/OPENSAFETY", models+ 40}, /* 155 */ {"CRC-8/OPENSAFETY", models + 40}, /* 155 */
{"CRC-8/ROHC", models+ 13}, /* 156 */ {"CRC-8/ROHC", models + 13}, /* 156 */
{"CRC-8/SAE-J1850", models+ 34}, /* 157 */ {"CRC-8/SAE-J1850", models + 34}, /* 157 */
{"CRC-8/SMBUS", models+ 11}, /* 158 */ {"CRC-8/SMBUS", models + 11}, /* 158 */
{"CRC-8/TECH-3250", models+ 35}, /* 159 */ {"CRC-8/TECH-3250", models + 35}, /* 159 */
{"CRC-8/WCDMA", models+ 88}, /* 160 */ {"CRC-8/WCDMA", models + 88}, /* 160 */
{"CRC-82/DARC", models+ 17}, /* 161 */ {"CRC-82/DARC", models + 17}, /* 161 */
{"CRC-A", models+ 24}, /* 162 */ {"CRC-A", models + 24}, /* 162 */
{"CRC-B", models+ 28}, /* 163 */ {"CRC-B", models + 28}, /* 163 */
{"CRC-CCITT", models+ 20}, /* 164 */ {"CRC-CCITT", models + 20}, /* 164 */
{"CRC-IBM", models+ 69}, /* 165 */ {"CRC-IBM", models + 69}, /* 165 */
{"DOW-CRC", models+ 44}, /* 166 */ {"DOW-CRC", models + 44}, /* 166 */
{"JAMCRC", models+ 7}, /* 167 */ {"JAMCRC", models + 7}, /* 167 */
{"KERMIT", models+ 20}, /* 168 */ {"KERMIT", models + 20}, /* 168 */
{"MODBUS", models+ 73}, /* 169 */ {"MODBUS", models + 73}, /* 169 */
{"PKZIP", models+ 8}, /* 170 */ {"PKZIP", models + 8}, /* 170 */
{"R-CRC-16", models+ 10}, /* 171 */ {"R-CRC-16", models + 10}, /* 171 */
{"X-25", models+ 28}, /* 172 */ {"X-25", models + 28}, /* 172 */
{"X-CRC-12", models+ 77}, /* 173 */ {"X-CRC-12", models + 77}, /* 173 */
{"X-CRC-16", models+ 9}, /* 174 */ {"X-CRC-16", models + 9}, /* 174 */
{"XFER", models+ 1}, /* 175 */ {"XFER", models + 1}, /* 175 */
{"XMODEM", models+ 18}, /* 176 */ {"XMODEM", models + 18}, /* 176 */
{"ZMODEM", models+ 18}, /* 177 */ {"ZMODEM", models + 18}, /* 177 */
{NULL, NULL }, /* terminating entry */ {NULL, NULL}, /* terminating entry */
}; };
# define NALIASES 178 # define NALIASES 178

View file

@ -70,7 +70,7 @@ static int l_GetFromBigBuf(lua_State *L) {
len = luaL_checknumber(L, 2); len = luaL_checknumber(L, 2);
} }
if ( len == 0 ) { if (len == 0) {
//signal error by returning Nil, errorstring //signal error by returning Nil, errorstring
lua_pushnil(L); lua_pushnil(L);
lua_pushstring(L, "You need to supply number of bytes larger than zero"); lua_pushstring(L, "You need to supply number of bytes larger than zero");
@ -126,7 +126,7 @@ static int l_GetFromFlashMem(lua_State *L) {
len = luaL_checknumber(L, 2); len = luaL_checknumber(L, 2);
} }
if ( len == 0 ) { if (len == 0) {
//signal error by returning Nil, errorstring //signal error by returning Nil, errorstring
lua_pushnil(L); lua_pushnil(L);
lua_pushstring(L, "You need to supply number of bytes larger than zero"); lua_pushstring(L, "You need to supply number of bytes larger than zero");

View file

@ -5,6 +5,8 @@ define KNOWN_PLATFORMS
+--------------------------------------------------------+ +--------------------------------------------------------+
| PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 | | PM3RDV4 (def) | Proxmark3 rdv4 with AT91SAM7S512 |
+--------------------------------------------------------+ +--------------------------------------------------------+
| PM3RDV4FPC | Proxmark3 rdv4+FPC (experimental) |
+--------------------------------------------------------+
| PM3EVO | Proxmark3 EVO with AT91SAM7S512 | | PM3EVO | Proxmark3 EVO with AT91SAM7S512 |
+--------------------------------------------------------+ +--------------------------------------------------------+
| PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 | | PM3EASY | Proxmark3 rdv3 Easy with AT91SAM7S256 |
@ -31,6 +33,10 @@ ifeq ($(PLATFORM),PM3RDV4)
MCU = AT91SAM7S512 MCU = AT91SAM7S512
PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH
PLTNAME = Proxmark3 rdv4 PLTNAME = Proxmark3 rdv4
else ifeq ($(PLATFORM),PM3RDV4FPC)
MCU = AT91SAM7S512
PLATFORM_DEFS = -DWITH_SMARTCARD -DWITH_FLASH -DWITH_FPC_HOST
PLTNAME = Proxmark3 rdv4
else ifeq ($(PLATFORM),PM3EVO) else ifeq ($(PLATFORM),PM3EVO)
MCU = AT91SAM7S512 MCU = AT91SAM7S512
PLTNAME = Proxmark3 EVO PLTNAME = Proxmark3 EVO
@ -50,6 +56,11 @@ else
$(error Invalid or empty PLATFORM: $(PLATFORM). Known platforms: $(KNOWN_PLATFORMS)) $(error Invalid or empty PLATFORM: $(PLATFORM). Known platforms: $(KNOWN_PLATFORMS))
endif endif
# Add flags dependencies
ifneq (,$(findstring WITH_FPC_,$(PLATFORM_DEFS)))
PLATFORM_DEFS += -DWITH_FPC
endif
export PLATFORM export PLATFORM
export PLTNAME export PLTNAME
export MCU export MCU

View file

@ -31,6 +31,17 @@
*/ */
#include "cmd.h" #include "cmd.h"
#ifdef WITH_FPC_HOST
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
bool reply_via_fpc = 0;
extern void Dbprintf(const char *fmt, ...);
#define Dbprintf_usb(...) {\
reply_via_fpc = 0;\
Dbprintf(__VA_ARGS__);\
reply_via_fpc = 1;}
#endif
uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) { uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void *data, size_t len) {
UsbCommand txcmd; UsbCommand txcmd;
@ -53,11 +64,16 @@ uint8_t cmd_send(uint64_t cmd, uint64_t arg0, uint64_t arg1, uint64_t arg2, void
uint32_t sendlen = 0; uint32_t sendlen = 0;
// Send frame and make sure all bytes are transmitted // Send frame and make sure all bytes are transmitted
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));
#ifdef WITH_FPC #ifdef WITH_FPC_HOST
// usart_init(); if (reply_via_fpc) {
// usart_writebuffer( (uint8_t*)&txcmd, sizeof(UsbCommand) ); sendlen = usart_writebuffer((uint8_t *)&txcmd, sizeof(UsbCommand));
Dbprintf_usb("Sent %i bytes over usart", len);
} else {
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));
}
#else
sendlen = usb_write((uint8_t *)&txcmd, sizeof(UsbCommand));
#endif #endif
return sendlen; return sendlen;

View file

@ -502,7 +502,7 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
{128, 0, 0}, {128, 0, 0},
{256, 0, 0}, {256, 0, 0},
{384, 0, 0}, {384, 0, 0},
}; };
// loop through all samples (well, we don't want to go out-of-bounds) // loop through all samples (well, we don't want to go out-of-bounds)
while (i < size - 512) { while (i < size - 512) {
@ -519,12 +519,12 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
} }
int foo = getClosestClock(minClk); int foo = getClosestClock(minClk);
if (foo > 0 ) { if (foo > 0) {
for (uint8_t i = 0; i < 10; i++) { for (uint8_t i = 0; i < 10; i++) {
if ( tmpclk[i][0] == foo ) { if (tmpclk[i][0] == foo) {
tmpclk[i][1]++; tmpclk[i][1]++;
if ( tmpclk[i][2] == 0) { if (tmpclk[i][2] == 0) {
tmpclk[i][2] = shortestWaveIdx; tmpclk[i][2] = shortestWaveIdx;
} }
break; break;
@ -538,12 +538,12 @@ int DetectStrongAskClock(uint8_t *dest, size_t size, int high, int low, int *clo
for (uint8_t i = 0; i < 10; i++) { for (uint8_t i = 0; i < 10; i++) {
if (g_debugMode == 2) { if (g_debugMode == 2) {
prnt("DEBUG, ASK, clocks %u | hits %u | idx %u" prnt("DEBUG, ASK, clocks %u | hits %u | idx %u"
, tmpclk[i][0] , tmpclk[i][0]
, tmpclk[i][1] , tmpclk[i][1]
, tmpclk[i][2] , tmpclk[i][2]
); );
} }
if ( max < tmpclk[i][1] ) { if (max < tmpclk[i][1]) {
*clock = tmpclk[i][0]; *clock = tmpclk[i][0];
shortestWaveIdx = tmpclk[i][2]; shortestWaveIdx = tmpclk[i][2];
max = tmpclk[i][1]; max = tmpclk[i][1];

View file

@ -10,6 +10,7 @@
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include "usart.h" #include "usart.h"
#include "string.h" #include "string.h"
#include "apps.h" // for Dbprintf
#define AT91_BAUD_RATE 115200 #define AT91_BAUD_RATE 115200
@ -39,61 +40,63 @@ void usart_close(void) {
} }
*/ */
static uint8_t us_inbuf[sizeof(UsbCommand)];
static uint8_t us_outbuf[sizeof(UsbCommand)]; static uint8_t us_outbuf[sizeof(UsbCommand)];
/// Reads data from an USART peripheral // transfer from client to device
/// \param data Pointer to the buffer where the received data will be stored. inline int16_t usart_readbuffer(uint8_t *data) {
/// \param len Size of the data buffer (in bytes). uint32_t rcr = pUS1->US_RCR;
inline int16_t usart_readbuffer(uint8_t *data, size_t len) { if (rcr < sizeof(us_inbuf)) {
pUS1->US_PTCR = AT91C_PDC_RXTDIS;
// Check if the first PDC bank is free memcpy(data, us_inbuf, sizeof(us_inbuf) - rcr);
if (!(pUS1->US_RCR)) { // Reset DMA buffer
pUS1->US_RPR = (uint32_t)data; pUS1->US_RPR = (uint32_t)us_inbuf;
pUS1->US_RCR = len; pUS1->US_RCR = sizeof(us_inbuf);
pUS1->US_PTCR = AT91C_PDC_RXTEN;
pUS1->US_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTDIS; return sizeof(us_inbuf) - rcr;
return 2;
}
// Check if the second PDC bank is free
else if (!(pUS1->US_RNCR)) {
pUS1->US_RNPR = (uint32_t)data;
pUS1->US_RNCR = len;
pUS1->US_PTCR = AT91C_PDC_RXTEN | AT91C_PDC_TXTDIS;
return 1;
} else { } else {
return 0; return 0;
} }
} }
inline bool usart_dataavailable(void) {
return pUS1->US_RCR < sizeof(us_inbuf);
}
inline int16_t usart_readcommand(uint8_t *data) {
if (pUS1->US_RCR == 0)
return usart_readbuffer(data);
else
return 0;
}
inline bool usart_commandavailable(void) {
return pUS1->US_RCR == 0;
}
// transfer from device to client // transfer from device to client
inline int16_t usart_writebuffer(uint8_t *data, size_t len) { inline int16_t usart_writebuffer(uint8_t *data, size_t len) {
// Check if the first PDC bank is free
if (!(pUS1->US_TCR)) { if (pUS1->US_CSR & AT91C_US_ENDTX) {
memcpy(us_outbuf, data, len); memcpy(us_outbuf, data, len);
pUS1->US_TPR = (uint32_t)us_outbuf; pUS1->US_TPR = (uint32_t)us_outbuf;
pUS1->US_TCR = sizeof(us_outbuf); pUS1->US_TCR = len;
pUS1->US_PTCR = AT91C_PDC_TXTEN;
pUS1->US_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTDIS; while (!(pUS1->US_CSR & AT91C_US_ENDTX)) {};
return 2; pUS1->US_PTCR = AT91C_PDC_TXTDIS;
} return len;
// Check if the second PDC bank is free
else if (!(pUS1->US_TNCR)) {
memcpy(us_outbuf, data, len);
pUS1->US_TNPR = (uint32_t)us_outbuf;
pUS1->US_TNCR = sizeof(us_outbuf);
pUS1->US_PTCR = AT91C_PDC_TXTEN | AT91C_PDC_RXTDIS;
return 1;
} else { } else {
return 0; return 0;
} }
} }
void usart_init(void) { void usart_init(void) {
// For a nice detailed sample, interrupt driven but still relevant.
// See https://www.sparkfun.com/datasheets/DevTools/SAM7/at91sam7%20serial%20communications.pdf
// disable & reset receiver / transmitter for configuration // disable & reset receiver / transmitter for configuration
pUS1->US_CR = (AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS); pUS1->US_CR = (AT91C_US_RSTRX | AT91C_US_RSTTX | AT91C_US_RXDIS | AT91C_US_TXDIS);
@ -113,6 +116,7 @@ void usart_init(void) {
// set mode // set mode
pUS1->US_MR = AT91C_US_USMODE_NORMAL | // normal mode pUS1->US_MR = AT91C_US_USMODE_NORMAL | // normal mode
AT91C_US_CLKS_CLOCK | // MCK (48MHz) AT91C_US_CLKS_CLOCK | // MCK (48MHz)
AT91C_US_OVER | // oversampling
AT91C_US_CHRL_8_BITS | // 8 bits AT91C_US_CHRL_8_BITS | // 8 bits
AT91C_US_PAR_NONE | // parity: none AT91C_US_PAR_NONE | // parity: none
AT91C_US_NBSTOP_1_BIT | // 1 stop bit AT91C_US_NBSTOP_1_BIT | // 1 stop bit
@ -121,16 +125,9 @@ void usart_init(void) {
// all interrupts disabled // all interrupts disabled
pUS1->US_IDR = 0xFFFF; pUS1->US_IDR = 0xFFFF;
// iceman, setting 115200 doesn't work. Only speed I got to work is 9600. pUS1->US_BRGR = 48054841 / (115200 << 3);
// something fishy with the AT91SAM7S512 USART.. Or I missed something // Need speed?
// For a nice detailed sample, interrupt driven but still relevant. //pUS1->US_BRGR = 48054841 / (460800 << 3);
// See https://www.sparkfun.com/datasheets/DevTools/SAM7/at91sam7%20serial%20communications.pdf
// set baudrate to 115200
// 115200 * 16 == 1843200
//
//pUS1->US_BRGR = (48UL*1000*1000) / (9600*16);
pUS1->US_BRGR = 48054841 / (9600 << 4);
// Write the Timeguard Register // Write the Timeguard Register
pUS1->US_TTGR = 0; pUS1->US_TTGR = 0;
@ -138,6 +135,17 @@ void usart_init(void) {
pUS1->US_FIDI = 0; pUS1->US_FIDI = 0;
pUS1->US_IF = 0; pUS1->US_IF = 0;
// Disable double buffers for now
pUS1->US_TNPR = (uint32_t)0;
pUS1->US_TNCR = 0;
pUS1->US_RNPR = (uint32_t)0;
pUS1->US_RNCR = 0;
// re-enable receiver / transmitter // re-enable receiver / transmitter
pUS1->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN); pUS1->US_CR = (AT91C_US_RXEN | AT91C_US_TXEN);
// ready to receive
pUS1->US_RPR = (uint32_t)us_inbuf;
pUS1->US_RCR = sizeof(us_inbuf);
pUS1->US_PTCR = AT91C_PDC_RXTEN;
} }

View file

@ -7,6 +7,9 @@
void usart_init(void); void usart_init(void);
void usart_close(void); void usart_close(void);
int16_t usart_readbuffer(uint8_t *data, size_t len); int16_t usart_readbuffer(uint8_t *data);
int16_t usart_writebuffer(uint8_t *data, size_t len); int16_t usart_writebuffer(uint8_t *data, size_t len);
bool usart_dataavailable(void);
int16_t usart_readcommand(uint8_t *data);
bool usart_commandavailable(void);
#endif #endif

View file

@ -34,6 +34,12 @@ typedef struct {
uint32_t asDwords[USB_CMD_DATA_SIZE / 4]; uint32_t asDwords[USB_CMD_DATA_SIZE / 4];
} d; } d;
} PACKED UsbCommand; } PACKED UsbCommand;
#ifdef WITH_FPC_HOST
// "Session" flag, to tell via which interface next msgs should be sent: USB or FPC USART
extern bool reply_via_fpc;
#endif
// A struct used to send sample-configs over USB // A struct used to send sample-configs over USB
typedef struct { typedef struct {
uint8_t decimation; uint8_t decimation;

View file

@ -6,7 +6,6 @@ LDFLAGS +=
OBJS = crypto1.o crapto1.o parity.o util_posix.o bucketsort.o OBJS = crypto1.o crapto1.o parity.o util_posix.o bucketsort.o
EXES = mfkey32 mfkey32v2 mfkey64 EXES = mfkey32 mfkey32v2 mfkey64
WINEXES = $(patsubst %, %.exe, $(EXES))
all: $(OBJS) $(EXES) all: $(OBJS) $(EXES)
@ -17,4 +16,4 @@ all: $(OBJS) $(EXES)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $< $(CC) $(CFLAGS) $(LDFLAGS) -o $@ $(OBJS) $<
clean: clean:
rm -f $(OBJS) $(EXES) $(WINEXES) rm -f $(OBJS) $(EXES)

View file

@ -1,20 +1,23 @@
CC = gcc CC = gcc
LD = gcc CFLAGS = -std=c99 -Wall -O3 -I.
CFLAGS = -std=c99 -Wall -O3 -c LDFLAGS = -std=c99 -Wall
LDFLAGS = SRC := $(wildcard *.c)
OBJ := $(SRC:.c=.o)
DEP := $(SRC:.c=.d)
PROG := nonce2key
OBJS = crypto1.o crapto1.o all: $(PROG)
HEADERS = crapto1.h
EXES = nonce2key
WINEXES = $(patsubst %, %.exe, $(EXES))
all: $(OBJS) $(EXES) $(PROG): $(OBJ)
$(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
%.o : %.c
$(CC) $(CFLAGS) -c -o $@ $<
% : %.c
$(LD) $(LDFLAGS) -o $@ $(OBJS) $<
clean: clean:
rm -f $(OBJS) $(EXES) $(WINEXES) @$(RM) $(DEP) $(OBJ) $(PROG)
ifneq ($(filter clean,$(MAKECMDGOALS)),clean)
-include $(DEP)
endif
%.d: %.c
$(info GEN $@)
@$(CC) -MM $(CFLAGS) $< | sed 's/\($*\)\.o[ :]*/\1.o $@ : /g' > $@

View file

@ -71,7 +71,7 @@ typedef void *serial_port;
* *
* On errors, this method returns INVALID_SERIAL_PORT or CLAIMED_SERIAL_PORT. * On errors, this method returns INVALID_SERIAL_PORT or CLAIMED_SERIAL_PORT.
*/ */
serial_port uart_open(const char *pcPortName); serial_port uart_open(const char *pcPortName, uint32_t speed);
/* Closes the given port. /* Closes the given port.
*/ */

View file

@ -73,7 +73,7 @@ struct timeval timeout = {
.tv_usec = 30000 // 30 000 micro seconds .tv_usec = 30000 // 30 000 micro seconds
}; };
serial_port uart_open(const char *pcPortName) { serial_port uart_open(const char *pcPortName, uint32_t speed) {
serial_port_unix *sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t)); serial_port_unix *sp = calloc(sizeof(serial_port_unix), sizeof(uint8_t));
if (sp == 0) return INVALID_SERIAL_PORT; if (sp == 0) return INVALID_SERIAL_PORT;
@ -194,23 +194,19 @@ serial_port uart_open(const char *pcPortName) {
// Flush all lingering data that may exist // Flush all lingering data that may exist
tcflush(sp->fd, TCIOFLUSH); tcflush(sp->fd, TCIOFLUSH);
#ifdef WITH_FPC if (!uart_set_speed(sp, speed)) {
if (uart_set_speed(sp, 115200)) { // trying some fallbacks automatically
printf("[=] UART Setting serial baudrate 115200 [FPC enabled]\n"); speed = 115200;
} else { if (!uart_set_speed(sp, speed)) {
uart_set_speed(sp, 9600); speed = 9600;
printf("[=] UART Setting serial baudrate 9600 [FPC enabled]\n"); if (!uart_set_speed(sp, speed)) {
uart_close(sp);
printf("[!] UART error while setting baudrate\n");
return INVALID_SERIAL_PORT;
}
}
} }
#else printf("[=] UART Setting serial baudrate %i\n", speed);
// set speed, works for UBUNTU 14.04
bool success = uart_set_speed(sp, 460800);
if (success) {
printf("[=] UART Setting serial baudrate 460800\n");
} else {
uart_set_speed(sp, 115200);
printf("[=] UART Setting serial baudrate 115200\n");
}
#endif
return sp; return sp;
} }

View file

@ -48,7 +48,7 @@ typedef struct {
COMMTIMEOUTS ct; // Serial port time-out configuration COMMTIMEOUTS ct; // Serial port time-out configuration
} serial_port_windows; } serial_port_windows;
serial_port uart_open(const char *pcPortName) { serial_port uart_open(const char *pcPortName, uint32_t speed) {
char acPortName[255]; char acPortName[255];
serial_port_windows *sp = calloc(sizeof(serial_port_windows), sizeof(uint8_t)); serial_port_windows *sp = calloc(sizeof(serial_port_windows), sizeof(uint8_t));
@ -87,6 +87,7 @@ serial_port uart_open(const char *pcPortName) {
// all zero's configure: no timeout for read/write used. // all zero's configure: no timeout for read/write used.
// took settings from libnfc/buses/uart.c // took settings from libnfc/buses/uart.c
#ifdef WITH_FPC #ifdef WITH_FPC
// Still relevant?
sp->ct.ReadIntervalTimeout = 1000; sp->ct.ReadIntervalTimeout = 1000;
sp->ct.ReadTotalTimeoutMultiplier = 0; sp->ct.ReadTotalTimeoutMultiplier = 0;
sp->ct.ReadTotalTimeoutConstant = 1500; sp->ct.ReadTotalTimeoutConstant = 1500;
@ -108,22 +109,19 @@ serial_port uart_open(const char *pcPortName) {
PurgeComm(sp->hPort, PURGE_RXABORT | PURGE_RXCLEAR); PurgeComm(sp->hPort, PURGE_RXABORT | PURGE_RXCLEAR);
#ifdef WITH_FPC if (!uart_set_speed(sp, speed)) {
if (uart_set_speed(sp, 115200)) { // trying some fallbacks automatically
printf("[=] UART Setting serial baudrate 115200 [FPC enabled]\n"); speed = 115200;
} else { if (!uart_set_speed(sp, speed)) {
uart_set_speed(sp, 9600); speed = 9600;
printf("[=] UART Setting serial baudrate 9600 [FPC enabled]\n"); if (!uart_set_speed(sp, speed)) {
uart_close(sp);
printf("[!] UART error while setting baudrate\n");
return INVALID_SERIAL_PORT;
}
}
} }
#else printf("[=] UART Setting serial baudrate %i\n", speed);
bool success = uart_set_speed(sp, 460800);
if (success) {
printf("[=] UART Setting serial baudrate 460800\n");
} else {
uart_set_speed(sp, 115200);
printf("[=] UART Setting serial baudrate 115200\n");
}
#endif
return sp; return sp;
} }