Skip to content

Commit

Permalink
Improvement: Load Data as Hex String from txt File
Browse files Browse the repository at this point in the history
Improvement: Load Data as Hex String from File
  • Loading branch information
c3rebro committed Jul 24, 2022
1 parent d707038 commit 67178b9
Show file tree
Hide file tree
Showing 25 changed files with 100 additions and 2,188 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace RedCell.Diagnostics.Update
{
public class Updater
public class Updater : IDisposable
{
#region Constants

Expand Down Expand Up @@ -338,5 +338,11 @@ public void Update()
}
}
#endregion

public void Dispose()
{
this.Dispose();
}

}
}
56 changes: 2 additions & 54 deletions RFiDGear/DataAccessLayer/Local/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ namespace RFiDGear.DataAccessLayer

public static class Constants
{
public const int MAX_WAIT_INSERTION = 200; //timeout for chip response in ms
public const string TITLE_SUFFIX = ""; //turns out special app versions
public static readonly int MAX_WAIT_INSERTION = 200; //timeout for chip response in ms
public static readonly string TITLE_SUFFIX = ""; //turns out special app versions
//public const string TITLE_SUFFIX = "DEVELOPER PREVIEW"; //turns out special app versions
}

Expand Down Expand Up @@ -310,57 +310,5 @@ public MifareClassicDefaultKeys(int _keyNumber, string _accessBits)
public int KeyNumber;
public string AccessBits { get => accessBits; set => accessBits = value; }
}

#region LibLogicalAccess enums

/*
/// <summary>
///
/// </summary>
[Flags]
public enum DESFireKeyType
{
DF_KEY_3K3DES,
DF_KEY_AES,
DF_KEY_DES
}
/// <summary>
///
/// </summary>
[Flags]
public enum TaskAccessRights
{
AR_KEY0 = 0,
AR_KEY1 = 1,
AR_KEY2 = 2,
AR_KEY3 = 3,
AR_KEY4 = 4,
AR_KEY5 = 5,
AR_KEY6 = 6,
AR_KEY7 = 7,
AR_KEY8 = 8,
AR_KEY9 = 9,
AR_KEY10 = 10,
AR_KEY11 = 11,
AR_KEY12 = 12,
AR_KEY13 = 13,
AR_FREE = 14,
AR_NEVER = 15
}
/// <summary>
///
/// </summary>
[Flags]
public enum EncryptionMode
{
CM_ENCRYPT = 3,
CM_MAC = 1,
CM_PLAIN = 0,
CM_UNKNOWN = 255
}
*/
#endregion
}

3 changes: 2 additions & 1 deletion RFiDGear/DataAccessLayer/Local/CustomConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -258,13 +258,14 @@ public static int GetChipBasedDataBlockNumber(CARD_TYPE _cardType, int _sectorNu
break;

case CARD_TYPE.Mifare2K:

break;

case CARD_TYPE.Mifare4K:
blockCount = (_sectorNumber <= 31 ? 4 : 16);
break;

default:
throw new InvalidOperationException("Unexpected Card Type");

}

Expand Down
28 changes: 4 additions & 24 deletions RFiDGear/DataAccessLayer/Remote/FromIO/RFiDDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,16 +182,13 @@ public ERROR ReadChipPublic()
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//string readerSerialNumber = readerUnit.GetReaderSerialNumber(); //-> ERROR with OmniKey (and some others?) Reader when card isnt removed before recalling!

card = readerUnit.GetSingleChip();

if (!string.IsNullOrWhiteSpace(card.ChipIdentifier))
{
try
{
//CardInfo = new CARD_INFO((CARD_TYPE)Enum.Parse(typeof(CARD_TYPE), card.Type), card.ChipIdentifier);
//readerUnit.Disconnect();
GenericChip = new GenericChipModel(card.ChipIdentifier, (CARD_TYPE)Enum.Parse(typeof(CARD_TYPE), card.Type));

if (card.Type == "DESFire" || card.Type == "DESFireEV1")
Expand All @@ -213,9 +210,7 @@ public ERROR ReadChipPublic()
GenericChip.CardType = CARD_TYPE.DESFire;
}
}
//ISO15693Commands commands = card.Commands as ISO15693Commands;
//SystemInformation si = commands.GetSystemInformation();
//var block=commands.ReadBlock(21, 4);

