public static void GPPersoFromXmlTest(string xml) { perso perso = XMLUtil <perso> .Deserialize(xml); perso.application.ToList().ForEach(app => { installType it = app.commands.install; INSTALL_PARAM_C9_GP ip = null; if (it.tokens != null) { if (it.tokens.tlvxml != null) { ip = new INSTALL_PARAM_C9_GP(); valueC9Type c9 = it.tokens.tlvxml.valueC9; if (c9.C9_ApplicationInstanceSpecified) { ip.Value.ApplicationInstance = MapC9_ApplicationInstanceEnum(c9.C9_ApplicationInstance); } if (c9.C9_PinSharingSpecified) { ip.Value.PinSharing = MapC9_PinSharingEnum(c9.C9_PinSharing); } if (c9.C9_InterfacesAvailableSpecified) { ip.Value.InterfacesAvailable = MapC9_InterfacesAvailableEnum(c9.C9_InterfacesAvailable); } } } GPInstallRequestDataForInstall irfi = new GPInstallRequestDataForInstall() { ExecutableLoadFileAID = it.ExecutableLoadFileAID, ExecutableModuleAID = it.ExecutableModuleAID, ApplicationAID = it.ApplicationAID, Privileges = Formatting.HexStringToByteArray(it.Privileges), InstallToken = Formatting.HexStringToByteArray(it.InstallToken), InstallParamC9 = ip, }; //select //auth GPInstallRequest ir = new GPInstallRequest((byte)InstallRequestP1Enum.LastOrOnlyCommand | (byte)InstallRequestP1Enum.ForMakeSelectable | (byte)InstallRequestP1Enum.ForInstall) { CommandData = irfi.Serialize() }; System.Diagnostics.Debug.WriteLine(ir.ToPrintString()); //select //auth app.commands.storeData.ToList().ForEach(command => { GPStoreData sd = new GPStoreData { DGI = Formatting.HexStringToByteArray(command.DGI) }; if (command.data != null) { sd.DataBytes = Formatting.HexStringToByteArray(command.data); } else { sd.Data = DeserList(command.tlvxml); } GPStoreDataReqest sdr = new GPStoreDataReqest { CommandData = sd.Serialize() }; System.Diagnostics.Debug.WriteLine(sdr.ToPrintString()); }); }); }
public void PersoFromXml(string xml, string secDomainAID, string masterKey) { perso perso = XMLUtil <perso> .Deserialize(xml); byte[] masterKeyBytes = Formatting.HexStringToByteArray(masterKey); perso.application.ToList().ForEach(app => { installType it = app.commands.install; INSTALL_PARAM_C9_GP ip = null; if (it.tokens != null) { if (it.tokens.tlvxml != null) { ip = new INSTALL_PARAM_C9_GP(); valueC9Type c9 = it.tokens.tlvxml.valueC9; if (c9.C9_ApplicationInstanceSpecified) { ip.Value.ApplicationInstance = MapC9_ApplicationInstanceEnum(c9.C9_ApplicationInstance); } if (c9.C9_PinSharingSpecified) { ip.Value.PinSharing = MapC9_PinSharingEnum(c9.C9_PinSharing); } if (c9.C9_InterfacesAvailableSpecified) { ip.Value.InterfacesAvailable = MapC9_InterfacesAvailableEnum(c9.C9_InterfacesAvailable); } } } GPInstallRequestDataForInstall irfi = new GPInstallRequestDataForInstall() { ExecutableLoadFileAID = it.ExecutableLoadFileAID, ExecutableModuleAID = it.ExecutableModuleAID, ApplicationAID = it.ApplicationAID, Privileges = Formatting.HexStringToByteArray(it.Privileges), InstallToken = Formatting.HexStringToByteArray(it.InstallToken), InstallParamC9 = ip, }; persoAccessHandler.SelectApplication(Formatting.HexStringToByteArray(secDomainAID)); //persoAccessHandler.AuthWithCard(masterKey); persoAccessHandler.AuthWithCard(masterKeyBytes, cardChallenge); persoAccessHandler.InstallForPerso(irfi.ApplicationAID); byte counter = 0; List <storeDataType> storeCommands = app.commands.storeData.ToList(); storeCommands.ForEach(command => { bool isLast = (storeCommands.Count - 1) == counter; GPStoreData sd = new GPStoreData { DGI = Formatting.HexStringToByteArray(command.DGI), DataBlock = counter, IsLastBlock = isLast, }; if (command.data != null) { sd.DataBytes = Formatting.HexStringToByteArray(command.data); } else { sd.Data = DeserList(command.tlvxml); } persoAccessHandler.StoreDataToApplication(sd); counter++; }); }); }