Skip to content

Commit 43591e6

Browse files
marshmellow42pwpiwi
authored andcommitted
Add Smartcard functions (RDV4.0) (#646)
* allow common makefile options-defines * remove non-existing file references * Uncomment lcd option (still) not enabled by default use Makefile_Enabled_Options.common to enable lcd if desired. * Add Smartcard Functions * add smartcard to menu + make get atr work sc is now functioning as far as my limited knowledge takes me * sc cleanup - add init to all sc commands... because cmds won't work until the first init happens. (multiple inits don't appear to affect it negatively) * default options to exclude Smartcard for main repo * update changelog
1 parent f684231 commit 43591e6

14 files changed

+1661
-22
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac
2424
- Changed driver file proxmark3.inf to support both old and new Product/Vendor IDs (piwi)
2525

2626
### Added
27+
- Added `sc` smartcard (contact card) commands - reader, info, raw, upgrade, setclock, list (hardware version RDV4.0 only) must turn option on in makefile options (Willok, Iceman, marshmellow)
2728
- Added a bitbang mode to `lf cmdread` if delay is 0 the cmd bits turn off and on the antenna with 0 and 1 respectively (marshmellow)
2829
- Added PAC/Stanley detection to lf search (marshmellow)
2930
- Added lf pac demod and lf pac read - extracts the raw blocks from a PAC/Stanley tag (marshmellow)

armsrc/Makefile

+7-2
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,22 @@ APP_CFLAGS = -DON_DEVICE \
1515

1616
include ../common/Makefile_Enabled_Options.common
1717

18-
ifneq (,$(findstring LCD,$(APP_CFLAGS)))
18+
ifneq (,$(findstring WITH_LCD,$(APP_CFLAGS)))
1919
SRC_LCD = fonts.c LCD.c
2020
else
2121
SRC_LCD =
2222
endif
23-
#SRC_LCD = fonts.c LCD.c
2423
SRC_LF = lfops.c hitag2.c hitagS.c lfsampling.c pcf7931.c lfdemod.c protocols.c
2524
SRC_ISO15693 = iso15693.c iso15693tools.c
2625
SRC_ISO14443a = epa.c iso14443a.c mifareutil.c mifarecmd.c mifaresniff.c mifaresim.c
2726
SRC_ISO14443b = iso14443b.c
2827
SRC_CRAPTO1 = crypto1.c des.c
2928
SRC_CRC = iso14443crc.c crc.c crc16.c crc32.c parity.c
29+
ifneq (,$(findstring WITH_SMARTCARD,$(APP_CFLAGS)))
30+
SRC_SMARTCARD = i2c.c
31+
else
32+
SRC_SMARTCARD =
33+
endif
3034
#the FPGA bitstream files. Note: order matters!
3135
FPGA_BITSTREAMS = fpga_lf.bit fpga_hf.bit
3236

@@ -44,6 +48,7 @@ THUMBSRC = start.c \
4448
$(SRC_ISO15693) \
4549
$(SRC_LF) \
4650
$(SRC_ZLIB) \
51+
$(SRC_SMARTCARD) \
4752
appmain.c \
4853
printf.c \
4954
util.c \

armsrc/appmain.c

+35-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@
3030
#ifdef WITH_LCD
3131
#include "LCD.h"
3232
#endif
33+
#ifdef WITH_SMARTCARD
34+
#include "i2c.h"
35+
#endif
36+
3337

3438
// Craig Young - 14a stand-alone code
3539
#ifdef WITH_ISO14443a
@@ -357,12 +361,15 @@ void SendStatus(void)
357361
{
358362
BigBuf_print_status();
359363
Fpga_print_status();
364+
#ifdef WITH_SMARTCARD
365+
I2C_print_status();
366+
#endif
360367
printConfig(); //LF Sampling config
361368
printUSBSpeed();
362369
Dbprintf("Various");
363-
Dbprintf(" MF_DBGLEVEL......%d", MF_DBGLEVEL);
364-
Dbprintf(" ToSendMax........%d",ToSendMax);
365-
Dbprintf(" ToSendBit........%d",ToSendBit);
370+
Dbprintf(" MF_DBGLEVEL........%d", MF_DBGLEVEL);
371+
Dbprintf(" ToSendMax..........%d", ToSendMax);
372+
Dbprintf(" ToSendBit..........%d", ToSendBit);
366373

367374
cmd_send(CMD_ACK,1,0,0,0,0);
368375
}
@@ -1253,6 +1260,31 @@ void UsbPacketReceived(uint8_t *packet, int len)
12531260
HfSnoop(c->arg[0], c->arg[1]);
12541261
break;
12551262
#endif
1263+
#ifdef WITH_SMARTCARD
1264+
case CMD_SMART_ATR: {
1265+
SmartCardAtr();
1266+
break;
1267+
}
1268+
case CMD_SMART_SETCLOCK:{
1269+
SmartCardSetClock(c->arg[0]);
1270+
break;
1271+
}
1272+
case CMD_SMART_RAW: {
1273+
SmartCardRaw(c->arg[0], c->arg[1], c->d.asBytes);
1274+
break;
1275+
}
1276+
case CMD_SMART_UPLOAD: {
1277+
// upload file from client
1278+
uint8_t *mem = BigBuf_get_addr();
1279+
memcpy( mem + c->arg[0], c->d.asBytes, USB_CMD_DATA_SIZE);
1280+
cmd_send(CMD_ACK,1,0,0,0,0);
1281+
break;
1282+
}
1283+
case CMD_SMART_UPGRADE: {
1284+
SmartCardUpgrade(c->arg[0]);
1285+
break;
1286+
}
1287+
#endif
12561288

12571289
case CMD_BUFF_CLEAR:
12581290
BigBuf_Clear();

0 commit comments

Comments
 (0)