/// <inheritdoc />
        public IFakeCardFeedback ExecuteCommand(CommandAPDU cApdu)
        {
            if (cApdu.BinaryCommand.Length < 5)
            {
                return(FakeCardFeedback.FromError(ErrorCode.CommDataLost));
            }

            if (cApdu.IsCc2 && cApdu.Cla == 0x00 && cApdu.Ins == 0xC0)
            {
                return(ProcessGetResponse(cApdu));
            }

            ClearUdrToBeRetrieved();

            IFakeCardFeedback response;

            try
            {
                response = _fakeCard.ExecuteCommand(cApdu);
            }
            catch (ISOException isoException)
            {
                return(FakeCardFeedback.FromSuccess(isoException.getReason()));
            }

            if (response.RApdu.Udr.Length == 0 || cApdu.IsCc2)
            {
                return(response);
            }

            StoreUdrToBeRetrieved(response.RApdu.Udr, cApdu.Ins);

            return(FakeCardFeedback.FromSuccess((short)response.RApdu.StatusWord));
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public virtual ErrorCode Transmit(ICardCommand command, ICardResponse response)
        {
            var result = _fakeCard.ExecuteCommand(new CommandAPDU(command.BinaryCommand));

            if (result.ErrorCode == ErrorCode.Success)
            {
                var rApdu = result.RApdu;
                response.Parse(rApdu.Udr.Concat(new byte[] { rApdu.Sw1, rApdu.Sw2 }).ToArray());
            }

            return(result.ErrorCode);
        }