mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-31 12:00:10 -07:00
Adding support for standard USB Smartcard Readers (#769)
* add PCSC reader support to 'sc raw' and all 'emv' commands * move all APDU -> TPDU mapping to ExchangeAPDUSC() * print "PSE" instead of "PPSE" when using contact interface * fix some #defines in protocols.h * DropField only when using contactless * some refactoring
This commit is contained in:
parent
437035a75b
commit
6b5105bea9
12 changed files with 388 additions and 311 deletions
|
@ -61,7 +61,7 @@ int CmdHFFidoInfo(const char *cmd) {
|
||||||
PrintAndLog("--------------------------------------------");
|
PrintAndLog("--------------------------------------------");
|
||||||
SetAPDULogging(false);
|
SetAPDULogging(false);
|
||||||
|
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = FIDOSelect(true, true, buf, sizeof(buf), &len, &sw);
|
int res = FIDOSelect(true, true, buf, sizeof(buf), &len, &sw);
|
||||||
|
|
|
@ -43,8 +43,7 @@ static int usage_sm_raw(void) {
|
||||||
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
PrintAndLogEx(NORMAL, " d <bytes> : bytes to send");
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(NORMAL, "Examples:");
|
PrintAndLogEx(NORMAL, "Examples:");
|
||||||
PrintAndLogEx(NORMAL, " sc raw s 0 d 00a404000e315041592e5359532e4444463031 - `1PAY.SYS.DDF01` PPSE directory with get ATR");
|
PrintAndLogEx(NORMAL, " sc raw s 0 d 00a404000e315041592e5359532e4444463031 - `1PAY.SYS.DDF01` PSE directory with get ATR");
|
||||||
PrintAndLogEx(NORMAL, " sc raw 0 d 00a404000e325041592e5359532e4444463031 - `2PAY.SYS.DDF01` PPSE directory");
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,19 +176,19 @@ float FArray[] = {
|
||||||
0 // b1111 RFU
|
0 // b1111 RFU
|
||||||
};
|
};
|
||||||
|
|
||||||
int GetATRDi(uint8_t *atr, size_t atrlen) {
|
static int GetATRDi(uint8_t *atr, size_t atrlen) {
|
||||||
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
||||||
|
|
||||||
return DiArray[TA1 & 0x0f]; // The 4 low-order bits of TA1 (4th MSbit to 1st LSbit) encode Di
|
return DiArray[TA1 & 0x0f]; // The 4 low-order bits of TA1 (4th MSbit to 1st LSbit) encode Di
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetATRFi(uint8_t *atr, size_t atrlen) {
|
static int GetATRFi(uint8_t *atr, size_t atrlen) {
|
||||||
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
||||||
|
|
||||||
return FiArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
|
return FiArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
|
||||||
}
|
}
|
||||||
|
|
||||||
float GetATRF(uint8_t *atr, size_t atrlen) {
|
static float GetATRF(uint8_t *atr, size_t atrlen) {
|
||||||
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
uint8_t TA1 = GetATRTA1(atr, atrlen);
|
||||||
|
|
||||||
return FArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
|
return FArray[TA1 >> 4]; // The 4 high-order bits of TA1 (8th MSbit to 5th LSbit) encode fmax and Fi
|
||||||
|
@ -350,82 +349,48 @@ static bool smart_select(bool silent) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smart_wait(uint8_t *data) {
|
|
||||||
UsbCommand resp;
|
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
|
||||||
PrintAndLogEx(WARNING, "smart card response timeout");
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t len = resp.arg[0];
|
static void smart_transmit(uint8_t *data, uint32_t data_len, uint32_t flags, uint8_t *response, int *response_len, uint32_t max_response_len)
|
||||||
if ( !len ) {
|
{
|
||||||
PrintAndLogEx(WARNING, "smart card response failed");
|
// PrintAndLogEx(SUCCESS, "C-TPDU>>>> %s", sprint_hex(data, data_len));
|
||||||
return -2;
|
if (UseAlternativeSmartcardReader) {
|
||||||
}
|
*response_len = max_response_len;
|
||||||
memcpy(data, resp.d.asBytes, len);
|
pcscTransmit(data, data_len, flags, response, response_len);
|
||||||
if (len >= 2) {
|
|
||||||
PrintAndLogEx(SUCCESS, "%02X%02X | %s", data[len - 2], data[len - 1], GetAPDUCodeDescription(data[len - 2], data[len - 1]));
|
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(SUCCESS, " %d | %s", len, sprint_hex_inrow_ex(data, len, 8));
|
UsbCommand c = {CMD_SMART_RAW, {flags, data_len, 0}};
|
||||||
}
|
memcpy(c.d.asBytes, data, data_len);
|
||||||
|
SendCommand(&c);
|
||||||
return len;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int smart_response(uint8_t *data) {
|
if (!WaitForResponseTimeout(CMD_ACK, &c, 2500)) {
|
||||||
|
PrintAndLogEx(WARNING, "smart card response timeout");
|
||||||
int datalen = smart_wait(data);
|
*response_len = -1;
|
||||||
bool needGetData = false;
|
return;
|
||||||
|
|
||||||
if (datalen < 2 ) {
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data[datalen - 2] == 0x61 || data[datalen - 2] == 0x9F ) {
|
|
||||||
needGetData = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (needGetData) {
|
|
||||||
int len = data[datalen - 1];
|
|
||||||
PrintAndLogEx(INFO, "Requesting 0x%02X bytes response", len);
|
|
||||||
uint8_t getstatus[] = {0x00, ISO7816_GETSTATUS, 0x00, 0x00, len};
|
|
||||||
UsbCommand cStatus = {CMD_SMART_RAW, {SC_RAW, sizeof(getstatus), 0}};
|
|
||||||
memcpy(cStatus.d.asBytes, getstatus, sizeof(getstatus) );
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&cStatus);
|
|
||||||
|
|
||||||
datalen = smart_wait(data);
|
|
||||||
|
|
||||||
if (datalen < 2 ) {
|
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// data wo ACK
|
*response_len = c.arg[0];
|
||||||
if (datalen != len + 2) {
|
if (*response_len > 0) {
|
||||||
// data with ACK
|
memcpy(response, c.d.asBytes, *response_len);
|
||||||
if (datalen == len + 2 + 1) { // 2 - response, 1 - ACK
|
|
||||||
if (data[0] != ISO7816_GETSTATUS) {
|
|
||||||
PrintAndLogEx(ERR, "GetResponse ACK error. len 0x%x | data[0] %02X", len, data[0]);
|
|
||||||
datalen = 0;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
datalen--;
|
|
||||||
memmove(data, &data[1], datalen);
|
|
||||||
} else {
|
|
||||||
// wrong length
|
|
||||||
PrintAndLogEx(WARNING, "GetResponse wrong length. Must be 0x%02X got 0x%02X", len, datalen - 3);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
if (*response_len <= 0) {
|
||||||
return datalen;
|
PrintAndLogEx(WARNING, "smart card response failed");
|
||||||
|
*response_len = -2;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (*response_len < 2) {
|
||||||
|
// PrintAndLogEx(SUCCESS, "R-TPDU %02X | ", response[0]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// PrintAndLogEx(SUCCESS, "R-TPDU<<<< %s", sprint_hex(response, *response_len));
|
||||||
|
// PrintAndLogEx(SUCCESS, "R-TPDU SW %02X%02X | %s", response[*response_len-2], response[*response_len-1], GetAPDUCodeDescription(response[*response_len-2], response[*response_len-1]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CmdSmartSelect(const char *Cmd) {
|
static int CmdSmartSelect(const char *Cmd)
|
||||||
|
{
|
||||||
const char *readername;
|
const char *readername;
|
||||||
|
|
||||||
if (tolower(param_getchar(Cmd, 0)) == 'h') {
|
if (tolower(param_getchar(Cmd, 0)) == 'h') {
|
||||||
|
@ -449,7 +414,8 @@ int CmdSmartSelect(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdSmartRaw(const char *Cmd) {
|
|
||||||
|
static int CmdSmartRaw(const char *Cmd) {
|
||||||
|
|
||||||
int hexlen = 0;
|
int hexlen = 0;
|
||||||
bool active = false;
|
bool active = false;
|
||||||
|
@ -457,7 +423,7 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
bool useT0 = false;
|
bool useT0 = false;
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false, reply = true, decodeTLV = false, breakloop = false;
|
bool errors = false, reply = true, decodeTLV = false, breakloop = false;
|
||||||
uint8_t data[USB_CMD_DATA_SIZE] = {0x00};
|
uint8_t data[ISO7816_MAX_FRAME_SIZE] = {0x00};
|
||||||
|
|
||||||
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
while (param_getchar(Cmd, cmdp) != 0x00 && !errors) {
|
||||||
switch (tolower(param_getchar(Cmd, cmdp))) {
|
switch (tolower(param_getchar(Cmd, cmdp))) {
|
||||||
|
@ -511,101 +477,107 @@ int CmdSmartRaw(const char *Cmd) {
|
||||||
//Validations
|
//Validations
|
||||||
if (errors || cmdp == 0 ) return usage_sm_raw();
|
if (errors || cmdp == 0 ) return usage_sm_raw();
|
||||||
|
|
||||||
// arg0 = RFU flags
|
uint32_t flags = 0;
|
||||||
// arg1 = length
|
uint32_t protocol = 0;
|
||||||
UsbCommand c = {CMD_SMART_RAW, {0, hexlen, 0}};
|
|
||||||
|
|
||||||
if (active || active_select) {
|
if (active || active_select) {
|
||||||
c.arg[0] |= SC_CONNECT;
|
flags |= SC_CONNECT;
|
||||||
if (active_select)
|
if (active_select)
|
||||||
c.arg[0] |= SC_SELECT;
|
flags |= SC_SELECT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hexlen > 0) {
|
if (hexlen > 0) {
|
||||||
if (useT0)
|
if (useT0)
|
||||||
c.arg[0] |= SC_RAW_T0;
|
protocol = SC_RAW_T0;
|
||||||
else
|
else
|
||||||
c.arg[0] |= SC_RAW;
|
protocol = SC_RAW;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(c.d.asBytes, data, hexlen );
|
int response_len = 0;
|
||||||
clearCommandBuffer();
|
uint8_t *response = NULL;
|
||||||
SendCommand(&c);
|
if (reply) {
|
||||||
|
response = calloc(ISO7816_MAX_FRAME_SIZE, sizeof(uint8_t));
|
||||||
|
if ( !response )
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
smart_transmit(data, hexlen, flags|protocol, response, &response_len, ISO7816_MAX_FRAME_SIZE);
|
||||||
|
|
||||||
// reading response from smart card
|
// reading response from smart card
|
||||||
if ( reply ) {
|
if ( reply ) {
|
||||||
|
if ( response_len < 0 ) {
|
||||||
uint8_t* buf = calloc(USB_CMD_DATA_SIZE, sizeof(uint8_t));
|
free(response);
|
||||||
if ( !buf )
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
int len = smart_response(buf);
|
|
||||||
if ( len < 0 ) {
|
|
||||||
free(buf);
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( buf[0] == 0x6C ) {
|
if ( response[0] == 0x6C ) {
|
||||||
data[4] = buf[1];
|
data[4] = response[1];
|
||||||
|
smart_transmit(data, hexlen, protocol, response, &response_len, ISO7816_MAX_FRAME_SIZE);
|
||||||
memcpy(c.d.asBytes, data, sizeof(data) );
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&c);
|
|
||||||
len = smart_response(buf);
|
|
||||||
|
|
||||||
data[4] = 0;
|
data[4] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (decodeTLV && len > 4)
|
if (decodeTLV && response_len > 4)
|
||||||
TLVPrintFromBuffer(buf, len-2);
|
TLVPrintFromBuffer(response, response_len-2);
|
||||||
|
|
||||||
free(buf);
|
free(response);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen) {
|
|
||||||
*dataoutlen = 0;
|
int ExchangeAPDUSC(uint8_t *APDU, int APDUlen, bool activateCard, bool leaveSignalON, uint8_t *response, int maxresponselen, int *responselen)
|
||||||
|
{
|
||||||
|
uint8_t TPDU[ISO7816_MAX_FRAME_SIZE];
|
||||||
|
|
||||||
|
*responselen = 0;
|
||||||
|
|
||||||
if (activateCard)
|
if (activateCard)
|
||||||
smart_select(false);
|
smart_select(false);
|
||||||
|
|
||||||
PrintAndLogEx(DEBUG, "APDU SC");
|
uint32_t flags = SC_RAW_T0;
|
||||||
|
|
||||||
UsbCommand c = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}};
|
|
||||||
if (activateCard) {
|
if (activateCard) {
|
||||||
c.arg[0] |= SC_SELECT | SC_CONNECT;
|
flags |= SC_SELECT | SC_CONNECT;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APDUlen == 4) { // Case 1
|
||||||
|
memcpy(TPDU, APDU, 4);
|
||||||
|
TPDU[4] = 0x00;
|
||||||
|
smart_transmit(TPDU, 5, flags, response, responselen, maxresponselen);
|
||||||
|
} else if (APDUlen == 5) { // Case 2 Short
|
||||||
|
smart_transmit(APDU, 5, flags, response, responselen, maxresponselen);
|
||||||
|
if (response[0] == 0x6C) { // wrong Le
|
||||||
|
uint16_t Le = APDU[4] ? APDU[4] : 256;
|
||||||
|
uint8_t La = response[1];
|
||||||
|
memcpy(TPDU, APDU, 5);
|
||||||
|
TPDU[4] = La;
|
||||||
|
smart_transmit(TPDU, 5, SC_RAW_T0, response, responselen, maxresponselen);
|
||||||
|
if (Le < La && *responselen >= 0) {
|
||||||
|
response[Le] = response[*responselen-2];
|
||||||
|
response[Le+1] = response[*responselen-1];
|
||||||
|
*responselen = Le + 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (APDU[4] != 0 && APDUlen == 5 + APDU[4]) { // Case 3 Short
|
||||||
|
smart_transmit(APDU, APDUlen, flags, response, responselen, maxresponselen);
|
||||||
|
} else if (APDU[4] != 0 && APDUlen == 5 + APDU[4] + 1) { // Case 4 Short
|
||||||
|
smart_transmit(APDU, APDUlen-1, flags, response, responselen, maxresponselen);
|
||||||
|
if (response[0] == 0x90 && response[1] == 0x00) {
|
||||||
|
uint8_t Le = APDU[APDUlen-1];
|
||||||
|
uint8_t get_response[5] = {0x00, ISO7816_GET_RESPONSE, 0x00, 0x00, Le};
|
||||||
|
return ExchangeAPDUSC(get_response, 5, false, leaveSignalON, response, maxresponselen, responselen);
|
||||||
|
}
|
||||||
|
} else { // Long Cases not yet implemented
|
||||||
|
PrintAndLogEx(ERR, "Long APDUs not yet implemented");
|
||||||
|
*responselen = -3;
|
||||||
}
|
}
|
||||||
memcpy(c.d.asBytes, datain, datainlen);
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&c);
|
|
||||||
|
|
||||||
int len = smart_response(dataout);
|
if (*responselen < 0 ) {
|
||||||
|
|
||||||
if ( len < 0 ) {
|
|
||||||
return 2;
|
return 2;
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// retry
|
|
||||||
if (len > 1 && dataout[len - 2] == 0x6c && datainlen > 4) {
|
|
||||||
UsbCommand c2 = {CMD_SMART_RAW, {SC_RAW_T0, datainlen, 0}};
|
|
||||||
memcpy(c2.d.asBytes, datain, 5);
|
|
||||||
|
|
||||||
// transfer length via T=0
|
|
||||||
c2.d.asBytes[4] = dataout[len - 1];
|
|
||||||
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&c2);
|
|
||||||
|
|
||||||
len = smart_response(dataout);
|
|
||||||
}
|
|
||||||
*dataoutlen = len;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int CmdSmartUpgrade(const char *Cmd) {
|
static int CmdSmartUpgrade(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(NORMAL, "");
|
PrintAndLogEx(NORMAL, "");
|
||||||
PrintAndLogEx(WARNING, "WARNING - RDV4.0 Smartcard Socket Firmware upgrade.");
|
PrintAndLogEx(WARNING, "WARNING - RDV4.0 Smartcard Socket Firmware upgrade.");
|
||||||
|
@ -805,7 +777,8 @@ int CmdSmartUpgrade(const char *Cmd) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdSmartInfo(const char *Cmd){
|
|
||||||
|
static int CmdSmartInfo(const char *Cmd){
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false, silent = false;
|
bool errors = false, silent = false;
|
||||||
|
|
||||||
|
@ -898,7 +871,8 @@ int CmdSmartReader(const char *Cmd){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdSmartSetClock(const char *Cmd){
|
|
||||||
|
static int CmdSmartSetClock(const char *Cmd){
|
||||||
uint8_t cmdp = 0;
|
uint8_t cmdp = 0;
|
||||||
bool errors = false;
|
bool errors = false;
|
||||||
uint8_t clock = 0;
|
uint8_t clock = 0;
|
||||||
|
@ -953,12 +927,14 @@ int CmdSmartSetClock(const char *Cmd){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdSmartList(const char *Cmd) {
|
|
||||||
|
static int CmdSmartList(const char *Cmd) {
|
||||||
CmdHFList("7816");
|
CmdHFList("7816");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdSmartBruteforceSFI(const char *Cmd) {
|
|
||||||
|
static int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||||
|
|
||||||
char ctmp = tolower(param_getchar(Cmd, 0));
|
char ctmp = tolower(param_getchar(Cmd, 0));
|
||||||
if (ctmp == 'h') return usage_sm_brute();
|
if (ctmp == 'h') return usage_sm_brute();
|
||||||
|
@ -970,16 +946,16 @@ int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Selecting PPSE aid");
|
PrintAndLogEx(INFO, "Selecting PSE aid");
|
||||||
CmdSmartRaw("s 0 t d 00a404000e325041592e5359532e4444463031");
|
CmdSmartRaw("s 0 t d 00a404000e325041592e5359532e4444463031");
|
||||||
CmdSmartRaw("0 t d 00a4040007a000000004101000"); // mastercard
|
CmdSmartRaw("0 t d 00a4040007a000000004101000"); // mastercard
|
||||||
// CmdSmartRaw("0 t d 00a4040007a0000000031010"); // visa
|
// CmdSmartRaw("0 t d 00a4040007a0000000031010"); // visa
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "starting");
|
PrintAndLogEx(INFO, "starting");
|
||||||
|
|
||||||
UsbCommand c = {CMD_SMART_RAW, {SC_RAW, sizeof(data), 0}};
|
int response_len = 0;
|
||||||
uint8_t* buf = malloc(USB_CMD_DATA_SIZE);
|
uint8_t* response = malloc(ISO7816_MAX_FRAME_SIZE);
|
||||||
if ( !buf )
|
if (!response)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
for (uint8_t i=1; i < 4; i++) {
|
for (uint8_t i=1; i < 4; i++) {
|
||||||
|
@ -988,53 +964,47 @@ int CmdSmartBruteforceSFI(const char *Cmd) {
|
||||||
data[2] = p1;
|
data[2] = p1;
|
||||||
data[3] = (i << 3) + 4;
|
data[3] = (i << 3) + 4;
|
||||||
|
|
||||||
memcpy(c.d.asBytes, data, sizeof(data) );
|
smart_transmit(data, sizeof(data), SC_RAW_T0, response, &response_len, ISO7816_MAX_FRAME_SIZE);
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&c);
|
|
||||||
|
|
||||||
smart_response(buf);
|
if ( response[0] == 0x6C ) {
|
||||||
|
data[4] = response[1];
|
||||||
if ( buf[0] == 0x6C ) {
|
smart_transmit(data, sizeof(data), SC_RAW_T0, response, &response_len, ISO7816_MAX_FRAME_SIZE);
|
||||||
data[4] = buf[1];
|
|
||||||
|
|
||||||
memcpy(c.d.asBytes, data, sizeof(data) );
|
|
||||||
clearCommandBuffer();
|
|
||||||
SendCommand(&c);
|
|
||||||
uint8_t len = smart_response(buf);
|
|
||||||
|
|
||||||
// TLV decoder
|
// TLV decoder
|
||||||
if (len > 4)
|
if (response_len > 4)
|
||||||
TLVPrintFromBuffer(buf+1, len-3);
|
TLVPrintFromBuffer(response+1, response_len-3);
|
||||||
|
|
||||||
data[4] = 0;
|
data[4] = 0;
|
||||||
}
|
}
|
||||||
memset(buf, 0x00, USB_CMD_DATA_SIZE);
|
memset(response, 0x00, ISO7816_MAX_FRAME_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
free(buf);
|
free(response);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, 1, "This help"},
|
{"help", CmdHelp, 1, "This help"},
|
||||||
{"select", CmdSmartSelect, 1, "Select the Smartcard Reader to use"},
|
{"select", CmdSmartSelect, 1, "Select the Smartcard Reader to use"},
|
||||||
{"list", CmdSmartList, 0, "List ISO 7816 history"},
|
{"list", CmdSmartList, 1, "List ISO 7816 history"},
|
||||||
{"info", CmdSmartInfo, 0, "Tag information"},
|
{"info", CmdSmartInfo, 1, "Tag information"},
|
||||||
{"reader", CmdSmartReader, 0, "Act like an IS07816 reader"},
|
{"reader", CmdSmartReader, 1, "Act like an IS07816 reader"},
|
||||||
{"raw", CmdSmartRaw, 0, "Send raw hex data to tag"},
|
{"raw", CmdSmartRaw, 1, "Send raw hex data to tag"},
|
||||||
{"upgrade", CmdSmartUpgrade, 0, "Upgrade firmware"},
|
{"upgrade", CmdSmartUpgrade, 0, "Upgrade firmware"},
|
||||||
{"setclock", CmdSmartSetClock, 0, "Set clock speed"},
|
{"setclock", CmdSmartSetClock, 1, "Set clock speed"},
|
||||||
{"brute", CmdSmartBruteforceSFI, 0, "Bruteforce SFI"},
|
{"brute", CmdSmartBruteforceSFI, 1, "Bruteforce SFI"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int CmdSmartcard(const char *Cmd) {
|
int CmdSmartcard(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
CmdsParse(CommandTable, Cmd);
|
CmdsParse(CommandTable, Cmd);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdHelp(const char *Cmd) {
|
|
||||||
|
static int CmdHelp(const char *Cmd) {
|
||||||
CmdsHelp(CommandTable);
|
CmdsHelp(CommandTable);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,12 +15,6 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
extern int CmdSmartcard(const char *Cmd);
|
extern int CmdSmartcard(const char *Cmd);
|
||||||
|
|
||||||
extern int CmdSmartRaw(const char* cmd);
|
|
||||||
extern int CmdSmartUpgrade(const char* cmd);
|
|
||||||
extern int CmdSmartInfo(const char* cmd);
|
|
||||||
extern int CmdSmartReader(const char *Cmd);
|
|
||||||
|
|
||||||
extern int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
extern int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -45,7 +45,7 @@ void ParamLoadDefaults(struct tlvdb *tlvRoot) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVSelect(const char *cmd) {
|
int CmdEMVSelect(const char *cmd) {
|
||||||
uint8_t data[APDU_AID_LEN] = {0};
|
uint8_t data[APDU_DATA_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
|
|
||||||
CLIParserInit("emv select",
|
CLIParserInit("emv select",
|
||||||
|
@ -83,7 +83,7 @@ int CmdEMVSelect(const char *cmd) {
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVSelect(channel, activateField, leaveSignalON, data, datalen, buf, sizeof(buf), &len, &sw, NULL);
|
int res = EMVSelect(channel, activateField, leaveSignalON, data, datalen, buf, sizeof(buf), &len, &sw, NULL);
|
||||||
|
@ -193,7 +193,7 @@ int CmdEMVPPSE(const char *cmd) {
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVSelectPSE(channel, activateField, leaveSignalON, PSENum, buf, sizeof(buf), &len, &sw);
|
int res = EMVSelectPSE(channel, activateField, leaveSignalON, PSENum, buf, sizeof(buf), &len, &sw);
|
||||||
|
@ -212,7 +212,7 @@ int CmdEMVPPSE(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVGPO(const char *cmd) {
|
int CmdEMVGPO(const char *cmd) {
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
|
|
||||||
CLIParserInit("emv gpo",
|
CLIParserInit("emv gpo",
|
||||||
|
@ -295,7 +295,7 @@ int CmdEMVGPO(const char *cmd) {
|
||||||
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
PrintAndLogEx(INFO, "PDOL data[%d]: %s", pdol_data_tlv_data_len, sprint_hex(pdol_data_tlv_data, pdol_data_tlv_data_len));
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVGPO(channel, leaveSignalON, pdol_data_tlv_data, pdol_data_tlv_data_len, buf, sizeof(buf), &len, &sw, tlvRoot);
|
int res = EMVGPO(channel, leaveSignalON, pdol_data_tlv_data, pdol_data_tlv_data_len, buf, sizeof(buf), &len, &sw, tlvRoot);
|
||||||
|
@ -317,7 +317,7 @@ int CmdEMVGPO(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVReadRecord(const char *cmd) {
|
int CmdEMVReadRecord(const char *cmd) {
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
|
|
||||||
CLIParserInit("emv readrec",
|
CLIParserInit("emv readrec",
|
||||||
|
@ -356,7 +356,7 @@ int CmdEMVReadRecord(const char *cmd) {
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVReadRecord(channel, leaveSignalON, data[0], data[1], buf, sizeof(buf), &len, &sw, NULL);
|
int res = EMVReadRecord(channel, leaveSignalON, data[0], data[1], buf, sizeof(buf), &len, &sw, NULL);
|
||||||
|
@ -375,7 +375,7 @@ int CmdEMVReadRecord(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVAC(const char *cmd) {
|
int CmdEMVAC(const char *cmd) {
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
|
|
||||||
CLIParserInit("emv genac",
|
CLIParserInit("emv genac",
|
||||||
|
@ -474,7 +474,7 @@ int CmdEMVAC(const char *cmd) {
|
||||||
PrintAndLogEx(INFO, "CDOL data[%d]: %s", cdol_data_tlv->len, sprint_hex(cdol_data_tlv->value, cdol_data_tlv->len));
|
PrintAndLogEx(INFO, "CDOL data[%d]: %s", cdol_data_tlv->len, sprint_hex(cdol_data_tlv->value, cdol_data_tlv->len));
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVAC(channel, leaveSignalON, termDecision, (uint8_t *)cdol_data_tlv->value, cdol_data_tlv->len, buf, sizeof(buf), &len, &sw, tlvRoot);
|
int res = EMVAC(channel, leaveSignalON, termDecision, (uint8_t *)cdol_data_tlv->value, cdol_data_tlv->len, buf, sizeof(buf), &len, &sw, tlvRoot);
|
||||||
|
@ -524,7 +524,7 @@ int CmdEMVGenerateChallenge(const char *cmd) {
|
||||||
SetAPDULogging(APDULogging);
|
SetAPDULogging(APDULogging);
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVGenerateChallenge(channel, leaveSignalON, buf, sizeof(buf), &len, &sw, NULL);
|
int res = EMVGenerateChallenge(channel, leaveSignalON, buf, sizeof(buf), &len, &sw, NULL);
|
||||||
|
@ -544,7 +544,7 @@ int CmdEMVGenerateChallenge(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVInternalAuthenticate(const char *cmd) {
|
int CmdEMVInternalAuthenticate(const char *cmd) {
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
int datalen = 0;
|
int datalen = 0;
|
||||||
|
|
||||||
CLIParserInit("emv intauth",
|
CLIParserInit("emv intauth",
|
||||||
|
@ -624,7 +624,7 @@ int CmdEMVInternalAuthenticate(const char *cmd) {
|
||||||
PrintAndLogEx(INFO, "DDOL data[%d]: %s", ddol_data_tlv->len, sprint_hex(ddol_data_tlv->value, ddol_data_tlv->len));
|
PrintAndLogEx(INFO, "DDOL data[%d]: %s", ddol_data_tlv->len, sprint_hex(ddol_data_tlv->value, ddol_data_tlv->len));
|
||||||
|
|
||||||
// exec
|
// exec
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res = EMVInternalAuthenticate(channel, leaveSignalON, data, datalen, buf, sizeof(buf), &len, &sw, NULL);
|
int res = EMVInternalAuthenticate(channel, leaveSignalON, data, datalen, buf, sizeof(buf), &len, &sw, NULL);
|
||||||
|
@ -711,10 +711,10 @@ void ProcessGPOResponseFormat1(struct tlvdb *tlvRoot, uint8_t *buf, size_t len,
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVExec(const char *cmd) {
|
int CmdEMVExec(const char *cmd) {
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
uint8_t AID[APDU_AID_LEN] = {0};
|
uint8_t AID[APDU_DATA_LEN] = {0};
|
||||||
size_t AIDlen = 0;
|
size_t AIDlen = 0;
|
||||||
uint8_t ODAiList[4096];
|
uint8_t ODAiList[4096];
|
||||||
size_t ODAiListLen = 0;
|
size_t ODAiListLen = 0;
|
||||||
|
@ -769,6 +769,8 @@ int CmdEMVExec(const char *cmd) {
|
||||||
channel = ECC_CONTACT;
|
channel = ECC_CONTACT;
|
||||||
#endif
|
#endif
|
||||||
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;
|
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;
|
||||||
|
char *PSE_or_PPSE = psenum == 1 ? "PSE" : "PPSE";
|
||||||
|
|
||||||
CLIParserFree();
|
CLIParserFree();
|
||||||
|
|
||||||
SetAPDULogging(showAPDU);
|
SetAPDULogging(showAPDU);
|
||||||
|
@ -780,12 +782,12 @@ int CmdEMVExec(const char *cmd) {
|
||||||
// Application Selection
|
// Application Selection
|
||||||
// https://www.openscdp.org/scripts/tutorial/emv/applicationselection.html
|
// https://www.openscdp.org/scripts/tutorial/emv/applicationselection.html
|
||||||
if (!forceSearch) {
|
if (!forceSearch) {
|
||||||
// PPSE
|
// PPSE / PSE
|
||||||
PrintAndLogEx(NORMAL, "\n* PPSE.");
|
PrintAndLogEx(NORMAL, "\n* %s.", PSE_or_PPSE);
|
||||||
SetAPDULogging(showAPDU);
|
SetAPDULogging(showAPDU);
|
||||||
res = EMVSearchPSE(channel, activateField, true, psenum, decodeTLV, tlvSelect);
|
res = EMVSearchPSE(channel, activateField, true, psenum, decodeTLV, tlvSelect);
|
||||||
|
|
||||||
// check PPSE and select application id
|
// check PPSE / PSE and select application id
|
||||||
if (!res) {
|
if (!res) {
|
||||||
TLVPrintAIDlistFromSelectTLV(tlvSelect);
|
TLVPrintAIDlistFromSelectTLV(tlvSelect);
|
||||||
EMVSelectApplication(tlvSelect, AID, &AIDlen);
|
EMVSelectApplication(tlvSelect, AID, &AIDlen);
|
||||||
|
@ -1152,7 +1154,9 @@ int CmdEMVExec(const char *cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
|
|
||||||
// Destroy TLV's
|
// Destroy TLV's
|
||||||
free(pdol_data_tlv);
|
free(pdol_data_tlv);
|
||||||
|
@ -1164,9 +1168,9 @@ int CmdEMVExec(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVScan(const char *cmd) {
|
int CmdEMVScan(const char *cmd) {
|
||||||
uint8_t AID[APDU_AID_LEN] = {0};
|
uint8_t AID[APDU_DATA_LEN] = {0};
|
||||||
size_t AIDlen = 0;
|
size_t AIDlen = 0;
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res;
|
int res;
|
||||||
|
@ -1260,8 +1264,10 @@ int CmdEMVScan(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// drop field at start
|
// drop field at start
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
|
|
||||||
// iso 14443 select
|
// iso 14443 select
|
||||||
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
|
PrintAndLogEx(NORMAL, "--> GET UID, ATS.");
|
||||||
|
|
||||||
|
@ -1329,7 +1335,9 @@ int CmdEMVScan(const char *cmd) {
|
||||||
|
|
||||||
if (!AIDlen) {
|
if (!AIDlen) {
|
||||||
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1376,7 +1384,9 @@ int CmdEMVScan(const char *cmd) {
|
||||||
if (!pdol_data_tlv){
|
if (!pdol_data_tlv){
|
||||||
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1399,7 +1409,9 @@ int CmdEMVScan(const char *cmd) {
|
||||||
if (res) {
|
if (res) {
|
||||||
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
ProcessGPOResponseFormat1(tlvRoot, buf, len, decodeTLV);
|
ProcessGPOResponseFormat1(tlvRoot, buf, len, decodeTLV);
|
||||||
|
@ -1491,8 +1503,9 @@ int CmdEMVScan(const char *cmd) {
|
||||||
// free tlv object
|
// free tlv object
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
|
|
||||||
// DropField
|
if (channel == ECC_CONTACTLESS) {
|
||||||
DropField();
|
DropField();
|
||||||
|
}
|
||||||
|
|
||||||
res = json_dump_file(root, fname, JSON_INDENT(2));
|
res = json_dump_file(root, fname, JSON_INDENT(2));
|
||||||
if (res) {
|
if (res) {
|
||||||
|
@ -1512,9 +1525,9 @@ int CmdEMVTest(const char *cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int CmdEMVRoca(const char *cmd) {
|
int CmdEMVRoca(const char *cmd) {
|
||||||
uint8_t AID[APDU_AID_LEN] = {0};
|
uint8_t AID[APDU_DATA_LEN] = {0};
|
||||||
size_t AIDlen = 0;
|
size_t AIDlen = 0;
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res;
|
int res;
|
||||||
|
@ -1573,7 +1586,9 @@ int CmdEMVRoca(const char *cmd) {
|
||||||
|
|
||||||
if (!AIDlen) {
|
if (!AIDlen) {
|
||||||
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
PrintAndLogEx(INFO, "Can't select AID. EMV AID not found. Exit...");
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1588,7 +1603,9 @@ int CmdEMVRoca(const char *cmd) {
|
||||||
if (res) {
|
if (res) {
|
||||||
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
|
PrintAndLogEx(ERR, "Can't select AID (%d). Exit...", res);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1600,7 +1617,9 @@ int CmdEMVRoca(const char *cmd) {
|
||||||
if (!pdol_data_tlv){
|
if (!pdol_data_tlv){
|
||||||
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
PrintAndLogEx(ERR, "Can't create PDOL TLV.");
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 6;
|
return 6;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1623,7 +1642,9 @@ int CmdEMVRoca(const char *cmd) {
|
||||||
if (res) {
|
if (res) {
|
||||||
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
PrintAndLogEx(ERR, "GPO error(%d): %4x. Exit...", res, sw);
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
DropField();
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
DropField();
|
||||||
|
}
|
||||||
return 7;
|
return 7;
|
||||||
}
|
}
|
||||||
ProcessGPOResponseFormat1(tlvRoot, buf, len, false);
|
ProcessGPOResponseFormat1(tlvRoot, buf, len, false);
|
||||||
|
@ -1721,9 +1742,9 @@ out:
|
||||||
// free tlv object
|
// free tlv object
|
||||||
tlvdb_free(tlvRoot);
|
tlvdb_free(tlvRoot);
|
||||||
|
|
||||||
if ( channel == ECC_CONTACTLESS)
|
if (channel == ECC_CONTACTLESS) {
|
||||||
DropField();
|
DropField();
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1732,18 +1753,18 @@ int CmdHelp(const char *Cmd);
|
||||||
|
|
||||||
static command_t CommandTable[] = {
|
static command_t CommandTable[] = {
|
||||||
{"help", CmdHelp, 1, "This help"},
|
{"help", CmdHelp, 1, "This help"},
|
||||||
{"exec", CmdEMVExec, 0, "Executes EMV contactless transaction."},
|
{"exec", CmdEMVExec, 1, "Executes EMV contactless transaction."},
|
||||||
{"pse", CmdEMVPPSE, 0, "Execute PPSE. It selects 2PAY.SYS.DDF01 or 1PAY.SYS.DDF01 directory."},
|
{"pse", CmdEMVPPSE, 1, "Execute PPSE. It selects 2PAY.SYS.DDF01 or 1PAY.SYS.DDF01 directory."},
|
||||||
{"search", CmdEMVSearch, 0, "Try to select all applets from applets list and print installed applets."},
|
{"search", CmdEMVSearch, 1, "Try to select all applets from applets list and print installed applets."},
|
||||||
{"select", CmdEMVSelect, 0, "Select applet."},
|
{"select", CmdEMVSelect, 1, "Select applet."},
|
||||||
{"gpo", CmdEMVGPO, 0, "Execute GetProcessingOptions."},
|
{"gpo", CmdEMVGPO, 1, "Execute GetProcessingOptions."},
|
||||||
{"readrec", CmdEMVReadRecord, 0, "Read files from card."},
|
{"readrec", CmdEMVReadRecord, 1, "Read files from card."},
|
||||||
{"genac", CmdEMVAC, 0, "Generate ApplicationCryptogram."},
|
{"genac", CmdEMVAC, 1, "Generate ApplicationCryptogram."},
|
||||||
{"challenge", CmdEMVGenerateChallenge, 0, "Generate challenge."},
|
{"challenge", CmdEMVGenerateChallenge, 1, "Generate challenge."},
|
||||||
{"intauth", CmdEMVInternalAuthenticate, 0, "Internal authentication."},
|
{"intauth", CmdEMVInternalAuthenticate, 1, "Internal authentication."},
|
||||||
{"scan", CmdEMVScan, 0, "Scan EMV card and save it contents to json file for emulator."},
|
{"scan", CmdEMVScan, 1, "Scan EMV card and save it contents to json file for emulator."},
|
||||||
{"test", CmdEMVTest, 0, "Crypto logic test."},
|
{"test", CmdEMVTest, 1, "Crypto logic test."},
|
||||||
{"roca", CmdEMVRoca, 0, "Extract public keys and run ROCA test"},
|
{"roca", CmdEMVRoca, 1, "Extract public keys and run ROCA test"},
|
||||||
{NULL, NULL, 0, NULL}
|
{NULL, NULL, 0, NULL}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "emvcore.h"
|
#include "emvcore.h"
|
||||||
#include "emvjson.h"
|
#include "emvjson.h"
|
||||||
#include "util_posix.h"
|
#include "util_posix.h"
|
||||||
|
#include "protocols.h"
|
||||||
#ifdef WITH_SMARTCARD
|
#ifdef WITH_SMARTCARD
|
||||||
#include "cmdsmartcard.h"
|
#include "cmdsmartcard.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -235,44 +236,39 @@ struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2) {
|
||||||
return tlvdb_fixed(0x02, dCVVlen, dCVV);
|
return tlvdb_fixed(0x02, dCVVlen, dCVV);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, sAPDU apdu, bool IncludeLe, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
|
||||||
|
|
||||||
|
static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t *apdu, int apdu_len, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
|
{
|
||||||
*ResultLen = 0;
|
*ResultLen = 0;
|
||||||
if (sw) *sw = 0;
|
if (sw) *sw = 0;
|
||||||
uint16_t isw = 0;
|
uint16_t isw = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
|
||||||
if (ActivateField) {
|
if (ActivateField && channel == ECC_CONTACTLESS) {
|
||||||
DropField();
|
DropField();
|
||||||
msleep(50);
|
msleep(50);
|
||||||
}
|
}
|
||||||
|
|
||||||
// COMPUTE APDU
|
|
||||||
memcpy(data, &apdu, 5);
|
|
||||||
if (apdu.data)
|
|
||||||
memcpy(&data[5], apdu.data, apdu.Lc);
|
|
||||||
|
|
||||||
if (APDULogging)
|
if (APDULogging)
|
||||||
PrintAndLogEx(SUCCESS, ">>>> %s", sprint_hex(data, (IncludeLe?6:5) + apdu.Lc));
|
PrintAndLogEx(SUCCESS, ">>>> %s", sprint_hex(apdu, apdu_len));
|
||||||
|
|
||||||
switch(channel) {
|
switch(channel) {
|
||||||
case ECC_CONTACTLESS:
|
case ECC_CONTACTLESS:
|
||||||
// 6 byes + data = INS + CLA + P1 + P2 + Lc + <data = Nc> + Le(?IncludeLe)
|
// 6 byes + data = INS + CLA + P1 + P2 + Lc + <data = Nc> + Le(?IncludeLe)
|
||||||
res = ExchangeAPDU14a(data, (IncludeLe?6:5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
res = ExchangeAPDU14a(apdu, apdu_len, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||||
if (res) {
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ECC_CONTACT:
|
case ECC_CONTACT:
|
||||||
//int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
//int ExchangeAPDUSC(uint8_t *datain, int datainlen, bool activateCard, bool leaveSignalON, uint8_t *dataout, int maxdataoutlen, int *dataoutlen);
|
||||||
#ifdef WITH_SMARTCARD
|
#ifdef WITH_SMARTCARD
|
||||||
res = ExchangeAPDUSC(data, (IncludeLe?6:5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
res = ExchangeAPDUSC(apdu, apdu_len, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
|
||||||
if (res) {
|
if (res) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (APDULogging)
|
if (APDULogging)
|
||||||
|
@ -282,6 +278,12 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
|
||||||
return 200;
|
return 200;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Result[*ResultLen-2] == 0x61) {
|
||||||
|
uint8_t La = Result[*ResultLen-1];
|
||||||
|
uint8_t get_response[5] = {apdu[0], ISO7816_GET_RESPONSE, 0x00, 0x00, La};
|
||||||
|
return EMVExchangeEx(channel, false, LeaveFieldON, get_response, sizeof(get_response), Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
|
}
|
||||||
|
|
||||||
*ResultLen -= 2;
|
*ResultLen -= 2;
|
||||||
isw = Result[*ResultLen] * 0x0100 + Result[*ResultLen + 1];
|
isw = Result[*ResultLen] * 0x0100 + Result[*ResultLen + 1];
|
||||||
if (sw)
|
if (sw)
|
||||||
|
@ -289,12 +291,8 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
|
||||||
|
|
||||||
if (isw != 0x9000) {
|
if (isw != 0x9000) {
|
||||||
if (APDULogging) {
|
if (APDULogging) {
|
||||||
if (*sw >> 8 == 0x61) {
|
PrintAndLogEx(ERR, "APDU(%02x%02x) ERROR: [%4X] %s", apdu[0], apdu[1], isw, GetAPDUCodeDescription(*sw >> 8, *sw & 0xff));
|
||||||
PrintAndLogEx(ERR, "APDU chaining len:%02x -->", *sw & 0xff);
|
return 5;
|
||||||
} else {
|
|
||||||
PrintAndLogEx(ERR, "APDU(%02x%02x) ERROR: [%4X] %s", apdu.CLA, apdu.INS, isw, GetAPDUCodeDescription(*sw >> 8, *sw & 0xff));
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -307,16 +305,36 @@ int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool LeaveField
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVExchange(EMVCommandChannel channel, bool LeaveFieldON, sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVExchange(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *apdu, int apdu_len, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchangeEx(channel, false, LeaveFieldON, apdu, (channel == ECC_CONTACTLESS), Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t APDU[APDU_COMMAND_LEN];
|
||||||
|
memcpy(APDU, apdu, apdu_len);
|
||||||
|
APDU[apdu_len] = 0x00;
|
||||||
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
if (apdu_len == 5 && apdu[4] == 0) {
|
||||||
|
// there is no Lc but an Le == 0 already
|
||||||
|
} else if (apdu_len > 5 && apdu_len == 5 + apdu[4] + 1) {
|
||||||
|
// there is Lc, data and Le
|
||||||
|
} else {
|
||||||
|
apdu_len++; // no Le, add Le = 0x00 because some vendors require it for contactless
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return EMVExchangeEx(channel, false, LeaveFieldON, APDU, apdu_len, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVSelect(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t *AID, size_t AIDLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVSelect(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t *AID, size_t AIDLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchangeEx(channel, ActivateField, LeaveFieldON, (sAPDU){0x00, 0xa4, 0x04, 0x00, AIDLen, AID}, (channel == ECC_CONTACTLESS), Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t Select_APDU[APDU_COMMAND_LEN] = {0x00, ISO7816_SELECT_FILE, 0x04, 0x00, AIDLen, 0x00};
|
||||||
|
memcpy(Select_APDU + 5, AID, AIDLen);
|
||||||
|
int apdulen = 5 + AIDLen;
|
||||||
|
if (channel == ECC_CONTACTLESS) {
|
||||||
|
apdulen++; // some vendors require Le = 0x00 for contactless operations
|
||||||
|
}
|
||||||
|
return EMVExchangeEx(channel, ActivateField, LeaveFieldON, Select_APDU, apdulen, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVSelectPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int EMVSelectPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
||||||
uint8_t buf[APDU_AID_LEN] = {0};
|
uint8_t buf[APDU_DATA_LEN] = {0};
|
||||||
*ResultLen = 0;
|
*ResultLen = 0;
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
@ -325,6 +343,7 @@ int EMVSelectPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||||
param_gethex_to_eol(PSElist[1], 0, buf, sizeof(buf), &len);
|
param_gethex_to_eol(PSElist[1], 0, buf, sizeof(buf), &len);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
|
|
||||||
param_gethex_to_eol(PSElist[0], 0, buf, sizeof(buf), &len);
|
param_gethex_to_eol(PSElist[0], 0, buf, sizeof(buf), &len);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -338,11 +357,13 @@ int EMVSelectPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, bool decodeTLV, struct tlvdb *tlv) {
|
int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, bool decodeTLV, struct tlvdb *tlv) {
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t datalen = 0;
|
size_t datalen = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
char *PSE_or_PPSE = PSENum == 1 ? "PSE" : "PPSE";
|
||||||
|
|
||||||
// select PPSE
|
// select PPSE
|
||||||
res = EMVSelectPSE(channel, ActivateField, true, PSENum, data, sizeof(data), &datalen, &sw);
|
res = EMVSelectPSE(channel, ActivateField, true, PSENum, data, sizeof(data), &datalen, &sw);
|
||||||
|
|
||||||
|
@ -353,7 +374,7 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||||
int retrycnt = 0;
|
int retrycnt = 0;
|
||||||
struct tlvdb *ttmp = tlvdb_find_path(t, (tlv_tag_t[]){0x6f, 0xa5, 0xbf0c, 0x61, 0x00});
|
struct tlvdb *ttmp = tlvdb_find_path(t, (tlv_tag_t[]){0x6f, 0xa5, 0xbf0c, 0x61, 0x00});
|
||||||
if (!ttmp)
|
if (!ttmp)
|
||||||
PrintAndLogEx(FAILED, "PPSE don't have records.");
|
PrintAndLogEx(FAILED, "%s doesn't have any records.", PSE_or_PPSE);
|
||||||
|
|
||||||
while (ttmp) {
|
while (ttmp) {
|
||||||
const struct tlv *tgAID = tlvdb_get_inchild(ttmp, 0x4f, NULL);
|
const struct tlv *tgAID = tlvdb_get_inchild(ttmp, 0x4f, NULL);
|
||||||
|
@ -393,22 +414,22 @@ int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldO
|
||||||
|
|
||||||
tlvdb_free(t);
|
tlvdb_free(t);
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "PPSE ERROR: Can't get TLV from response.");
|
PrintAndLogEx(WARNING, "%s ERROR: Can't get TLV from response.", PSE_or_PPSE);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
PrintAndLogEx(WARNING, "PPSE ERROR: Can't select PPSE AID. Error: %d", res);
|
PrintAndLogEx(WARNING, "%s ERROR: Can't select PPSE AID. Error: %d", PSE_or_PPSE, res);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!LeaveFieldON)
|
if(!LeaveFieldON && channel == ECC_CONTACTLESS)
|
||||||
DropField();
|
DropField();
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv) {
|
int EMVSearch(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, bool decodeTLV, struct tlvdb *tlv) {
|
||||||
uint8_t aidbuf[APDU_AID_LEN] = {0};
|
uint8_t aidbuf[APDU_DATA_LEN] = {0};
|
||||||
int aidlen = 0;
|
int aidlen = 0;
|
||||||
uint8_t data[APDU_RES_LEN] = {0};
|
uint8_t data[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t datalen = 0;
|
size_t datalen = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
|
|
||||||
|
@ -489,38 +510,63 @@ int EMVSelectApplication(struct tlvdb *tlv, uint8_t *AID, size_t *AIDlen) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVGPO(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *PDOL, size_t PDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVGPO(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *PDOL, size_t PDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchange(channel, LeaveFieldON, (sAPDU){0x80, 0xa8, 0x00, 0x00, PDOLLen, PDOL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t GPO_APDU[APDU_COMMAND_LEN] = {0x80, 0xa8, 0x00, 0x00, PDOLLen, 0x00};
|
||||||
|
memcpy(GPO_APDU + 5, PDOL, PDOLLen);
|
||||||
|
int apdulen = 5 + PDOLLen;
|
||||||
|
|
||||||
|
return EMVExchange(channel, LeaveFieldON, GPO_APDU, apdulen, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVReadRecord(EMVCommandChannel channel, bool LeaveFieldON, uint8_t SFI, uint8_t SFIrec, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVReadRecord(EMVCommandChannel channel, bool LeaveFieldON, uint8_t SFI, uint8_t SFIrec, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
int res = EMVExchange(channel, LeaveFieldON, (sAPDU){0x00, 0xb2, SFIrec, (SFI << 3) | 0x04, 0, NULL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t read_APDU[5] = {0x00, ISO7816_READ_RECORDS, SFIrec, (SFI << 3) | 0x04, 0x00};
|
||||||
|
int res = EMVExchange(channel, LeaveFieldON, read_APDU, sizeof(read_APDU), Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
if (*sw == 0x6700) {
|
if (*sw == 0x6700) {
|
||||||
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
||||||
res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU){0x00, 0xb2, SFIrec, (SFI << 3) | 0x04, 0, NULL}, false, Result, MaxResultLen, ResultLen, sw, tlv);
|
res = EMVExchangeEx(channel, false, LeaveFieldON, read_APDU, sizeof(read_APDU), Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVAC(EMVCommandChannel channel, bool LeaveFieldON, uint8_t RefControl, uint8_t *CDOL, size_t CDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVAC(EMVCommandChannel channel, bool LeaveFieldON, uint8_t RefControl, uint8_t *CDOL, size_t CDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchange(channel, LeaveFieldON, (sAPDU){0x80, 0xae, RefControl, 0x00, CDOLLen, CDOL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t CDOL_APDU[APDU_COMMAND_LEN] = {0x80, 0xae, RefControl, 0x00, CDOLLen, 0x00};
|
||||||
|
memcpy(CDOL_APDU + 5, CDOL, CDOLLen);
|
||||||
|
int apdulen = 5 + CDOLLen;
|
||||||
|
|
||||||
|
return EMVExchange(channel, LeaveFieldON, CDOL_APDU, apdulen, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVGenerateChallenge(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVGenerateChallenge(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
int res = EMVExchange(channel, LeaveFieldON, (sAPDU){0x00, 0x84, 0x00, 0x00, 0x00, NULL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t get_challenge_APDU[APDU_COMMAND_LEN] = {0x00, ISO7816_GET_CHALLENGE, 0x00, 0x00};
|
||||||
|
|
||||||
|
int res = EMVExchange(channel, LeaveFieldON, get_challenge_APDU, 4, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
if (*sw == 0x6700) {
|
if (*sw == 0x6700) {
|
||||||
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
PrintAndLogEx(INFO, ">>> trying to reissue command withouth Le...");
|
||||||
res = EMVExchangeEx(channel, false, LeaveFieldON, (sAPDU){0x00, 0x84, 0x00, 0x00, 0x00, NULL}, false, Result, MaxResultLen, ResultLen, sw, tlv);
|
res = EMVExchangeEx(channel, false, LeaveFieldON, get_challenge_APDU, 4, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int EMVInternalAuthenticate(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *DDOL, size_t DDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int EMVInternalAuthenticate(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *DDOL, size_t DDOLLen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchange(channel, LeaveFieldON, (sAPDU){0x00, 0x88, 0x00, 0x00, DDOLLen, DDOL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t authenticate_APDU[APDU_COMMAND_LEN] = {0x00, ISO7816_INTERNAL_AUTHENTICATION, 0x00, 0x00, DDOLLen, 0x00};
|
||||||
|
memcpy(authenticate_APDU + 5, DDOL, DDOLLen);
|
||||||
|
int apdulen = 5 + DDOLLen;
|
||||||
|
|
||||||
|
return EMVExchange(channel, LeaveFieldON, authenticate_APDU, apdulen, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
int MSCComputeCryptoChecksum(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *UDOL, uint8_t UDOLlen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv) {
|
int MSCComputeCryptoChecksum(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *UDOL, uint8_t UDOLlen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv)
|
||||||
return EMVExchange(channel, LeaveFieldON, (sAPDU){0x80, 0x2a, 0x8e, 0x80, UDOLlen, UDOL}, Result, MaxResultLen, ResultLen, sw, tlv);
|
{
|
||||||
|
uint8_t checksum_APDU[APDU_COMMAND_LEN] = {0x80, 0x2a, 0x8e, 0x80, UDOLlen, 0x00};
|
||||||
|
memcpy(checksum_APDU + 5, UDOL, UDOLlen);
|
||||||
|
int apdulen = 5 + UDOLlen;
|
||||||
|
|
||||||
|
return EMVExchange(channel, LeaveFieldON, checksum_APDU, apdulen, Result, MaxResultLen, ResultLen, sw, tlv);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Authentication
|
// Authentication
|
||||||
|
@ -591,7 +637,7 @@ static const unsigned char default_ddol_value[] = {0x9f, 0x37, 0x04};
|
||||||
static struct tlv default_ddol_tlv = {.tag = 0x9f49, .len = 3, .value = default_ddol_value };
|
static struct tlv default_ddol_tlv = {.tag = 0x9f49, .len = 3, .value = default_ddol_value };
|
||||||
|
|
||||||
int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
int trDDA(EMVCommandChannel channel, bool decodeTLV, struct tlvdb *tlv) {
|
||||||
uint8_t buf[APDU_RES_LEN] = {0};
|
uint8_t buf[APDU_RESPONSE_LEN] = {0};
|
||||||
size_t len = 0;
|
size_t len = 0;
|
||||||
uint16_t sw = 0;
|
uint16_t sw = 0;
|
||||||
|
|
||||||
|
|
|
@ -29,8 +29,10 @@
|
||||||
#include "emv_pk.h"
|
#include "emv_pk.h"
|
||||||
#include "emv_pki.h"
|
#include "emv_pki.h"
|
||||||
|
|
||||||
#define APDU_RES_LEN 260
|
// maximum APDU lengths. Long APDUs not yet supported/needed
|
||||||
#define APDU_AID_LEN 50
|
#define APDU_DATA_LEN 255
|
||||||
|
#define APDU_COMMAND_LEN (4 + 1 + APDU_DATA_LEN + 1)
|
||||||
|
#define APDU_RESPONSE_LEN (256 + 2)
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ECC_CONTACTLESS,
|
ECC_CONTACTLESS,
|
||||||
|
@ -45,15 +47,6 @@ enum TransactionType {
|
||||||
};
|
};
|
||||||
extern char *TransactionTypeStr[];
|
extern char *TransactionTypeStr[];
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
uint8_t CLA;
|
|
||||||
uint8_t INS;
|
|
||||||
uint8_t P1;
|
|
||||||
uint8_t P2;
|
|
||||||
uint8_t Lc;
|
|
||||||
uint8_t *data;
|
|
||||||
} sAPDU;
|
|
||||||
|
|
||||||
enum CardPSVendor {
|
enum CardPSVendor {
|
||||||
CV_NA,
|
CV_NA,
|
||||||
CV_VISA,
|
CV_VISA,
|
||||||
|
@ -76,7 +69,7 @@ extern struct tlvdb *GetdCVVRawFromTrack2(const struct tlv *track2);
|
||||||
extern void SetAPDULogging(bool logging);
|
extern void SetAPDULogging(bool logging);
|
||||||
|
|
||||||
// exchange
|
// exchange
|
||||||
extern int EMVExchange(EMVCommandChannel channel, bool LeaveFieldON, sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
|
extern int EMVExchange(EMVCommandChannel channel, bool LeaveFieldON, uint8_t *APDU, int APDU_len, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw, struct tlvdb *tlv);
|
||||||
|
|
||||||
// search application
|
// search application
|
||||||
extern int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, bool decodeTLV, struct tlvdb *tlv);
|
extern int EMVSearchPSE(EMVCommandChannel channel, bool ActivateField, bool LeaveFieldON, uint8_t PSENum, bool decodeTLV, struct tlvdb *tlv);
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "crypto/libpcrypto.h"
|
#include "crypto/libpcrypto.h"
|
||||||
#include "fido/additional_ca.h"
|
#include "fido/additional_ca.h"
|
||||||
#include "fido/cose.h"
|
#include "fido/cose.h"
|
||||||
|
#include "protocols.h"
|
||||||
|
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t ErrorCode;
|
uint8_t ErrorCode;
|
||||||
|
@ -173,14 +175,16 @@ int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t Ma
|
||||||
return EMVSelect(ECC_CONTACTLESS, ActivateField, LeaveFieldON, data, sizeof(data), Result, MaxResultLen, ResultLen, sw, NULL);
|
return EMVSelect(ECC_CONTACTLESS, ActivateField, LeaveFieldON, data, sizeof(data), Result, MaxResultLen, ResultLen, sw, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDOExchange(sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDOExchange(uint8_t* apdu, int apdulen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
||||||
int res = EMVExchange(ECC_CONTACTLESS, true, apdu, Result, MaxResultLen, ResultLen, sw, NULL);
|
int res = EMVExchange(ECC_CONTACTLESS, true, apdu, apdulen, Result, MaxResultLen, ResultLen, sw, NULL);
|
||||||
if (res == 5) // apdu result (sw) not a 0x9000
|
if (res == 5) // apdu result (sw) not a 0x9000
|
||||||
res = 0;
|
res = 0;
|
||||||
// software chaining
|
// software chaining
|
||||||
while (!res && (*sw >> 8) == 0x61) {
|
while (!res && (*sw >> 8) == 0x61) {
|
||||||
|
uint8_t La = *sw & 0xff;
|
||||||
|
uint8_t get_response_APDU[5] = {apdu[0], ISO7816_GET_RESPONSE, 0x00, 0x00, La};
|
||||||
size_t oldlen = *ResultLen;
|
size_t oldlen = *ResultLen;
|
||||||
res = EMVExchange(ECC_CONTACTLESS, true, (sAPDU){0x00, 0xC0, 0x00, 0x00, 0x00, NULL}, &Result[oldlen], MaxResultLen - oldlen, ResultLen, sw, NULL);
|
res = EMVExchange(ECC_CONTACTLESS, true, get_response_APDU, sizeof(get_response_APDU), &Result[oldlen], MaxResultLen - oldlen, ResultLen, sw, NULL);
|
||||||
if (res == 5) // apdu result (sw) not a 0x9000
|
if (res == 5) // apdu result (sw) not a 0x9000
|
||||||
res = 0;
|
res = 0;
|
||||||
|
|
||||||
|
@ -191,31 +195,41 @@ int FIDOExchange(sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *Resul
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw)
|
||||||
return FIDOExchange((sAPDU){0x00, 0x01, 0x03, 0x00, 64, params}, Result, MaxResultLen, ResultLen, sw);
|
{
|
||||||
|
uint8_t APDU[4 + 64] = {0x00, 0x01, 0x03, 0x00, 64, 0x00};
|
||||||
|
memcpy(APDU, params, 64);
|
||||||
|
return FIDOExchange(APDU, 4 + 64, Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw)
|
||||||
return FIDOExchange((sAPDU){0x00, 0x02, controlb, 0x00, paramslen, params}, Result, MaxResultLen, ResultLen, sw);
|
{
|
||||||
|
uint8_t APDU[APDU_COMMAND_LEN] = {0x00, 0x02, controlb, 0x00, paramslen, 0x00};
|
||||||
|
memcpy(APDU+5, params, paramslen);
|
||||||
|
int apdu_len = 5 + paramslen;
|
||||||
|
return FIDOExchange(APDU, apdu_len, Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw)
|
||||||
uint8_t data[] = {fido2CmdGetInfo};
|
{
|
||||||
return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw);
|
uint8_t APDU[5] = {0x80, 0x10, 0x00, 0x00, fido2CmdGetInfo};
|
||||||
|
return FIDOExchange(APDU, sizeof(APDU), Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDO2MakeCredential(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDO2MakeCredential(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw)
|
||||||
uint8_t data[paramslen + 1];
|
{
|
||||||
data[0] = fido2CmdMakeCredential;
|
uint8_t APDU[APDU_COMMAND_LEN] = {0x80, 0x10, 0x00, 0x00, paramslen + 1, fido2CmdMakeCredential, 0x00};
|
||||||
memcpy(&data[1], params, paramslen);
|
memcpy(APDU+6, params, paramslen);
|
||||||
return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw);
|
int apdu_len = 5 + paramslen + 1;
|
||||||
|
return FIDOExchange(APDU, apdu_len, Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDO2GetAssertion(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw) {
|
int FIDO2GetAssertion(uint8_t *params, uint8_t paramslen, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw)
|
||||||
uint8_t data[paramslen + 1];
|
{
|
||||||
data[0] = fido2CmdGetAssertion;
|
uint8_t APDU[APDU_COMMAND_LEN] = {0x80, 0x10, 0x00, 0x00, paramslen + 1, fido2CmdGetAssertion, 0x00};
|
||||||
memcpy(&data[1], params, paramslen);
|
memcpy(APDU+6, params, paramslen);
|
||||||
return FIDOExchange((sAPDU){0x80, 0x10, 0x00, 0x00, sizeof(data), data}, Result, MaxResultLen, ResultLen, sw);
|
int apdu_len = 5 + paramslen + 1;
|
||||||
|
return FIDOExchange(APDU, apdu_len, Result, MaxResultLen, ResultLen, sw);
|
||||||
}
|
}
|
||||||
|
|
||||||
int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *publicKey, size_t publicKeyMaxLen) {
|
int FIDOCheckDERAndGetKey(uint8_t *der, size_t derLen, bool verbose, uint8_t *publicKey, size_t publicKeyMaxLen) {
|
||||||
|
|
|
@ -37,7 +37,7 @@ typedef enum {
|
||||||
} fido2PacketType;
|
} fido2PacketType;
|
||||||
|
|
||||||
extern int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
extern int FIDOSelect(bool ActivateField, bool LeaveFieldON, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||||
extern int FIDOExchange(sAPDU apdu, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
extern int FIDOExchange(uint8_t *APDU, int APDU_len, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||||
extern int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
extern int FIDORegister(uint8_t *params, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||||
extern int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
extern int FIDOAuthentication(uint8_t *params, uint8_t paramslen, uint8_t controlb, uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||||
extern int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
extern int FIDO2GetInfo(uint8_t *Result, size_t MaxResultLen, size_t *ResultLen, uint16_t *sw);
|
||||||
|
|
|
@ -175,3 +175,41 @@ bool pcscGetATR(smart_card_atr_t *card)
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void pcscTransmit(uint8_t *data, uint32_t data_len, uint32_t flags, uint8_t *response, int *response_len)
|
||||||
|
{
|
||||||
|
LPCSCARD_IO_REQUEST protocol;
|
||||||
|
if (flags & SC_RAW_T0) {
|
||||||
|
protocol = SCARD_PCI_T0;
|
||||||
|
} else {
|
||||||
|
protocol = SCARD_PCI_RAW;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: tracing
|
||||||
|
// if ((flags & SC_CONNECT))
|
||||||
|
// clear_trace();
|
||||||
|
|
||||||
|
// set_tracing(true);
|
||||||
|
|
||||||
|
if ((flags & SC_CONNECT || flags & SC_SELECT)) {
|
||||||
|
LONG res = SCardConnect(SC_Context, AlternativeSmartcardReader, SCARD_SHARE_SHARED,
|
||||||
|
SCARD_PROTOCOL_T0 | SCARD_PROTOCOL_T1, &SC_Card, &SC_Protocol);
|
||||||
|
if (res != SCARD_S_SUCCESS) {
|
||||||
|
*response_len = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((flags & SC_RAW) || (flags & SC_RAW_T0)) {
|
||||||
|
// TODO: tracing
|
||||||
|
// LogTrace(data, arg1, 0, 0, NULL, true);
|
||||||
|
DWORD len = *response_len;
|
||||||
|
LONG res = SCardTransmit(SC_Card, protocol, data, data_len, NULL, response, &len);
|
||||||
|
if (res != SCARD_S_SUCCESS) {
|
||||||
|
*response_len = -1;
|
||||||
|
} else {
|
||||||
|
*response_len = len;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -18,5 +18,6 @@ char *getAlternativeSmartcardReader(void);
|
||||||
bool pcscCheckForCardReaders(void);
|
bool pcscCheckForCardReaders(void);
|
||||||
bool pcscSelectAlternativeCardReader(const char *readername);
|
bool pcscSelectAlternativeCardReader(const char *readername);
|
||||||
bool pcscGetATR(smart_card_atr_t *card);
|
bool pcscGetATR(smart_card_atr_t *card);
|
||||||
|
void pcscTransmit(uint8_t *data, uint32_t data_len, uint32_t flags, uint8_t *response, int *response_len);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include "cmdhw.h"
|
#include "cmdhw.h"
|
||||||
#include "whereami.h"
|
#include "whereami.h"
|
||||||
#include "comms.h"
|
#include "comms.h"
|
||||||
#include "pcsc.h"
|
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
@ -262,12 +262,13 @@ NXP/Philips CUSTOM COMMANDS
|
||||||
#define ISO7816_VERIFY 0x20
|
#define ISO7816_VERIFY 0x20
|
||||||
#define ISO7816_INTERNAL_AUTHENTICATION 0x88
|
#define ISO7816_INTERNAL_AUTHENTICATION 0x88
|
||||||
#define ISO7816_EXTERNAL_AUTHENTICATION 0x82
|
#define ISO7816_EXTERNAL_AUTHENTICATION 0x82
|
||||||
#define ISO7816_GET_CHALLENGE 0xB4
|
#define ISO7816_GET_CHALLENGE 0x84
|
||||||
#define ISO7816_MANAGE_CHANNEL 0x70
|
#define ISO7816_MANAGE_CHANNEL 0x70
|
||||||
#define ISO7816_GETSTATUS 0xC0
|
#define ISO7816_GET_RESPONSE 0xC0
|
||||||
// ISO7816-4 For response APDU's
|
// ISO7816-4 For response APDU's
|
||||||
#define ISO7816_OK 0x9000
|
#define ISO7816_OK 0x9000
|
||||||
// 6x xx = ERROR
|
// 6x xx = ERROR
|
||||||
|
#define ISO7816_MAX_FRAME_SIZE 261
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue