Esempio n. 1
0
        /// <summary>
        /// Reads the file pointed by the SFI found in the FCI of the application.
        /// </summary>
        /// <returns>Last status word.</returns>
        public UInt16 Read()
        {
            BeforeReadEvent.Raise(this, new EmvEventArgs());

            var tlvSfi = TlvFci.GetTag(0x88);

            if (tlvSfi == null)
            {
                throw new Exception(String.Format("PSE: no tag 88 (sfi) found in FCI [{0}]", TlvFci));
            }
            var sfi = new ShortFileIdentifier(tlvSfi);

            byte recordNumber = 0;

            do
            {
                recordNumber++;
                var crp = new CommandResponsePair {
                    CApdu = new EMVReadRecordCommand(recordNumber, sfi.Sfi, 0)
                };
                crp.Transmit(_cardChannel);
                _lastStatusWord = crp.RApdu.StatusWord;
                if (crp.RApdu.StatusWord == 0x9000)
                {
                    _tlvRecords.Add(new TlvData(crp.RApdu.Udr));
                }
            } while (_lastStatusWord == 0x9000);

            AfterReadEvent.Raise(this, new EmvEventArgs());

            return(_lastStatusWord);
        }
 protected void RaiseBeforeRead(BeforeReadEventArgs args)
 {
     BeforeReadEvent?.Invoke(this, args);
 }