Beispiel #1
0
        /// <summary>
        /// Extension method to SmartCardConnection class similar to Transmit asyc method, however it accepts PCSC SDK commands.
        /// </summary>
        /// <param name="apduCommand">
        /// APDU command object to send to the ICC
        /// </param>
        /// <param name="connection">
        /// SmartCardConnection object
        /// </param>
        /// <returns>APDU response object of type defined by the APDU command object</returns>
        public static async Task <Iso7816.ApduResponse> TransceiveAsyncOriginal(this SmartCardConnection connection, Iso7816.ApduCommand apduCommand)
        {
            Iso7816.ApduResponse apduRes = Activator.CreateInstance(apduCommand.ApduResponseType) as Iso7816.ApduResponse;

            IBuffer responseBuf = await connection.TransmitAsync(apduCommand.GetBuffer());

            apduRes.ExtractResponse(responseBuf);

            return(apduRes);
        }
Beispiel #2
0
        public static async Task <Iso7816.ApduResponse> TransceiveAsync(this SmartCardConnection connection, Iso7816.ApduCommand apduCommand)
        {
            Iso7816.ApduResponse apduRes = Activator.CreateInstance(apduCommand.ApduResponseType) as Iso7816.ApduResponse;

            IBuffer cmdBuffer = apduCommand.GetBuffer();

            DeviceServerApp.Logger.Information("Transmitting <" + cmdBuffer.ToString() + ">");
            IBuffer responseBuf = await connection.TransmitAsync(cmdBuffer);   // <- throws exception (0x80004004 (E_ABORT))

            apduRes.ExtractResponse(responseBuf);

            return(apduRes);
        } // TransceiveAsync
Beispiel #3
0
        /// <summary>
        /// Extension method to SmartCardConnection class similar to Transmit asyc method, however it accepts PCSC SDK commands.
        /// </summary>
        /// <param name="apduCommand">
        /// APDU command object to send to the ICC
        /// </param>
        /// <param name="connection">
        /// SmartCardConnection object
        /// </param>
        /// <returns>APDU response object of type defined by the APDU command object</returns>
        internal static IAsyncOperation <Iso7816.ApduResponse> TransceiveAsync(this SmartCardConnection connection, Iso7816.ApduCommand apduCommand)
        {
            return(AsyncInfo.Run(async(cancel) =>
            {
                Iso7816.ApduResponse apduRes = Activator.CreateInstance(apduCommand.ApduResponseType) as Iso7816.ApduResponse;

                IBuffer responseBuf = await connection.TransmitAsync(apduCommand.GetBuffer());

                apduRes.ExtractResponse(responseBuf);

                return apduRes;
            }));
        }