コード例 #1
0
        public override CommandApdu AsApdu()
        {
            var apdu = CommandApdu.Case2S(ApduClass.GlobalPlatform, ApduInstruction.GetStatus, this.P1, this.P2 |= 0b00000010, 0x00);

            var data = new List <byte>();

            data.AddTLV(TLV.Build((byte)Tag.ApplicationAID, this.applicationFilter));

            apdu.CommandData = data.ToArray();

            return(apdu);
        }
コード例 #2
0
        public override CommandApdu AsApdu()
        {
            this.P1 = (byte)this.operation;
            this.P2 = this.operation == Operation.Close ? this.identifier : (byte)0x00;

            switch (this.operation)
            {
            case Operation.Open:
                return(CommandApdu.Case2S(ApduClass.GlobalPlatform, ApduInstruction.ManageChannel, this.P1, this.P2, 0x01));

            case Operation.Close:
                return(CommandApdu.Case1(ApduClass.GlobalPlatform, ApduInstruction.ManageChannel, this.P1, this.P2));

            default:
                throw new NotSupportedException("Operation not supported.");
            }
        }
コード例 #3
0
        public override CommandApdu AsApdu()
        {
            var apdu = CommandApdu.Case2S(ApduClass.GlobalPlatform, ApduInstruction.Delete, this.P1, this.P2, 0x00);

            var data = new List <byte>();

            switch (this.scope)
            {
            case DeleteCommandScope.CardContent:
                data.AddTLV(TLV.Build((byte)Tag.ExecutableLoadFileOrApplicationAID, this.application));

                if (this.token.Any())
                {
                    data.AddTLV(TLV.Build((byte)Tag.DeleteToken, this.token));
                }
                break;

            case DeleteCommandScope.Key:
                if (this.keyIdentifier == 0 && this.keyVersionNumber == 0)
                {
                    throw new InvalidOperationException("A key identifier or key version number must be specified.");
                }
                if (this.keyIdentifier > 0)
                {
                    data.AddTLV(TLV.Build((byte)Tag.KeyIdentifier, this.keyIdentifier));
                }
                if (this.keyVersionNumber > 0)
                {
                    data.AddTLV(TLV.Build((byte)Tag.KeyVersionNumber, this.keyVersionNumber));
                }
                break;
            }

            apdu.CommandData = data.ToArray();

            return(apdu);
        }