Skip to content
This repository has been archived by the owner on Mar 18, 2023. It is now read-only.

Commit

Permalink
Fix the issue with the UID0 byte of a random UID needing to be 0x08 n…
Browse files Browse the repository at this point in the history
…oted in the emsec#302 discussion
  • Loading branch information
maxieds committed Jan 16, 2022
1 parent 344238b commit f6b7037
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,6 @@ uint16_t ISO144433APiccProcess(uint8_t* Buffer, uint16_t BitCount) {
Uid[2] = Uid[1];
Uid[1] = Uid[0];
Uid[0] = ISO14443A_UID0_CT;
//Uid[0] = ISO14443A_UID0_RANDOM;
}
if (ISO14443ASelectDesfire(Buffer, &BitCount, Uid, SAK_CL1_VALUE)) {
/* CL1 stage has ended successfully */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,10 @@ void FactoryFormatPiccEV0(void) {
BYTE uidData[DESFIRE_UID_SIZE];
RandomGetBuffer(uidData, DESFIRE_UID_SIZE);
memcpy(&Picc.Uid[0], uidData, DESFIRE_UID_SIZE);
/* Conform to NXP Application Note AN10927 about the first
* byte of a randomly generated UID (refer to section 2.1.1).
*/
Picc.Uid[0] = ISO14443A_UID0_RANDOM;
/* Initialize params to look like EV0 */
Picc.StorageSize = DESFIRE_STORAGE_SIZE_4K;
Picc.HwVersionMajor = DESFIRE_HW_MAJOR_EV0;
Expand Down
1 change: 0 additions & 1 deletion Firmware/Chameleon-Mini/Application/MifareDESFire.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ uint16_t MifareDesfireAppProcess(uint8_t* Buffer, uint16_t BitCount) {
if(ByteCount >= 8 && DesfireCLA(Buffer[0]) && Buffer[2] == 0x00 &&
Buffer[3] == 0x00 && Buffer[4] == ByteCount - 8) {
return MifareDesfireProcess(Buffer, BitCount);

}
else if(ByteCount >= 6 && DesfireCLA(Buffer[0]) && Buffer[2] == 0x00 &&
Buffer[3] == 0x00 && Buffer[4] == ByteCount - 6) {
Expand Down
4 changes: 2 additions & 2 deletions Firmware/Chameleon-Mini/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ SETTINGS += -DDESFIRE_MEMORY_LIMITED_TESTING
#Set a minimum incoming/outgoing log size so we do not spam the
#Chameleon Mini logs to much by logging everything:
SETTINGS += -DDESFIRE_MIN_INCOMING_LOGSIZE=1
#SETTINGS += -DDESFIRE_MIN_OUTGOING_LOGSIZE=1
SETTINGS += -DDESFIRE_MIN_OUTGOING_LOGSIZE=0
SETTINGS += -DDESFIRE_MIN_OUTGOING_LOGSIZE=1
#SETTINGS += -DDESFIRE_MIN_OUTGOING_LOGSIZE=0

#Enable printing of crypto tests when a new DESFire emulation instance is started:
#SETTINGS += -DDESFIRE_RUN_CRYPTO_TESTING_PROCEDURE
Expand Down

0 comments on commit f6b7037

Please sign in to comment.