private async Task <List <ApplicationInformation> > ListPseApplications(Application application) { var result = new List <ApplicationInformation>(); var record = 1; while (true) { var res = await card.ReadAsync(application.Template.Sfi, record); if (res.Body is null || res.Body.Length < 1) { break; } ; var tlv = new Tlv.Tlv(res.Body); if (!tlv.ContainsKey(0x70)) { throw new InvalidOperationException("Invalid Pse Record"); } tlv = new Tlv.Tlv(tlv[0x70]); if (!tlv.ContainsKey(0x61)) { throw new InvalidOperationException("Invalid Pse Record"); } var info = TlvSerializer.Deserialize <ApplicationInformation>(tlv, 0x61); result.Add(info); record++; } return(result); }
public async Task <ProcessingOptions> GetProcessingAsync(Tlv.Tlv pdol) { var pdolData = pdol.Encode(); var res = await SendApduAsync(new APDUCommand { Class = 0x80, Instruction = 0xA8, Data = pdolData }); var body = new Tlv.Tlv(res.Body); if (body.ContainsKey(0x77)) { return(TlvSerializer.Deserialize <ProcessingOptions>(body, 0x77)); } if (!body.TryGetValue(0x80, out byte[] raw))
private async void ProcessCardInformation() { var groupTlv = new Tlv.Tlv(); foreach (var app in ProcessingOptions.ApplicationFileList) { var sdaCount = app.SdaCount; for (int i = app.Start; i <= app.End; i++) { var record = await card.ReadAsync(app.Sfi, i); var body = new Tlv.Tlv(record.Body); if (!body.ContainsKey(0x70)) { throw new InvalidOperationException("malformed application file"); } if (sdaCount > 0) { if (app.Sfi <= 10) { sdaData.AddRange(body[0x70]); } else { sdaData.AddRange(record.Body); } sdaCount--; } var template = new Tlv.Tlv(body[0x70]); groupTlv.CopyFrom(template); } } CardInformation = TlvSerializer.Deserialize <CardInformation>(groupTlv); }