mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 05:13:46 -07:00
fix smart card
This commit is contained in:
parent
e9b55acd00
commit
bc48941951
2 changed files with 15 additions and 15 deletions
15
armsrc/i2c.c
15
armsrc/i2c.c
|
@ -181,7 +181,7 @@ static bool WaitSCL_L(void) {
|
||||||
// It timeout reading response from card
|
// It timeout reading response from card
|
||||||
// Which ever comes first
|
// Which ever comes first
|
||||||
static bool WaitSCL_L_timeout(void) {
|
static bool WaitSCL_L_timeout(void) {
|
||||||
volatile uint32_t delay = 18000;
|
volatile uint32_t delay = 1800;
|
||||||
while (delay--) {
|
while (delay--) {
|
||||||
// exit on SCL LOW
|
// exit on SCL LOW
|
||||||
if (!SCL_read)
|
if (!SCL_read)
|
||||||
|
@ -219,7 +219,7 @@ static bool I2C_WaitForSim(void) {
|
||||||
// 8051 speaks with smart card.
|
// 8051 speaks with smart card.
|
||||||
// 1000*50*3.07 = 153.5ms
|
// 1000*50*3.07 = 153.5ms
|
||||||
// 1byte transfer == 1ms with max frame being 256bytes
|
// 1byte transfer == 1ms with max frame being 256bytes
|
||||||
if (!WaitSCL_H_delay(30 * 1000 * 50))
|
if (!WaitSCL_H_delay(20 * 1000 * 50))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -634,6 +634,9 @@ bool sc_rx_bytes(uint8_t *dest, uint8_t *destlen) {
|
||||||
|
|
||||||
len = I2C_BufferRead(dest, *destlen, I2C_DEVICE_CMD_READ, I2C_DEVICE_ADDRESS_MAIN);
|
len = I2C_BufferRead(dest, *destlen, I2C_DEVICE_CMD_READ, I2C_DEVICE_ADDRESS_MAIN);
|
||||||
|
|
||||||
|
|
||||||
|
LED_C_ON();
|
||||||
|
|
||||||
if (len > 1) {
|
if (len > 1) {
|
||||||
break;
|
break;
|
||||||
} else if (len == 1) {
|
} else if (len == 1) {
|
||||||
|
@ -667,7 +670,7 @@ bool GetATR(smart_card_atr_t *card_ptr, bool verbose) {
|
||||||
// 1byte = 1ms , max frame 256bytes. Should wait 256ms atleast just in case.
|
// 1byte = 1ms , max frame 256bytes. Should wait 256ms atleast just in case.
|
||||||
if (I2C_WaitForSim() == false)
|
if (I2C_WaitForSim() == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// read bytes from module
|
// read bytes from module
|
||||||
uint8_t len = sizeof(card_ptr->atr);
|
uint8_t len = sizeof(card_ptr->atr);
|
||||||
if (sc_rx_bytes(card_ptr->atr, &len) == false)
|
if (sc_rx_bytes(card_ptr->atr, &len) == false)
|
||||||
|
@ -706,12 +709,12 @@ bool GetATR(smart_card_atr_t *card_ptr, bool verbose) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SmartCardAtr(void) {
|
void SmartCardAtr(void) {
|
||||||
smart_card_atr_t card;
|
|
||||||
LED_D_ON();
|
LED_D_ON();
|
||||||
set_tracing(true);
|
set_tracing(true);
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
bool isOK = GetATR(&card, true);
|
smart_card_atr_t card;
|
||||||
reply_mix(CMD_ACK, isOK, sizeof(smart_card_atr_t), 0, &card, sizeof(smart_card_atr_t));
|
int res = GetATR(&card, true) ? PM3_SUCCESS : PM3_ETIMEOUT;
|
||||||
|
reply_ng(CMD_SMART_ATR, res, (uint8_t*)&card, sizeof(smart_card_atr_t));
|
||||||
set_tracing(false);
|
set_tracing(false);
|
||||||
LEDsoff();
|
LEDsoff();
|
||||||
}
|
}
|
||||||
|
|
|
@ -698,13 +698,12 @@ static int CmdSmartInfo(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
if (!WaitForResponseTimeout(CMD_SMART_ATR, &resp, 2500)) {
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
if (resp.status != PM3_SUCCESS) {
|
||||||
if (!isok) {
|
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -771,13 +770,12 @@ static int CmdSmartReader(const char *Cmd) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
if (!WaitForResponseTimeout(CMD_SMART_ATR, &resp, 2500)) {
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
if (resp.status != PM3_SUCCESS) {
|
||||||
if (!isok) {
|
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -1186,14 +1184,13 @@ bool smart_select(bool silent, smart_card_atr_t *atr) {
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
SendCommandNG(CMD_SMART_ATR, NULL, 0);
|
||||||
PacketResponseNG resp;
|
PacketResponseNG resp;
|
||||||
if (!WaitForResponseTimeout(CMD_ACK, &resp, 2500)) {
|
if (!WaitForResponseTimeout(CMD_SMART_ATR, &resp, 2500)) {
|
||||||
|
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t isok = resp.oldarg[0] & 0xFF;
|
if (resp.status != PM3_SUCCESS) {
|
||||||
if (!isok) {
|
|
||||||
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
if (!silent) PrintAndLogEx(WARNING, "smart card select failed");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue