Replace WITH_SMARTCARD by dynamic detection in client

This commit is contained in:
Philippe Teuwen 2019-05-01 22:33:27 +02:00
commit 6b2677c154
2 changed files with 19 additions and 23 deletions

View file

@ -809,13 +809,12 @@ static int CmdEMVExec(const char *Cmd) {
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2; uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;
CLIParserFree(); CLIParserFree();
#ifndef WITH_SMARTCARD if (!IfPm3Smartcard()) {
// not compiled with smartcard functionality, we need to exit if (channel == ECC_CONTACT) {
if (channel == ECC_CONTACT) { PrintAndLogEx(WARNING, "PM3 does not have SMARTCARD support. Exiting.");
PrintAndLogEx(WARNING, "PM3 Client is not compiled with support for SMARTCARD. Exiting."); return PM3_EDEVNOTSUPP;
return PM3_EDEVNOTSUPP; }
} }
#endif
SetAPDULogging(showAPDU); SetAPDULogging(showAPDU);
@ -1400,13 +1399,12 @@ static int CmdEMVScan(const char *Cmd) {
CLIGetStrWithReturn(12, relfname, &relfnamelen); CLIGetStrWithReturn(12, relfname, &relfnamelen);
CLIParserFree(); CLIParserFree();
#ifndef WITH_SMARTCARD if (!IfPm3Smartcard()) {
// not compiled with smartcard functionality, we need to exit if (channel == ECC_CONTACT) {
if (channel == ECC_CONTACT) { PrintAndLogEx(WARNING, "PM3 does not have SMARTCARD support. Exiting.");
PrintAndLogEx(ERR, "PM3 Client is not compiled with support for SMARTCARD. Exiting."); return PM3_EDEVNOTSUPP;
return PM3_EDEVNOTSUPP; }
} }
#endif
SetAPDULogging(showAPDU); SetAPDULogging(showAPDU);
@ -1736,13 +1734,12 @@ static int CmdEMVRoca(const char *Cmd) {
PrintChannel(channel); PrintChannel(channel);
CLIParserFree(); CLIParserFree();
#ifndef WITH_SMARTCARD if (!IfPm3Smartcard()) {
// not compiled with smartcard functionality, we need to exit if (channel == ECC_CONTACT) {
if (channel == ECC_CONTACT) { PrintAndLogEx(WARNING, "PM3 does not have SMARTCARD support. Exiting.");
PrintAndLogEx(WARNING, "PM3 Client is not compiled with support for SMARTCARD. Exiting."); return PM3_EDEVNOTSUPP;
return PM3_EDEVNOTSUPP; }
} }
#endif
// select card // select card
uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2; uint8_t psenum = (channel == ECC_CONTACT) ? 1 : 2;

View file

@ -293,11 +293,10 @@ static int EMVExchangeEx(EMVCommandChannel channel, bool ActivateField, bool Lea
} }
break; break;
case ECC_CONTACT: case ECC_CONTACT:
#ifdef WITH_SMARTCARD if (IfPm3Smartcard())
res = ExchangeAPDUSC(data, (IncludeLe ? 6 : 5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen); res = ExchangeAPDUSC(data, (IncludeLe ? 6 : 5) + apdu.Lc, ActivateField, LeaveFieldON, Result, (int)MaxResultLen, (int *)ResultLen);
#else else
res = 1; res = 1;
#endif
if (res) { if (res) {
return res; return res;
} }