Skip to content

Commit

Permalink
not allow to write block 0
Browse files Browse the repository at this point in the history
  • Loading branch information
willok committed Jun 22, 2020
1 parent a83b6fe commit 4ac7154
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions Firmware/Chameleon-Mini/Application/MifareClassic.c
Original file line number Diff line number Diff line change
Expand Up @@ -1020,12 +1020,20 @@ uint16_t MifareClassicAppProcess(uint8_t *Buffer, uint16_t BitCount) {
}
} else if (Buffer[0] == CMD_WRITE) {
if (ISO14443ACheckCRCA(Buffer, CMD_WRITE_FRAME_SIZE)) {
DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2);
/* Write command. Store the address and prepare for the upcoming data.
* Respond with ACK. */
CurrentAddress = Buffer[1];
State = STATE_WRITE;
Buffer[0] = ACK_VALUE ^ Crypto1Nibble();
// not allow to write block 0
if (Buffer[1] == 0x00) {
State = STATE_HALT;
Buffer[0] = NAK_NOT_AUTHED ^ Crypto1Nibble();
return ACK_NAK_FRAME_SIZE;
}
else {
DetectionLogToFlash(LOG_INFO_APP_CMD_WRITE, Buffer, 2);
/* Write command. Store the address and prepare for the upcoming data.
* Respond with ACK. */
CurrentAddress = Buffer[1];
State = STATE_WRITE;
Buffer[0] = ACK_VALUE ^ Crypto1Nibble();
}
} else {
LogEntry(LOG_ERR_APP_CHECKSUM_FAIL, Buffer, 4);
Buffer[0] = NAK_CRC_ERROR ^ Crypto1Nibble();
Expand Down

0 comments on commit 4ac7154

Please sign in to comment.