Skip to content

Commit

Permalink
Merge pull request #107 from McEloff/fix_4k_tags
Browse files Browse the repository at this point in the history
Mifare Classic 4K tag size fix
  • Loading branch information
iceman1001 authored Jul 30, 2019
2 parents 18f763a + 04e3ee2 commit 0b5cc0a
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Firmware/Chameleon-Mini/Application/MifareClassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,8 +592,15 @@ uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount)
}
} else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B)) {
if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) {
uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK;
uint8_t SectorAddress;
uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET);
/* Fix for MFClassic 4k cards */
if(Buffer[1] >= 128) {
SectorAddress = Buffer[1] & MEM_BIGSECTOR_ADDR_MASK;
KeyOffset += MEM_KEY_BIGSECTOR_OFFSET;
} else {
SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK;
}
uint16_t KeyAddress = (uint16_t) SectorAddress * MEM_BYTES_PER_BLOCK + KeyOffset;
uint8_t Key[6];
uint8_t Uid[4];
Expand Down Expand Up @@ -757,8 +764,15 @@ uint16_t MifareClassicAppProcess(uint8_t* Buffer, uint16_t BitCount)
} else if ( (Buffer[0] == CMD_AUTH_A) || (Buffer[0] == CMD_AUTH_B) ) {
if (ISO14443ACheckCRCA(Buffer, CMD_AUTH_FRAME_SIZE)) {
/* Nested authentication. */
uint8_t SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK;
uint8_t SectorAddress;
uint8_t KeyOffset = (Buffer[0] == CMD_AUTH_A ? MEM_KEY_A_OFFSET : MEM_KEY_B_OFFSET);
/* Fix for MFClassic 4k cards */
if(Buffer[1] >= 128) {
SectorAddress = Buffer[1] & MEM_BIGSECTOR_ADDR_MASK;
KeyOffset += MEM_KEY_BIGSECTOR_OFFSET;
} else {
SectorAddress = Buffer[1] & MEM_SECTOR_ADDR_MASK;
}
uint16_t KeyAddress = (uint16_t) SectorAddress * MEM_BYTES_PER_BLOCK + KeyOffset;
uint8_t Key[6];
uint8_t Uid[4];
Expand Down

0 comments on commit 0b5cc0a

Please sign in to comment.