Updating nfc-mfclassic.c
Modifying behavior relating to magic cards. If a user has a 'magic2' card (IE, direct-write, not a 'fully magic' card) - we'll warn them that they don't need to use the W / R modes, and then proceed with the unlock operation, instead of exiting.
This commit is contained in:
parent
48c271e49d
commit
87c6053d6f
1 changed files with 22 additions and 11 deletions
|
@ -233,11 +233,6 @@ authenticate(uint32_t uiBlock)
|
||||||
static bool
|
static bool
|
||||||
unlock_card(void)
|
unlock_card(void)
|
||||||
{
|
{
|
||||||
if (magic2) {
|
|
||||||
printf("Don't use R/W with this card, this is not required!\n");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Configure the CRC
|
// Configure the CRC
|
||||||
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
if (nfc_device_set_property_bool(pnd, NP_HANDLE_CRC, false) < 0) {
|
||||||
nfc_perror(pnd, "nfc_configure");
|
nfc_perror(pnd, "nfc_configure");
|
||||||
|
@ -314,9 +309,17 @@ read_card(int read_unlocked)
|
||||||
bool bFailure = false;
|
bool bFailure = false;
|
||||||
uint32_t uiReadBlocks = 0;
|
uint32_t uiReadBlocks = 0;
|
||||||
|
|
||||||
if (read_unlocked)
|
if (read_unlocke) {
|
||||||
if (!unlock_card())
|
//If the user is attempting an unlocked read, but has a direct-write type magic card, they don't
|
||||||
|
//need to use the R mode. We'll trigger a warning and let them proceed.
|
||||||
|
if (magic2) {
|
||||||
|
printf("Note: This card does not require an unlocked write (R) \n");
|
||||||
|
} else {
|
||||||
|
//If User has requested an unlocked read, but we're unable to unlock the card, we'll error out.
|
||||||
|
if (!unlock_card()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("Reading out %d blocks |", uiBlocks + 1);
|
printf("Reading out %d blocks |", uiBlocks + 1);
|
||||||
// Read the card from end to begin
|
// Read the card from end to begin
|
||||||
|
@ -384,9 +387,17 @@ write_card(int write_block_zero)
|
||||||
bool bFailure = false;
|
bool bFailure = false;
|
||||||
uint32_t uiWriteBlocks = 0;
|
uint32_t uiWriteBlocks = 0;
|
||||||
|
|
||||||
if (write_block_zero)
|
if (write_block_zero) {
|
||||||
if (!unlock_card())
|
//If the user is attempting an unlocked write, but has a direct-write type magic card, they don't
|
||||||
|
//need to use the W mode. We'll trigger a warning and let them proceed.
|
||||||
|
if (magic2) {
|
||||||
|
printf("Note: This card does not require an unlocked write (W) \n");
|
||||||
|
} else {
|
||||||
|
//If User has requested an unlocked write, but we're unable to unlock the card, we'll error out.
|
||||||
|
if (!unlock_card()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
printf("Writing %d blocks |", uiBlocks + 1);
|
printf("Writing %d blocks |", uiBlocks + 1);
|
||||||
// Write the card from begin to end;
|
// Write the card from begin to end;
|
||||||
|
|
Loading…
Reference in a new issue