Exemplo n.º 1
0
        public void T0_Should_be_kept_if_T1_is_added_but_t0_was_only_indicated_by_default()
        {
            Atr Atr = new Atr(new byte[] { 0x3F, 0x42, 0x00, 0x21, 0x45 });

            Atr.IndicateProtocol(ProtocolType.T1);
            Assert.That(Atr.Bytes.ToHexString(), Is.EqualTo(new byte[] { 0x3F, 0xC2, 0x00, 0x80, 0x01, 0x21, 0x45, 0x27 }.ToHexString()));
        }
Exemplo n.º 2
0
 public UnknownProtocolParameters(Atr owner, ProtocolType protocolType)
     : base(owner, protocolType, _ => _.Type == (InterfaceByteGroupType)protocolType && _.Number != 2)
     // if not T=0 is indicated, the T=0 specific byte should not be set. In this case, there cannot be protocol specific information
     // coded in this group. This means, the T=x specific protocol indicated here has to be indicated again in a following group if data has to be set
 {
     protocolType.DbC_Assure(value => value != ProtocolType.T0 && value != ProtocolType.T1);
 }
Exemplo n.º 3
0
        /* ISO 7816-4 ch. 8.3 Optional COMPACT-TLV data objects
         * The coding of the COMPACT-TLV data objects is deduced from the basic encoding rules af ASN.1 (see
         * ISO/IEC 8825 and annex D) for BER-TLV data objects with tag='4X' and length='0Y'. The coding of
         * such data objects is replaced by 'XY' followed by 'Y' bytes of data. In this clause, 'X' is
         * referred to as the tag number and 'Y' as the length.
         * Besides the data objects defined in this clause, the historical bytes may contain data objects
         * defined in part 4 of ISO/IEC 7816. In this case the coding of the tags and length fields defined in
         * part 5 shall be modified as above.
         * When COMPACT-TLV data objects defined in this clause appear in the ATR file, they shall be encoded
         * according to the basic encoding rules of ASN.1 (i.e tag='4X', length='0Y').
         * All application-class tags not defined in ISO/IEC 7816 are reserved for ISO.
         *
         * 8.4 Status information
         * If the category indicator is valued to '80', then the status information may be present in a
         * COMPACT-TLV data object. In this case, the tag number is '8'. When the length is '1', then the
         * value is the card life status. When the length is '2', then the value is SW1-SW2. When the length
         * is '3', then the value is the card life status followed by SW1-SW2. Other values of the length are
         * reserved for ISO.
         */
        public AtrCompactTlvHistoricalCharacters(Atr owner)
            : base(owner)
        {
            this.dataObjects = new Dictionary <byte, CompactTlvDataObjectBase>
            {
                { 0x40, new CompactTlvDataObjectRfu(this, 0x40) },
                { 0x41, new CompactTlvDataObjectCountryCode(this) },
                { 0x42, new CompactTlvDataObjectIssuerIdentificationNumber(this) },
                { 0x43, new CompactTlvDataObjectCardServiceData(this) },
                { 0x44, new CompactTlvDataObjectInitialAccessData(this) },
                { 0x45, new CompactTlvDataObjectCardIssuerData(this) },
                { 0x46, new CompactTlvDataObjectPreIssuingData(this) },
                { 0x47, new CompactTlvDataObjectCardCapabilities(this) },
                { 0x48, new CompactTlvDataObjectStatusIndicator(this) },
                { 0x49, new CompactTlvDataObjectRfu(this, 0x49) },
                { 0x4A, new CompactTlvDataObjectRfu(this, 0x4A) },
                { 0x4B, new CompactTlvDataObjectRfu(this, 0x4B) },
                { 0x4C, new CompactTlvDataObjectRfu(this, 0x4C) },
                { 0x4D, new CompactTlvDataObjectRfu(this, 0x4D) },
                { 0x4E, new CompactTlvDataObjectRfu(this, 0x4E) },
                { 0x4F, new CompactTlvDataObjectApplicationIdentifier(this) }
            };

            this.dataObjectsAdapter = this.CreatePropertyAdapter(
                nameof(this.DataObjects),
                () => from DataObject in this.dataObjects.Values where DataObject.IsApplicable select DataObject,
                _ => _
                );
        }
Exemplo n.º 4
0
        public GlobalInterfaceBytes(Atr owner)
            : base(owner, _ => _.Type == InterfaceByteGroupType.Global ||
                   _.Type == InterfaceByteGroupType.GlobalExtended ||
                   _.Number == 2, InterfaceByteGroupType.GlobalExtended)             //Special handling for T?2 group, as it may contain global characters Ta2 and Tb2 and Tc2 is dedicated to T=0

        {
        }
Exemplo n.º 5
0
 internal ProtocolParametersBase(Atr owner, ProtocolType protocolType, Func <AtrInterfaceByteGroupToken, bool> groupTypeSelection)
     : base(owner, groupTypeSelection, (InterfaceByteGroupType)protocolType)
 {
     this.ProtocolType = protocolType;
     this.isOnlyIndicatedProtocolAdapter = this.CreatePropertyAdapter(
         nameof(ProtocolParametersBase.IsOnlyIndicatedProtocol),
         () => this.Owner.ProtocolParameters.Count() == 1
         );
 }
Exemplo n.º 6
0
 public AtrProprietaryHistoricalCharacters(Atr owner)
     : base(owner)
 {
 }
Exemplo n.º 7
0
 protected AtrHistoricalCharactersBase(Atr owner)
 {
     this.owner = owner;
 }
Exemplo n.º 8
0
 public T1ProtocolParameters(Atr owner)
     : base(owner, ProtocolType.T1, _ => _.Type == (InterfaceByteGroupType)ProtocolType.T1 && _.Number != 2)
     // if not T=0 is indicated, the T=0 specific byte should not be set. In this case, there cannot be protocol specific information
     // coded in this group. This means, the T=x specific protocol indicated here has to be indicated again in a following group if data has to be set
 {
 }
Exemplo n.º 9
0
 protected AtrParametersBase(Atr owner, Func <AtrInterfaceByteGroupToken, bool> groupTypeSelection, InterfaceByteGroupType groupType)
 {
     this.Owner = owner;
     this.groupTypeSelection = groupTypeSelection;
     this.groupType          = groupType;
 }
Exemplo n.º 10
0
 public T0ProtocolParameters(Atr owner)
     : base(owner, ProtocolType.T0, _ => _.Type == (InterfaceByteGroupType)ProtocolType.T0)
 {
 }
 public AtrRfuHistoricalCharacters(Atr owner)
     : base(owner)
 {
 }