Skip to content

Commit

Permalink
Updates to LibNFC test code (ISO auth works) ; Untested changes to fw…
Browse files Browse the repository at this point in the history
… source to support recall of header data from EEPROM on power cycle (need to test) ; Other misc minor modifications to stash as a restore point
  • Loading branch information
maxieds committed Jul 17, 2022
1 parent 1c2cf3a commit e7790dc
Show file tree
Hide file tree
Showing 20 changed files with 196 additions and 145 deletions.
2 changes: 1 addition & 1 deletion Firmware/Chameleon-Mini/Application/CryptoTDEA.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ PCD's side.
extern uint8_t __CryptoDESOpMode;

/* Key sizes, in bytes */
#define CRYPTO_DES_KEY_SIZE 8 /* Bytes */
#define CRYPTO_DES_KEY_SIZE (8) /* Bytes */
#define CRYPTO_2KTDEA_KEY_SIZE (CRYPTO_DES_KEY_SIZE * 2)
#define CRYPTO_3KTDEA_KEY_SIZE (CRYPTO_DES_KEY_SIZE * 3)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ This notice must be retained at the top of all source files where indicated.
#include "../../Terminal/Terminal.h"
#include "../../Terminal/Commands.h"
#include "../../Settings.h"
#include "../../Memory.h"
#include "DESFireChameleonTerminal.h"
#include "DESFireFirmwareSettings.h"
#include "DESFirePICCControl.h"
#include "DESFireMemoryOperations.h"
#include "DESFireLogging.h"

bool IsDESFireConfiguration(void) {
Expand Down Expand Up @@ -111,7 +111,7 @@ CommandStatusIdType CommandDESFireSetHeaderProperty(char *OutParam, const char *
return COMMAND_ERR_INVALID_USAGE_ID;
}
SynchronizePICCInfo();
MemoryStore();
MemoryStoreDesfireHeaderBytes();
return COMMAND_INFO_OK_ID;
}
#endif /* DISABLE_PERMISSIVE_DESFIRE_SETTINGS */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ This notice must be retained at the top of all source files where indicated.

#define DESFIRE_FIRMWARE_BUILD_TIMESTAMP PSTR(BUILD_DATE)
#define DESFIRE_FIRMWARE_GIT_COMMIT_ID PSTR(COMMIT_ID)
#define DESFIRE_FIRMWARE_REVISION PSTR("1.0.0-testing")
#define DESFIRE_FIRMWARE_PICC_LAYOUT_REVISION (0x03)
#define DESFIRE_FIRMWARE_REVISION PSTR("1.0.1-beta")
#define DESFIRE_FIRMWARE_PICC_LAYOUT_REVISION (0x04)

#define DESFIRE_LITTLE_ENDIAN (1)

Expand All @@ -64,15 +64,17 @@ typedef uint32_t UINT;
#define IsFalse(rcond) (rcond == FALSE)

/* Allow users to modify typically reserved and protected read-only data on the tag
like the manufacturer bytes and the serial number (set in Makefile)? */
* like the manufacturer bytes and the serial number (set in Makefile):
*/
#ifdef ENABLE_PERMISSIVE_DESFIRE_SETTINGS
#define DESFIRE_ALLOW_PROTECTED_MODIFY (1)
#else
#define DESFIRE_ALLOW_PROTECTED_MODIFY (0)
#endif

/* Whether to auto select application ID and file before the user (input system)
even invokes an ISO SELECT APPLICATION [0x00 0xa4 0x04] command? */
* even invokes an ISO SELECT APPLICATION [0x00 0xa4 0x04] command:
*/
#define DESFIRE_LEGACY_SUPPORT (0)

