Exemplo n.º 1
0
        private IsoReader GetReader(ref bool iSSecureElement)
        {
            IsoReader reader;
            // Establish SCard context
            SCardContext hContext = new SCardContext();

            hContext.Establish(SCardScope.System);
            // Retrieve the list of Smartcard readers
            string[] szReaders = hContext.GetReaders();

            // Create a reader object using the existing context
            reader = new IsoReader(hContext);

            // Connect to the card
            foreach (var sZReader in szReaders)
            {
                reader.Connect(sZReader,
                               SCardShareMode.Shared,
                               SCardProtocol.T0 | SCardProtocol.T1);

                var response = reader.Transmit(GetSelectAppBytes(reader));
                if (response.SW1 == 0x90)
                {
                    iSSecureElement = true;
                    break;
                }
            }
            return(reader);
        }
Exemplo n.º 2
0
        public void OpenCard()
        {
            EnsureInitialized();

            if (reader.Reader.IsConnected)
            {
                return;
            }

            TryPcsc(() =>
                    reader.Connect(name, shareMode, protocol));
        }
Exemplo n.º 3
0
 public IsoReader TryConnect(String cardName)
 {
     try
     {
         IsoReader card = new IsoReader(this.reader);
         card.Connect(cardName, SCardShareMode.Shared, SCardProtocol.Any);
         return(card);
     }
     catch (PCSCException)
     {
         return(null);
     }
 }
Exemplo n.º 4
0
 public SmartCard(SCardContext context, string readerName)
 {
     reader = new IsoReader(context);
     reader.Connect(readerName, SCardShareMode.Exclusive, SCardProtocol.Any);
 }