fix #2790 - MFU OTP writes shouldnt allow for zeroing. Bad sanity check implemented, it should check that every bit doesnt try to zero out. Will do for now

This commit is contained in:
iceman1001 2025-03-19 08:56:00 +01:00
commit af93383115
2 changed files with 13 additions and 0 deletions

View file

@ -3,6 +3,7 @@ All notable changes to this project will be documented in this file.
This project uses the changelog in accordance with [keepchangelog](http://keepachangelog.com/). Please use this to write notable changes, which is not the same as git commit log...
## [unreleased][unreleased]
- Change `hf mfu sim` deny OTP changes with all zeros (@iceman1001)
- Added missing file in CMakeLists.txt (@iceman1001)
- Major update to `lf em 4x70` internals on ARM side; Enabling improved debugging and reliability (@henrygab)
- Improved `pcf7931` generic readability of the code. Unified datatypes and added documentation/explainations (@tinooo)

View file

@ -1730,6 +1730,18 @@ void SimulateIso14443aTag(uint8_t tagType, uint16_t flags, uint8_t *useruid, uin
if (CheckCrc14A(receivedCmd, len)) {
uint8_t block = receivedCmd[1];
// OTP sanity check
// Quite a bad one, one should look at all individual bits and see if anyone tries be set as zero
// we cheat and do fat 00000000 check instead
if (block == 0x03) {
if (memcmp(receivedCmd + 2, "\x00\x00\x00\x00", 4) == 0) {
// OTP can't be set back to zero
// send NACK 0x0 == invalid argument,
EmSend4bit(CARD_NACK_IV);
}
}
if (block > pages) {
// send NACK 0x0 == invalid argument
EmSend4bit(CARD_NACK_IV);