diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c b/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c index b6c9c039..b836f5bd 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireInstructions.c @@ -447,7 +447,7 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) { } /* Make sure that this key is AES, and figure out its byte size */ BYTE cryptoKeyType = ReadKeyCryptoType(SelectedApp.Slot, KeyId); - if (!CryptoTypeDES(cryptoKeyType)) { + if (!CryptoType3KTDEA(cryptoKeyType)) { Buffer[0] = STATUS_NO_SUCH_KEY; return DESFIRE_STATUS_RESPONSE_SIZE; } @@ -492,7 +492,7 @@ uint16_t EV0CmdAuthenticateLegacy1(uint8_t *Buffer, uint16_t ByteCount) { &Buffer[1], NULL, Key); /* Scrub the key */ - memset(*Key, 0, keySize); + memset(Key, 0, keySize); /* Done */ DesfireState = DESFIRE_LEGACY_AUTHENTICATE2; diff --git a/Firmware/Chameleon-Mini/Application/DESFire/DESFireMemoryOperations.c b/Firmware/Chameleon-Mini/Application/DESFire/DESFireMemoryOperations.c index 1c6cc7e2..ddb0c8da 100644 --- a/Firmware/Chameleon-Mini/Application/DESFire/DESFireMemoryOperations.c +++ b/Firmware/Chameleon-Mini/Application/DESFire/DESFireMemoryOperations.c @@ -45,7 +45,7 @@ void ReadBlockBytes(void *Buffer, SIZET StartBlock, SIZET Count) { DEBUG_PRINT_P(rbbLogMsg, StartBlock, MEMORY_SIZE_PER_SETTING); return; } - MemoryDownloadBlock(Buffer, StartBlock * BLOCKWISE_IO_MULTIPLIER, Count); + MemoryReadBlockInSetting(Buffer, StartBlock * BLOCKWISE_IO_MULTIPLIER, Count); } void WriteBlockBytesMain(const void *Buffer, SIZET StartBlock, SIZET Count) { @@ -54,7 +54,7 @@ void WriteBlockBytesMain(const void *Buffer, SIZET StartBlock, SIZET Count) { DEBUG_PRINT_P(wbbLogMsg, StartBlock, MEMORY_SIZE_PER_SETTING); return; } - MemoryUploadBlock(Buffer, StartBlock * BLOCKWISE_IO_MULTIPLIER, Count); + MemoryWriteBlockInSetting(Buffer, StartBlock * BLOCKWISE_IO_MULTIPLIER, Count); } uint16_t AllocateBlocksMain(uint16_t BlockCount) { diff --git a/Firmware/Chameleon-Mini/Log.h b/Firmware/Chameleon-Mini/Log.h index 0ed475a7..39828d1f 100644 --- a/Firmware/Chameleon-Mini/Log.h +++ b/Firmware/Chameleon-Mini/Log.h @@ -3,7 +3,7 @@ /** @file */ #include "Common.h" -#define LOG_SIZE 2048 +#define LOG_SIZE 2048 #define FRAM_LOG_ADDR_ADDR 0x4000 // start of the second half of FRAM #define FRAM_LOG_START_ADDR 0x4002 // directly after the address #define FRAM_LOG_SIZE 0x3FFE // the whole second half (minus the 2 Bytes of Address) diff --git a/Firmware/Chameleon-Mini/Memory.c b/Firmware/Chameleon-Mini/Memory.c index c4cbd520..d0800210 100644 --- a/Firmware/Chameleon-Mini/Memory.c +++ b/Firmware/Chameleon-Mini/Memory.c @@ -366,7 +366,25 @@ void MemoryWriteBlock(const void *Buffer, uint16_t Address, uint16_t ByteCount) if (ByteCount == 0) return; FRAMWrite(Buffer, Address, ByteCount); + LEDHook(LED_MEMORY_CHANGED, LED_ON); +} +void MemoryReadBlockInSetting(void *Buffer, uint16_t Address, uint16_t ByteCount) { + if (ByteCount == 0 || ByteCount >= MEMORY_SIZE_PER_SETTING) + return; + uint16_t ShiftedAddress = Address + GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING; + if (ShiftedAddress < Address) + return; + FRAMRead(Buffer, ShiftedAddress, ByteCount); +} + +void MemoryWriteBlockInSetting(const void *Buffer, uint16_t Address, uint16_t ByteCount) { + if (ByteCount == 0 || ByteCount >= MEMORY_SIZE_PER_SETTING) + return; + uint16_t ShiftedAddress = Address + GlobalSettings.ActiveSettingIdx * MEMORY_SIZE_PER_SETTING; + if (ShiftedAddress < Address) + return; + FRAMWrite(Buffer, ShiftedAddress, ByteCount); LEDHook(LED_MEMORY_CHANGED, LED_ON); } diff --git a/Firmware/Chameleon-Mini/Memory.h b/Firmware/Chameleon-Mini/Memory.h index 35163009..eb58c4a3 100644 --- a/Firmware/Chameleon-Mini/Memory.h +++ b/Firmware/Chameleon-Mini/Memory.h @@ -19,6 +19,8 @@ void MemoryInit(void); void MemoryReadBlock(void *Buffer, uint16_t Address, uint16_t ByteCount); void MemoryWriteBlock(const void *Buffer, uint16_t Address, uint16_t ByteCount); +void MemoryReadBlockInSetting(void *Buffer, uint16_t Address, uint16_t ByteCount); +void MemoryWriteBlockInSetting(const void *Buffer, uint16_t Address, uint16_t ByteCount); void MemoryClear(void); void MemoryRecall(void); diff --git a/Firmware/Chameleon-Mini/Terminal/Terminal.h b/Firmware/Chameleon-Mini/Terminal/Terminal.h index 8aa06f01..36217c1c 100644 --- a/Firmware/Chameleon-Mini/Terminal/Terminal.h +++ b/Firmware/Chameleon-Mini/Terminal/Terminal.h @@ -16,11 +16,7 @@ #define TERMINAL_VBUS_PORT PORTD #define TERMINAL_VBUS_MASK PIN5_bm -#ifdef MEMORY_LIMITED_TESTING -#define TERMINAL_BUFFER_SIZE 256 -#else #define TERMINAL_BUFFER_SIZE 512 -#endif typedef enum { TERMINAL_UNINITIALIZED,