mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
Make smartcard support detection dynamic
This commit is contained in:
parent
f33d0bf206
commit
b723126deb
4 changed files with 35 additions and 20 deletions
|
@ -441,15 +441,20 @@ void SendCapabilities(void) {
|
||||||
|
|
||||||
#ifdef WITH_FLASH
|
#ifdef WITH_FLASH
|
||||||
capabilities.compiled_with_flash = true;
|
capabilities.compiled_with_flash = true;
|
||||||
|
// TODO
|
||||||
|
capabilities.hw_available_flash = true;
|
||||||
#else
|
#else
|
||||||
capabilities.compiled_with_flash = false;
|
capabilities.compiled_with_flash = false;
|
||||||
|
capabilities.hw_available_flash = false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_SMARTCARD
|
#ifdef WITH_SMARTCARD
|
||||||
capabilities.compiled_with_smartcard = true;
|
capabilities.compiled_with_smartcard = true;
|
||||||
|
uint8_t maj, min;
|
||||||
|
capabilities.hw_available_smartcard = I2C_get_version(&maj, &min) == PM3_SUCCESS;
|
||||||
#else
|
#else
|
||||||
capabilities.compiled_with_smartcard = false;
|
capabilities.compiled_with_smartcard = false;
|
||||||
|
capabilities.hw_available_smartcard = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WITH_FPC
|
#ifdef WITH_FPC
|
||||||
capabilities.compiled_with_fpc = true;
|
capabilities.compiled_with_fpc = true;
|
||||||
#else
|
#else
|
||||||
|
@ -457,8 +462,11 @@ void SendCapabilities(void) {
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_FPC_HOST
|
#ifdef WITH_FPC_HOST
|
||||||
capabilities.compiled_with_fpc_host = true;
|
capabilities.compiled_with_fpc_host = true;
|
||||||
|
// TODO
|
||||||
|
capabilities.hw_available_fpc_host = true;
|
||||||
#else
|
#else
|
||||||
capabilities.compiled_with_fpc_host = false;
|
capabilities.compiled_with_fpc_host = false;
|
||||||
|
capabilities.hw_available_fpc_host = false;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_LF
|
#ifdef WITH_LF
|
||||||
capabilities.compiled_with_lf = true;
|
capabilities.compiled_with_lf = true;
|
||||||
|
@ -510,12 +518,6 @@ void SendCapabilities(void) {
|
||||||
#else
|
#else
|
||||||
capabilities.compiled_with_lcd = false;
|
capabilities.compiled_with_lcd = false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// TODO
|
|
||||||
// capabilities.hw_available_flash
|
|
||||||
// capabilities.hw_available_smartcard
|
|
||||||
// capabilities.hw_available_fpc_host
|
|
||||||
|
|
||||||
reply_ng(CMD_CAPABILITIES, PM3_SUCCESS, (uint8_t *)&capabilities, sizeof(capabilities));
|
reply_ng(CMD_CAPABILITIES, PM3_SUCCESS, (uint8_t *)&capabilities, sizeof(capabilities));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,17 +30,17 @@ bool IfPm3Present(void) {
|
||||||
bool IfPm3Flash(void) {
|
bool IfPm3Flash(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
// TODO
|
if (!pm3_capabilities.compiled_with_flash)
|
||||||
// capabilities.hw_available_flash
|
return false;
|
||||||
return pm3_capabilities.compiled_with_flash;
|
return pm3_capabilities.hw_available_flash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Smartcard(void) {
|
bool IfPm3Smartcard(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
// TODO
|
if (!pm3_capabilities.compiled_with_smartcard)
|
||||||
// capabilities.hw_available_smartcard
|
return false;
|
||||||
return pm3_capabilities.compiled_with_smartcard;
|
return pm3_capabilities.hw_available_smartcard;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Fpc(void) {
|
bool IfPm3Fpc(void) {
|
||||||
|
@ -52,9 +52,9 @@ bool IfPm3Fpc(void) {
|
||||||
bool IfPm3FpcHost(void) {
|
bool IfPm3FpcHost(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
// TODO
|
if (!pm3_capabilities.compiled_with_fpc_host)
|
||||||
// capabilities.hw_available_fpc_host
|
return false;
|
||||||
return pm3_capabilities.compiled_with_fpc_host;
|
return pm3_capabilities.hw_available_fpc_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Lf(void) {
|
bool IfPm3Lf(void) {
|
||||||
|
|
20
common/i2c.c
20
common/i2c.c
|
@ -594,13 +594,25 @@ bool I2C_WriteFW(uint8_t *data, uint8_t len, uint8_t msb, uint8_t lsb, uint8_t d
|
||||||
|
|
||||||
void I2C_print_status(void) {
|
void I2C_print_status(void) {
|
||||||
DbpString(_BLUE_("Smart card module (ISO 7816)"));
|
DbpString(_BLUE_("Smart card module (ISO 7816)"));
|
||||||
|
uint8_t maj, min;
|
||||||
|
if (I2C_get_version(&maj, &min) == PM3_SUCCESS)
|
||||||
|
Dbprintf(" version.................v%x.%02d", maj, min);
|
||||||
|
else
|
||||||
|
DbpString(" version................." _RED_("FAILED"));
|
||||||
|
}
|
||||||
|
|
||||||
|
int I2C_get_version(uint8_t *maj, uint8_t *min) {
|
||||||
uint8_t resp[] = {0, 0, 0, 0};
|
uint8_t resp[] = {0, 0, 0, 0};
|
||||||
I2C_Reset_EnterMainProgram();
|
I2C_Reset_EnterMainProgram();
|
||||||
uint8_t len = I2C_BufferRead(resp, sizeof(resp), I2C_DEVICE_CMD_GETVERSION, I2C_DEVICE_ADDRESS_MAIN);
|
uint8_t len = I2C_BufferRead(resp, sizeof(resp), I2C_DEVICE_CMD_GETVERSION, I2C_DEVICE_ADDRESS_MAIN);
|
||||||
if (len > 0)
|
if (len > 0) {
|
||||||
Dbprintf(" version.................v%x.%02d", resp[0], resp[1]);
|
Dbprintf(" version.................v%x.%02d", maj, min);
|
||||||
else
|
*maj = resp[0];
|
||||||
DbpString(" version................." _RED_("FAILED"));
|
*min = resp[1];
|
||||||
|
return PM3_SUCCESS;
|
||||||
|
} else {
|
||||||
|
return PM3_EDEVNOTSUPP;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will read response from smart card module, retries 3 times to get the data.
|
// Will read response from smart card module, retries 3 times to get the data.
|
||||||
|
|
|
@ -47,4 +47,5 @@ void SmartCardUpgrade(uint64_t arg0);
|
||||||
void SmartCardSetBaud(uint64_t arg0);
|
void SmartCardSetBaud(uint64_t arg0);
|
||||||
void SmartCardSetClock(uint64_t arg0);
|
void SmartCardSetClock(uint64_t arg0);
|
||||||
void I2C_print_status(void);
|
void I2C_print_status(void);
|
||||||
|
int I2C_get_version(uint8_t *maj, uint8_t *min);
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue