private EmvCardDgis BuildDgi(EmvPersonalizationData cardData) { var builder = new DgiBuilder(cardData.Model, cardData.Data, cardData.IssuerContext, cardData.IccContext); var fci = builder.BuildDgi(cardData.Model.Fci); var gpo = builder.BuildDgi(cardData.Model.Gpo); var acid = builder.BuildDgi(cardData.Model.Acid); var records = new List <string>(); foreach (var record in cardData.Model.Records) { LogActionStart($"Building DGI Record '{record.Sfi}.{record.Index}': "); try { records.Add(builder.BuildDgi(record)); LogSuccess(); } catch (Exception exception) { LogException(exception); } } LogActionStart($"Building DGI PINBlock '{guiAppletPin.Text}': "); string pin = default; try { pin = $"8010{cardData.PinBlock.PinBlock.Length:X2}{cardData.PinBlock.PinBlock.ToHexa('\0')}"; LogSuccess(); } catch (Exception exception) { LogException(exception); } return(new EmvCardDgis(fci, gpo, acid, records, pin)); }
static void Main(/*string[] args*/) { ShowHeader(); var model = LoadFile <EmvPersonalizationModel>(EmvCardModelFileName); if (model == null) { return; } var data = LoadFile <EmvPersonalizationData>(EmvCardDataFileName); if (data == null) { return; } var issuerContext = LoadFile <EmvIssuerContext>(EmvIssuerContextFileName); if (issuerContext == null) { return; } var iccContext = LoadFile <EmvIccContext>(EmvIccContextFileName); if (iccContext == null) { return; } var builder = new DgiBuilder(model, data, issuerContext, iccContext); var container = new DgiContainer(); try { Console.WriteLine("Building DGI for FCI"); var dgiFci = builder.BuildDgi(model.Fci); Console.WriteLine("FCI: {0}", dgiFci); container.Fci = dgiFci; } catch (Exception e) { Console.WriteLine(e); } try { Console.WriteLine("Building DGI for GPO"); var dgiGpo = builder.BuildDgi(model.Gpo); Console.WriteLine("GPO: {0}", dgiGpo); container.Gpo = dgiGpo; } catch (Exception e) { Console.WriteLine(e); } try { Console.WriteLine("Building DGI for ACID"); var dgiAcid = builder.BuildDgi(model.Acid); Console.WriteLine("ACID: {0}", dgiAcid); container.Acid = dgiAcid; } catch (Exception e) { Console.WriteLine(e); } foreach (var record in model.Records) { try { Console.WriteLine("Building DGI for Record {0}.{1}", record.Sfi, record.Index); var dgiRecord = builder.BuildDgi(record); Console.WriteLine("DGI for Record {0}.{1}: {2}", record.Sfi, record.Index, dgiRecord); container.Records.Add(dgiRecord); } catch (Exception e) { Console.WriteLine(e); } } Console.WriteLine("Saving DGI in {0} file", OutputJsonFileName); container.WriteToJsonFile(OutputJsonFileName, true); }