readerUnit.Disconnect();
return ERROR.NoError;
}
Expand Down Expand Up @@ -1197,6 +1192,8 @@ public ERROR CreateMifareDesfireFile(string _appMasterKey, DESFireKeyType _keyTy
case FileType_MifareDesfireFileType.LinearRecordFile:
cmd.CreateLinearRecordFile((byte)_fileNo, _encMode, accessRights, (uint)_fileSize, (uint)_maxNbOfRecords);
break;
default:
throw new InvalidOperationException("Unexpected FileTypeSelection");
}

return ERROR.NoError;
Expand Down Expand Up @@ -1723,7 +1720,6 @@ public ERROR GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKe
{
var cmd = card.Commands as IDESFireCommands;
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

try
{
Expand Down Expand Up @@ -1791,7 +1787,6 @@ public ERROR GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKe
{
var cmd = card.Commands as IDESFireEV1Commands;
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

try
{
Expand Down Expand Up @@ -1897,7 +1892,6 @@ public ERROR CreateMifareDesfireApplication(string _piccMasterKey, DESFireKeySet
SecurityLevel = EncryptionMode.CM_ENCRYPT
};

// IDESFireEV1Commands cmd;
// Keys to use for authentication
IDESFireAccessInfo aiToUse = new DESFireAccessInfo();
CustomConverter.FormatMifareDesfireKeyStringWithSpacesEachByte(_piccMasterKey);
Expand Down Expand Up @@ -2030,7 +2024,6 @@ public ERROR ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurre
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand Down Expand Up @@ -2182,7 +2175,6 @@ public ERROR DeleteMifareDesfireApplication(string _applicationMasterKey, DESFir
SecurityLevel = EncryptionMode.CM_ENCRYPT
};

// IDESFireEV1Commands cmd;
// Keys to use for authentication
IDESFireAccessInfo aiToUse = new DESFireAccessInfo();
CustomConverter.FormatMifareDesfireKeyStringWithSpacesEachByte(_applicationMasterKey);
Expand All @@ -2196,7 +2188,6 @@ public ERROR DeleteMifareDesfireApplication(string _applicationMasterKey, DESFir
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand Down Expand Up @@ -2278,7 +2269,6 @@ public ERROR DeleteMifareDesfireFile(string _applicationMasterKey, DESFireKeyTyp
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand Down Expand Up @@ -2363,7 +2353,6 @@ public ERROR FormatDesfireCard(string _applicationMasterKey, DESFireKeyType _key
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand Down Expand Up @@ -2425,7 +2414,6 @@ public ERROR GetMifareDesfireFileList(string _applicationMasterKey, DESFireKeyTy
SecurityLevel = EncryptionMode.CM_ENCRYPT
};

//IDESFireEV1Commands cmd;
// Keys to use for authentication
IDESFireAccessInfo aiToUse = new DESFireAccessInfo();
CustomConverter.FormatMifareDesfireKeyStringWithSpacesEachByte(_applicationMasterKey);
Expand All @@ -2441,7 +2429,6 @@ public ERROR GetMifareDesfireFileList(string _applicationMasterKey, DESFireKeyTy
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand Down Expand Up @@ -2522,7 +2509,6 @@ public ERROR GetMifareDesfireFileSettings(string _applicationMasterKey, DESFireK
{
try
{
// IDESFireEV1Commands cmd;
// Keys to use for authentication
IDESFireAccessInfo aiToUse = new DESFireAccessInfo();
CustomConverter.FormatMifareDesfireKeyStringWithSpacesEachByte(_applicationMasterKey);
Expand Down Expand Up @@ -2628,7 +2614,6 @@ public ERROR ReadISO15693Chip()
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();

Expand All @@ -2638,9 +2623,7 @@ public ERROR ReadISO15693Chip()
var cmd = card.Commands as ISO15693Commands;// IMifareUltralightCommands;

object t = cmd.GetSystemInformation();
//object res = cmd.ReadPage(4);

//appIDs = (appIDsObject as UInt32[]);
}

return ERROR.NoError;
Expand Down Expand Up @@ -2671,17 +2654,14 @@ public ERROR ReadEM4135ChipPublic()
if (readerUnit.Connect())
{
ReaderUnitName = readerUnit.ConnectedName;
//readerSerialNumber = readerUnit.GetReaderSerialNumber();

card = readerUnit.GetSingleChip();


if (true) //card.Type == "ISO15693"
if (true)
{
var cmd = (card as EM4135Chip).ChipIdentifier;// IMifareUltralightCommands;
//object res = cmd.ReadPage(4);

//appIDs = (appIDsObject as UInt32[]);
}

return ERROR.NoError;
Expand Down
38 changes: 0 additions & 38 deletions RFiDGear/Model/CheckpointModel.cs

This file was deleted.

Loading

0 comments on commit 67178b9

Please sign in to comment.