Merge branch 'epozzobon-master'

This commit is contained in:
Fabian
2019-12-06 15:00:46 +01:00
@@ -683,7 +683,6 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
return rVal;
}
case Reader14443_Clone_MF_Ultralight:
case Reader14443_Read_MF_Ultralight: {
static uint8_t MFURead_CurrentAdress = 0;
static uint8_t MFUContents[64];
@@ -718,28 +717,18 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
if (MFURead_CurrentAdress == 16) {
Selected = false;
MFURead_CurrentAdress = 0;
Reader14443CurrentCommand = Reader14443_Do_Nothing;
if (Reader14443CurrentCommand == Reader14443_Read_MF_Ultralight) { // dump
Reader14443CurrentCommand = Reader14443_Do_Nothing;
char tmpBuf[135]; // 135 = 128 hex digits + 3 * \r\n + \0
BufferToHexString(tmpBuf, 135, MFUContents, 16);
snprintf(tmpBuf + 32, 135 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2, 135 - 32 - 2, MFUContents + 16, 16);
snprintf(tmpBuf + 32 + 2 + 32, 135 - 32 - 2 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2 + 32 + 2, 135 - 32 - 2 - 32 - 2, MFUContents + 32, 16);
snprintf(tmpBuf + 32 + 2 + 32 + 2 + 32, 135 - 32 - 2 - 32 - 2 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2 + 32 + 2 + 32 + 2, 135 - 32 - 2 - 32 - 2 - 32 - 2, MFUContents + 48, 16);
CodecReaderFieldStop();
CommandLinePendingTaskFinished(COMMAND_INFO_OK_WITH_TEXT_ID, tmpBuf);
} else { // clone
Reader14443CurrentCommand = Reader14443_Do_Nothing;
CodecReaderFieldStop();
MemoryUploadBlock(&MFUContents, 0, 64);
CommandLinePendingTaskFinished(COMMAND_INFO_OK_WITH_TEXT_ID, "Card Cloned to Slot");
ConfigurationSetById(CONFIG_MF_ULTRALIGHT);
MemoryStore();
SettingsSave();
}
char tmpBuf[135]; // 135 = 128 hex digits + 3 * \r\n + \0
BufferToHexString(tmpBuf, 135, MFUContents, 16);
snprintf(tmpBuf + 32, 135 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2, 135 - 32 - 2, MFUContents + 16, 16);
snprintf(tmpBuf + 32 + 2 + 32, 135 - 32 - 2 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2 + 32 + 2, 135 - 32 - 2 - 32 - 2, MFUContents + 32, 16);
snprintf(tmpBuf + 32 + 2 + 32 + 2 + 32, 135 - 32 - 2 - 32 - 2 - 32, "\r\n");
BufferToHexString(tmpBuf + 32 + 2 + 32 + 2 + 32 + 2, 135 - 32 - 2 - 32 - 2 - 32 - 2, MFUContents + 48, 16);
CodecReaderFieldStop();
CommandLinePendingTaskFinished(COMMAND_INFO_OK_WITH_TEXT_ID, tmpBuf);
return 0;
}
Buffer[0] = 0x30; // MiFare Ultralight read command
@@ -814,16 +803,22 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
int cfgid = -1;
switch (CardCandidates[0]) {
case CardType_NXP_MIFARE_Ultralight: {
#ifdef CONFIG_MF_ULTRALIGHT_SUPPORT
cfgid = CONFIG_MF_ULTRALIGHT;
#endif
// TODO: enter MFU clone mdoe
break;
}
case CardType_NXP_MIFARE_Classic_1k:
case CardType_Infineon_MIFARE_Classic_1k: {
if (CardCharacteristics.UIDSize == UIDSize_Single) {
#ifdef CONFIG_MF_CLASSIC_1K_SUPPORT
cfgid = CONFIG_MF_CLASSIC_1K;
#endif
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
#ifdef CONFIG_MF_CLASSIC_1K_7B_SUPPORT
cfgid = CONFIG_MF_CLASSIC_1K_7B;
#endif
}
break;
}
@@ -831,9 +826,13 @@ uint16_t Reader14443AAppProcess(uint8_t *Buffer, uint16_t BitCount) {
case CardType_Nokia_MIFARE_Classic_4k_emulated_6212:
case CardType_Nokia_MIFARE_Classic_4k_emulated_6131: {
if (CardCharacteristics.UIDSize == UIDSize_Single) {
#ifdef CONFIG_MF_CLASSIC_4K_SUPPORT
cfgid = CONFIG_MF_CLASSIC_4K;
#endif
} else if (CardCharacteristics.UIDSize == UIDSize_Double) {
#ifdef CONFIG_MF_CLASSIC_4K_7B_SUPPORT
cfgid = CONFIG_MF_CLASSIC_4K_7B;
#endif
}
break;
}