#endif
77 changes: 50 additions & 27 deletions Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,10 +441,13 @@ uint16_t DesfireCmdFreeMemory(uint8_t *Buffer, uint16_t ByteCount) {
uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
BYTE KeyId;
BYTE keySize;
BYTE *Key;
BYTE *Key, *IV;
BYTE CryptoChallengeResponseBytesSize;

/* Reset authentication state right away */
InvalidateAuthState(SelectedApp.Slot == DESFIRE_PICC_APP_SLOT);
if (!Authenticated || !AuthenticatedWithPICCMasterKey) {
InvalidateAuthState(SelectedApp.Slot == DESFIRE_PICC_APP_SLOT);
}
/* Validate command length */
if (ByteCount != 2) {
Buffer[0] = STATUS_LENGTH_ERROR;
Expand All @@ -466,9 +469,11 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
/* Indicate that we are in DES key authentication land */
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_2KTDEA);
Key = SessionKey;
IV = SessionIV;
DesfireCommandState.KeyId = KeyId;
DesfireCommandState.CryptoMethodType = CRYPTO_TYPE_3K3DES;
DesfireCommandState.ActiveCommMode = GetCryptoMethodCommSettings(CRYPTO_TYPE_3K3DES);
DesfireCommandState.CryptoMethodType = CRYPTO_TYPE_DES;
DesfireCommandState.ActiveCommMode = GetCryptoMethodCommSettings(CRYPTO_TYPE_DES);
CryptoChallengeResponseBytesSize = CRYPTO_DES_BLOCK_SIZE;

/* Fetch the key */
if (cryptoKeyType == CRYPTO_TYPE_DES) {
Expand All @@ -480,7 +485,7 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
DesfireLogEntry(LOG_APP_AUTH_KEY, (const void *) Key, keySize);

/* Generate the nonce B (RndB / Challenge response) */
if (DesfireDebuggingOn) {
if (!DesfireDebuggingOn) {
RandomGetBuffer(DesfireCommandState.RndB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
} else {
/* Fixed nonce for testing */
Expand All @@ -504,8 +509,10 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
DesfireLogEntry(LOG_APP_NONCE_B, DesfireCommandState.RndB, CRYPTO_CHALLENGE_RESPONSE_BYTES);

/* Encrypt RndB with the selected key and transfer it back to the PCD */
Encrypt2K3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, DesfireCommandState.RndB,
&Buffer[1], NULL, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
EncryptDESBuffer(CryptoChallengeResponseBytesSize, DesfireCommandState.RndB,
&Buffer[1], IV, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);

/* Scrub the key */
memset(Key, 0, keySize);
Expand All @@ -519,13 +526,14 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) {
uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {
BYTE KeyId;
BYTE cryptoKeyType, keySize;
BYTE *Key;
BYTE *Key, *IV;
BYTE CryptoChallengeResponseBytesSize;

/* Set status for the next incoming command on error */
DesfireState = DESFIRE_IDLE;

/* Validate command length */
if (ByteCount != 2 * CRYPTO_CHALLENGE_RESPONSE_BYTES + 1) {
if (ByteCount != 2 * CryptoChallengeResponseBytesSize + 1) {
Buffer[0] = STATUS_LENGTH_ERROR;
return DESFIRE_STATUS_RESPONSE_SIZE;
}
Expand All @@ -535,6 +543,7 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {
cryptoKeyType = DesfireCommandState.CryptoMethodType;
keySize = GetDefaultCryptoMethodKeySize(CRYPTO_TYPE_3K3DES);
Key = SessionKey;
IV = SessionIV;
if (cryptoKeyType == CRYPTO_TYPE_DES) {
ReadAppKey(SelectedApp.Slot, KeyId, Key, CRYPTO_DES_KEY_SIZE);
memcpy(Key + CRYPTO_DES_KEY_SIZE, Key, CRYPTO_DES_KEY_SIZE);
Expand All @@ -543,28 +552,33 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {
}

/* Decrypt the challenge sent back to get RndA and a shifted RndB */
BYTE challengeRndAB[2 * CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndA[CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndB[CRYPTO_CHALLENGE_RESPONSE_BYTES];
Decrypt2K3DESBuffer(2 * CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);
RotateArrayLeft(challengeRndAB + CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndB,
CRYPTO_CHALLENGE_RESPONSE_BYTES);
memcpy(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
CryptoChallengeResponseBytesSize = CRYPTO_DES_BLOCK_SIZE;
BYTE challengeRndAB[2 * CryptoChallengeResponseBytesSize];
BYTE challengeRndA[CryptoChallengeResponseBytesSize];
BYTE challengeRndB[CryptoChallengeResponseBytesSize];
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
DecryptDESBuffer(2 * CryptoChallengeResponseBytesSize, challengeRndAB,
&Buffer[1], IV, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
RotateArrayLeft(challengeRndAB + CryptoChallengeResponseBytesSize, challengeRndB,
CryptoChallengeResponseBytesSize);
memcpy(challengeRndA, challengeRndAB, CryptoChallengeResponseBytesSize);

/* Check that the returned RndB matches what we sent in the previous round */
if (memcmp(DesfireCommandState.RndB, challengeRndB, CRYPTO_CHALLENGE_RESPONSE_BYTES)) {
if (memcmp(DesfireCommandState.RndB, challengeRndB, CryptoChallengeResponseBytesSize)) {
Buffer[0] = STATUS_AUTHENTICATION_ERROR;
return DESFIRE_STATUS_RESPONSE_SIZE;
}

/* Encrypt and send back the once rotated RndA buffer to the PCD */
RotateArrayRight(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
Encrypt2K3DESBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB,
&Buffer[1], NULL, Key);
RotateArrayRight(challengeRndA, challengeRndAB, CryptoChallengeResponseBytesSize);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
EncryptDESBuffer(CryptoChallengeResponseBytesSize, challengeRndAB,
&Buffer[1], IV, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);

/* Create the session key based on the previous exchange */
generateSessionKey(SessionKey, challengeRndA, challengeRndB, CRYPTO_TYPE_2KTDEA);
generateSessionKey(SessionKey, challengeRndA, challengeRndB, CRYPTO_TYPE_DES);

/* Now that we have auth'ed with the legacy command, a ChangeKey command will
* allow for subsequent authentication with the ISO or AES routines
Expand All @@ -576,7 +590,7 @@ uint16_t EV0CmdAuthenticateLegacy2(uint8_t *Buffer, uint16_t ByteCount) {

/* Return the status on success */
Buffer[0] = STATUS_OPERATION_OK;
return DESFIRE_STATUS_RESPONSE_SIZE + CRYPTO_CHALLENGE_RESPONSE_BYTES;
return DESFIRE_STATUS_RESPONSE_SIZE + CryptoChallengeResponseBytesSize;
}

uint16_t EV0CmdChangeKey(uint8_t *Buffer, uint16_t ByteCount) {
Expand Down Expand Up @@ -1785,7 +1799,7 @@ uint16_t DesfireCmdAuthenticate3KTDEA1(uint8_t *Buffer, uint16_t ByteCount) {
} else {
Encrypt2K3DESBuffer(CryptoChallengeResponseBytesSize, DesfireCommandState.RndB, &Buffer[1], IV, Key);
}
DesfireLogEntry(LOG_INFO_DESFIRE_STATUS_INFO, (void *) IV, CryptoChallengeResponseBytesSize);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);

/* Scrub the key */
memset(Key, 0, keySize);
Expand Down Expand Up @@ -1835,6 +1849,7 @@ uint16_t DesfireCmdAuthenticate3KTDEA2(uint8_t *Buffer, uint16_t ByteCount) {
BYTE challengeRndAB[2 * CryptoChallengeResponseBytesSize];
BYTE challengeRndA[CryptoChallengeResponseBytesSize];
BYTE challengeRndB[CryptoChallengeResponseBytesSize];
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
if (cryptoKeyType == CRYPTO_TYPE_DES || cryptoKeyType == CRYPTO_TYPE_3K3DES ||
cryptoKeyType == CRYPTO_TYPE_ANY) {
Decrypt3DESBuffer(2 * CryptoChallengeResponseBytesSize, challengeRndAB,
Expand All @@ -1843,7 +1858,7 @@ uint16_t DesfireCmdAuthenticate3KTDEA2(uint8_t *Buffer, uint16_t ByteCount) {
Decrypt2K3DESBuffer(2 * CryptoChallengeResponseBytesSize, challengeRndAB,
&Buffer[1], IV, Key);
}
DesfireLogEntry(LOG_INFO_DESFIRE_STATUS_INFO, (void *) IV, CryptoChallengeResponseBytesSize);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
RotateArrayLeft(challengeRndAB + CryptoChallengeResponseBytesSize, challengeRndB,
CryptoChallengeResponseBytesSize);
memcpy(challengeRndA, challengeRndAB, CryptoChallengeResponseBytesSize);
Expand All @@ -1857,6 +1872,7 @@ uint16_t DesfireCmdAuthenticate3KTDEA2(uint8_t *Buffer, uint16_t ByteCount) {

/* Encrypt and send back the once rotated RndA buffer to the PCD */
RotateArrayRight(challengeRndA, challengeRndAB, CryptoChallengeResponseBytesSize);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);
if (cryptoKeyType == CRYPTO_TYPE_DES || cryptoKeyType == CRYPTO_TYPE_3K3DES ||
cryptoKeyType == CRYPTO_TYPE_ANY) {
Encrypt3DESBuffer(CryptoChallengeResponseBytesSize, challengeRndAB,
Expand All @@ -1865,7 +1881,7 @@ uint16_t DesfireCmdAuthenticate3KTDEA2(uint8_t *Buffer, uint16_t ByteCount) {
Encrypt2K3DESBuffer(CryptoChallengeResponseBytesSize, challengeRndAB,
&Buffer[1], IV, Key);
}
DesfireLogEntry(LOG_INFO_DESFIRE_STATUS_INFO, (void *) IV, CryptoChallengeResponseBytesSize);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IV, CryptoChallengeResponseBytesSize);

/* Create the session key based on the previous exchange */
generateSessionKey(SessionKey, challengeRndA, challengeRndB, cryptoKeyType);
Expand Down Expand Up @@ -1944,7 +1960,7 @@ uint16_t DesfireCmdAuthenticateAES1(uint8_t *Buffer, uint16_t ByteCount) {
CryptoAESInitContext(&AESCryptoContext);

/* Generate the nonce B (RndB / Challenge response) */
if (DesfireDebuggingOn) {
if (!DesfireDebuggingOn) {
RandomGetBuffer(&(DesfireCommandState.RndB[0]), CRYPTO_CHALLENGE_RESPONSE_BYTES);
} else {
/* Fixed nonce for testing */
Expand All @@ -1968,8 +1984,11 @@ uint16_t DesfireCmdAuthenticateAES1(uint8_t *Buffer, uint16_t ByteCount) {
DesfireLogEntry(LOG_APP_NONCE_B, DesfireCommandState.RndB, CRYPTO_CHALLENGE_RESPONSE_BYTES);

/* Encrypt RndB with the selected key and transfer it back to the PCD */
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);
Status = CryptoAESEncryptBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, DesfireCommandState.RndB,
&Buffer[1], IVBuffer, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);

if (Status != STATUS_OPERATION_OK) {
Buffer[0] = Status;
return DESFIRE_STATUS_RESPONSE_SIZE;
Expand Down Expand Up @@ -2010,7 +2029,9 @@ uint16_t DesfireCmdAuthenticateAES2(uint8_t *Buffer, uint16_t ByteCount) {
BYTE challengeRndAB[2 * CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndA[CRYPTO_CHALLENGE_RESPONSE_BYTES];
BYTE challengeRndB[CRYPTO_CHALLENGE_RESPONSE_BYTES];
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);
CryptoAESDecryptBuffer(2 * CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndAB, &Buffer[1], IVBuffer, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);
RotateArrayLeft(challengeRndAB + CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
memcpy(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);

Expand All @@ -2024,7 +2045,9 @@ uint16_t DesfireCmdAuthenticateAES2(uint8_t *Buffer, uint16_t ByteCount) {

/* Encrypt and send back the once rotated RndA buffer to the PCD */
RotateArrayRight(challengeRndA, challengeRndAB, CRYPTO_CHALLENGE_RESPONSE_BYTES);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);
CryptoAESEncryptBuffer(CRYPTO_CHALLENGE_RESPONSE_BYTES, challengeRndA, &Buffer[1], IVBuffer, Key);
DesfireLogEntry(LOG_APP_SESSION_IV, (void *) IVBuffer, CRYPTO_CHALLENGE_RESPONSE_BYTES);

/* Create the session key based on the previous exchange */
generateSessionKey(SessionKey, challengeRndA, challengeRndB, CRYPTO_TYPE_AES128);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ This notice must be retained at the top of all source files where indicated.

#ifndef __DESFIRE_LOGGING_CODES_INCLUDE_C__
#define __DESFIRE_LOGGING_CODES_INCLUDE_C__
/* Intended to log all routine, complete transaction records (verbose output), and
to source a list of debugging messages and TODO items in the
developing DESFire emulation support within the firmware sources.
These codes should almost immediately be supported for use of the Chameleon Mini
devices with the Chameleon Mini Live Debugger logger application for Android: */

LOG_ERR_DESFIRE_GENERIC_ERROR = 0xE0,
LOG_INFO_DESFIRE_STATUS_INFO = 0xE1,
LOG_INFO_DESFIRE_DEBUGGING_OUTPUT = 0xE2,
Expand All @@ -49,14 +45,16 @@ LOG_INFO_DESFIRE_PROTECTED_DATA_SET = 0xEC,
LOG_INFO_DESFIRE_PROTECTED_DATA_SET_VERBOSE = 0xED,

/* DESFire app */
LOG_APP_AUTH_KEY = 0xD0, ///< The key used for authentication
LOG_APP_NONCE_B = 0xD1, ///< Nonce B's value (generated)
LOG_APP_NONCE_AB = 0xD2, ///< Nonces A and B values (received)
LOG_APP_AUTH_KEY = 0xD0, ///< The key used for authentication
LOG_APP_NONCE_B = 0xD1, ///< Nonce B's value (generated)
LOG_APP_NONCE_AB = 0xD2, ///< Nonces A and B values (received)
LOG_APP_SESSION_IV = 0xD3, ///< Contents of the session IV buffer

/* ISO 14443 related entries */
LOG_ISO14443_3A_STATE = 0x53,
LOG_ISO14443_4_STATE = 0x54,
LOG_ISO14443A_APP_NO_RESPONSE = 0x55,
LOG_ISO14443_3A_STATE = 0x53,
LOG_ISO14443_4_STATE = 0x54,
LOG_ISO14443A_APP_NO_RESPONSE = 0x55,

#endif

#endif /* CONFIG_MF_DESFIRE_SUPPORT */
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ This notice must be retained at the top of all source files where indicated.
#ifdef CONFIG_MF_DESFIRE_SUPPORT

#include "../../Common.h"
#include "../../Settings.h"
#include "../../Memory.h"

#include "DESFireMemoryOperations.h"
Expand Down Expand Up @@ -88,6 +89,25 @@ uint8_t GetCardCapacityBlocks(void) {
return MaxFreeBlocks - Picc.FirstFreeBlock;
}

/* TODO: Note: If things suddenly start to break, this code is a good first place to look ... */
void MemoryStoreDesfireHeaderBytes(void) {
void *PiccHeaderDataAddr = (void *) &Picc;
uint16_t PiccHeaderDataSize = sizeof(Picc);
/* Place the header data in EEPROM in the space directly below the settings structures
* (see function SettingsUpdate in "../../Settings.h"):
*/
uintptr_t EEWriteAddr = (uintptr_t)PiccHeaderDataAddr - (uintptr_t)&GlobalSettings - (uintptr_t)((SETTINGS_COUNT - GlobalSettings.ActiveSettingIdx) * PiccHeaderDataSize);
eeprom_update_block((uint8_t *) PiccHeaderDataAddr, (uint8_t *) EEWriteAddr, PiccHeaderDataSize);
}

/* TODO: Same note to examine code here on unexpected new errors ... */
void MemoryRestoreDesfireHeaderBytes(void) {
void *PiccHeaderDataAddr = (void *) &Picc;
uint16_t PiccHeaderDataSize = sizeof(Picc);
uintptr_t EEReadAddr = (uintptr_t)PiccHeaderDataAddr - (uintptr_t)&GlobalSettings - (uintptr_t)((SETTINGS_COUNT - GlobalSettings.ActiveSettingIdx) * PiccHeaderDataSize);
eeprom_read_block((uint8_t *) PiccHeaderDataAddr, (uint8_t *) EEReadAddr, PiccHeaderDataSize);
}

void ReadDataEEPROMSource(uint8_t *Buffer, uint8_t Count) {
MemoryReadBlock(Buffer, TransferState.ReadData.Source.Pointer, Count);
TransferState.ReadData.Source.Pointer += DESFIRE_BYTES_TO_BLOCKS(Count);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,16 @@ extern volatile char __InternalStringBuffer[STRING_BUFFER_SIZE];
void ReadBlockBytes(void *Buffer, SIZET StartBlock, SIZET Count);

void WriteBlockBytesMain(const void *Buffer, SIZET StartBlock, SIZET Count);
#define WriteBlockBytes(Buffer, StartBlock, Count) \
WriteBlockBytesMain(Buffer, StartBlock, Count);
#define WriteBlockBytes(Buffer, StartBlock, Count) WriteBlockBytesMain(Buffer, StartBlock, Count);

uint16_t AllocateBlocksMain(uint16_t BlockCount);
#define AllocateBlocks(BlockCount) \
AllocateBlocksMain(BlockCount);
#define AllocateBlocks(BlockCount) AllocateBlocksMain(BlockCount);

BYTE GetCardCapacityBlocks(void);

void MemoryStoreDesfireHeaderBytes(void);
void MemoryRestoreDesfireHeaderBytes(void);

/* File data transfer related routines: */
void ReadDataEEPROMSource(uint8_t *Buffer, uint8_t Count);
void WriteDataEEPROMSink(uint8_t *Buffer, uint8_t Count);
Expand Down
Loading

0 comments on commit e7790dc

Please sign in to comment.