Exemple #1
0
        public override int Deserialize(string rawTlv, int pos)
        {
            if (rawTlv.Length == 0)
            {
                return(0);
            }

            children = new QRDEList();

            Tag        = (TagId)GetEnum(typeof(TagId), Convert.ToInt16(rawTlv.Substring(pos, 2)));
            pos        = pos + 2;
            Length     = Convert.ToInt16(rawTlv.Substring(pos, 2));
            pos        = pos + 2;
            Value      = rawTlv.Substring(pos, Length);
            pos        = pos + Length;
            IsTemplate = QRMetaDataSourceSingleton.Instance.DataSource.IsTemplate(Tag, TagParent);
            //DataFormatterBase formatter = QRMetaDataSourceSingleton.Instance.DataSource.GetFormatter(Tag, TagParent);
            if (IsTemplate)
            {
                for (int i = 0; i < Value.Length;)
                {
                    QRDE child = new QRDE
                    {
                        TagParent = Tag
                    };
                    i = child.Deserialize(Value, i);
                    Children.AddToList(child);
                }
            }
            return(pos);
        }
 private void AddTTL(EMVTagMeta tag, KernelDatabaseBase database)
 {
     if (database.IsNotEmpty(tag.Tag))
     {
         Children.AddToList(TLV.Create(tag.Tag, database.Get(tag).Value));
     }
 }
Exemple #3
0
        public override int Deserialize(byte[] rawTlv, int pos)
        {
            if (rawTlv.Length == 0)
            {
                return(0);
            }

            children = new TLVList();

            //some byte streams may have FF padding between tags ??
            while (rawTlv[pos] == 0xFF)
            {
                pos++;
            }

            Tag = new T();
            pos = Tag.Deserialize(rawTlv, pos);
            Val = new V(TLVMetaDataSourceSingleton.Instance.DataSource.GetFormatter(Tag.TagLable));
            pos = Val.Deserialize(rawTlv, pos);

            if (Tag.IsConstructed)
            {
                for (int i = 0; i < Value.Length;)
                {
                    TLV child = new TLV();
                    i = child.Deserialize(Value, i);
                    //TODO: Dont like this...had to change AddToList to allow duplicates, previously if a item in the list already existed its
                    //value was replaced, some cards may return blocks of 0x00 bytes
                    //in their read record byte streams, this is not valid TLV but we have to cater for it
                    //the TLV class sees a tag of 00 with length of 00 and so on, we add the 00 tags and allow duplicates so that when things
                    //like static data for authentication is calcaulted the dups are serialized back into the origional
                    //blocks of 0x00, since the card has included this invalid data in its signature!!
                    //this should change, probably include the 0x00 blocks as some sort of custom padding tag, and switch dups back off?
                    Children.AddToList(child, true);
                }
            }
            return(pos);
        }