Skip to content

Commit

Permalink
Fix: getAppIds on Desfire
Browse files Browse the repository at this point in the history
  • Loading branch information
c3rebro committed Oct 4, 2022
1 parent 8ce0c0e commit 7f77b82
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 23 deletions.
18 changes: 11 additions & 7 deletions RFiDGear/DataAccessLayer/Remote/FromIO/ElatecNetProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,7 @@ public override ERROR ReadChipPublic()
if(!IsConnected)
{
Instance.Connect();
}

readerDevice.GreenLED(true);
readerDevice.RedLED(true);
}

card = readerDevice.GetSingleChip();

Expand All @@ -72,7 +69,8 @@ public override ERROR ReadChipPublic()
readerDevice.Beep(1, 50, 1000, 100);

GenericChip = new GenericChipModel(card.ChipIdentifier, (CARD_TYPE)card.CardType);

readerDevice.GreenLED(true);
readerDevice.RedLED(false);
return ERROR.NoError;
}
catch (Exception e)
Expand All @@ -84,6 +82,8 @@ public override ERROR ReadChipPublic()
else
{
readerDevice.Beep(3, 25, 600, 100);
readerDevice.GreenLED(false);
readerDevice.RedLED(true);
GenericChip = null;

return ERROR.NotReadyError;
Expand Down Expand Up @@ -275,7 +275,11 @@ public override ERROR AuthToMifareDesfireApplication(string _applicationMasterKe
{
ReadChipPublic();

return readerDevice.DesfireAuthenticate(_applicationMasterKey, (byte)_keyNumber, 0, 0) == true ? ERROR.NoError : ERROR.NotAllowed;
return readerDevice.DesfireAuthenticate(
_applicationMasterKey,
(byte)_keyNumber,
(byte)Enum.Parse(typeof(Elatec.NET.DESfireKeyType), Enum.GetName(typeof(RFiDGear.DataAccessLayer.DESFireKeyType), _keyType)),
1) == true ? ERROR.NoError : ERROR.NotAllowed;

}
public override ERROR GetMifareDesfireAppSettings(string _applicationMasterKey, DESFireKeyType _keyType, int _keyNumberCurrent, int _appID)
Expand All @@ -286,7 +290,7 @@ public override ERROR CreateMifareDesfireApplication(string _piccMasterKey, DESF
DESFireKeyType _keyTypePiccMasterKey, DESFireKeyType _keyTypeTargetApplication,
int _maxNbKeys, int _appID, bool authenticateToPICCFirst = true)
{
throw new NotImplementedException();
return readerDevice.DesfireCreateApplication((Elatec.NET.DESFireKeySettings)_keySettingsTarget, (Elatec.NET.DESFireKeyType)_keyTypeTargetApplication, _maxNbKeys, _appID) == true ? ERROR.NoError : ERROR.NotAllowed;
}
public override ERROR ChangeMifareDesfireApplicationKey(string _applicationMasterKeyCurrent, int _keyNumberCurrent, DESFireKeyType _keyTypeCurrent,
string _applicationMasterKeyTarget, int _keyNumberTarget, int selectedDesfireAppKeyVersionTargetAsIntint,
Expand Down
2 changes: 1 addition & 1 deletion RFiDGear/RFiDGear.csproj.user
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<StartArguments>REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=1 %24JobNumber=1234 %24CardType=MifareDesfire</StartArguments>
<StartArguments>REPORTTARGETPATH="C:\temp\test file.pdf" AUTORUN=0 %24JobNumber=1234 %24CardType=</StartArguments>
<StartWorkingDirectory>D:\Seafile\Dokumente Privat\Steven\Projekte\Software\Windows\RFIDGear\RFiDGear\bin\Debug\</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
Expand Down
32 changes: 17 additions & 15 deletions RFiDGear/ViewModel/MainWindowViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ public class MainWindowViewModel : ObservableObject
private protected bool _runSelectedOnly;

private int currentTaskIndex = 0;
//set if task was completed; indicates greenlight to continue execution
//if programming takes too long; quit the process
// set if task was completed; indicates greenlight to continue execution
// if programming takes too long; quit the process
private bool firstRun = true;
private bool updateAvailable = false;
private protected Mutex mutex;
//one reader, one instance - only
// one reader, one instance - only

#region Events / Delegates

Expand Down Expand Up @@ -697,17 +697,17 @@ private void OnNewCreateDesfireTaskCommand()
}

if (sender.SelectedTaskType == TaskType_MifareDesfireTask.FormatDesfireCard ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.PICCMasterKeyChangeover ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ReadAppSettings ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.AppExistCheck ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.AuthenticateApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ApplicationKeyChangeover ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.DeleteApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.CreateApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.DeleteFile ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.CreateFile ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ReadData ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.WriteData)
sender.SelectedTaskType == TaskType_MifareDesfireTask.PICCMasterKeyChangeover ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ReadAppSettings ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.AppExistCheck ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.AuthenticateApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ApplicationKeyChangeover ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.DeleteApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.CreateApplication ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.DeleteFile ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.CreateFile ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.ReadData ||
sender.SelectedTaskType == TaskType_MifareDesfireTask.WriteData)
{
if (ChipTasks.TaskCollection.OfType<MifareDesfireSetupViewModel>().Any(x => (x as MifareDesfireSetupViewModel).SelectedTaskIndexAsInt == sender.SelectedTaskIndexAsInt))
{
Expand Down Expand Up @@ -1132,7 +1132,7 @@ private void OnNewWriteToChipOnceCommand()

if (GenericChip != null)
{
if (GenericChip.CardType == CARD_TYPE.DESFire || GenericChip.CardType == CARD_TYPE.DESFireEV1 || GenericChip.CardType == CARD_TYPE.DESFireEV2)
if (GenericChip.CardType.ToString().ToLower(CultureInfo.CurrentCulture).Contains("desfire"))
{
device.GetMiFareDESFireChipAppIDs();
}
Expand Down Expand Up @@ -2077,12 +2077,14 @@ private void AskForUpdateNow()
{
updater.AllowUpdate = false;
updateAction.Close();
mw.Activate();
},

OnCloseRequest = (updateAction) =>
{
updater.AllowUpdate = false;
updateAction.Close();
mw.Activate();
}
});
}
Expand Down

0 comments on commit 7f77b82

Please sign in to comment.