public static TLV Create(byte[] rawTLV, ref int pos) { TLV tlv = new TLV(); pos = tlv.Deserialize(rawTLV, pos); return(tlv); }
public virtual TLV Clone() { TLV clone = new TLV(); clone.Deserialize(Serialize(), 0); return(clone); }
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); }