SSE4E GPError GPSystem ByteString ByteBuffer TLV TLVList Card Atr Key Crypto Application GPApplication GPSecDomain ASN1 CardFile IsoSecureChannel ApplFactory GPXML JsScript CardSim X509 CRL KeyStore CMSSignedData CMSGenerator XMLSignature OCSPQuery LDAP SOAP URLConnection PKCS11Provider PKCS11Session PKCS11Object OutlineNode OpenSCDP |
TLVList - Reference DocumentationImplementation of a mutable TLV object list. Index of Methods
Properties
ConstructorPrototypeTLVList(ByteString tlvStream, Number encoding) DescriptionCreate a TLV list object initialized with the tlv objects encoded within the given ByteString object. For EMV encoding the tag field has a variable length of up to 4 bytes. The length field has a variable length of up to 4 byte. Both fields are encoded as specified as per ASN.1 Basic Encoding Rule (ISO 8825). For DGI encoding the tag field has a fixed length of two bytes. The length field contains one byte for values between 0 and 254. The length is encoded in three bytes for values between 255 and 65535, with the first byte set to 'FF'. For L16 encoding the tag field has a fixed length of two bytes. The length field is always two byte long and is encoded in big endian / little endian format. Arguments
Exceptions
Example// EMV data = new ByteString("61050102030405620100630A00010203040506070809", HEX); // Create a TLV list list = new TLVList(data, TLV.EMV); assert(list.length == 3); // Create a TLV list with "illegal" ASN.1 DER encoding list = new TLVList(new ByteString("9f030100", HEX), TLV.EMV); assert(list.length == 1); // DGI data = new ByteString("7F1F05010203040500630A00010203040506070809", HEX); list = new TLVList(data, TLV.DGI); assert(list.length == 2); // L16 data = new ByteString("7F1F000501020304050063000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); index()PrototypeTLV index(Number index) DescriptionReturns a TLV object which represents the TLV stored within the TLVList at the given index. The index is zero based.Arguments
Return
Exceptions
Example// EMV data = new ByteString("610501020304056201008E0A00010203040506070809", HEX); // Create a TLV list list = new TLVList(data, TLV.EMV); assert(list.length == 3); tag_61 = list.index(0); assert(tag_61 != null); assert(tag_61.getTag() == 0x61); tag_62 = list.index(1); assert(tag_62 != null); assert(tag_62.getTag() == 0x62); tag_8e = list.index(2); assert(tag_8e != null); assert(tag_8e.getTag() == 0x8E); // Invalid index try { tag = list.index(10); } catch (e) { assert(e instanceof GPError); } // Check various EMV length encodings data = new ByteString("6181050102030405", HEX); list = new TLVList(data, TLV.EMV); tlv = list.index(0); assert(tlv.getTag() == 0x61); assert(tlv.getValue().length == 5); assert(tlv.getValue().toString(HEX) == "0102030405"); data = new ByteString("618200050102030405", HEX); list = new TLVList(data, TLV.EMV); tlv = list.index(0); assert(tlv.getTag() == 0x61); assert(tlv.getValue().length == 5); assert(tlv.getValue().toString(HEX) == "0102030405"); append()Prototypeappend(ByteString tlvStream) append(Number tag, ByteString value) append(TLV tlv) DescriptionAppends the specified TLV data to the end of the existing list of TLV objects.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F00050102030405", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 1); // append(Number, Value) list.append(0x63, new ByteString("00010203040506070809", HEX)); assert(list.length == 2); // append(ByteString) list.append(new ByteString("0061000A00010203040506070809", HEX)); assert(list.length == 3); // append(TLV) t = new TLV(0x3221, new ByteString("123456", HEX), TLV.L16); list.append(t); assert(list.length == 4); // try to append an invalid type try { list.append("HALLO"); } catch (e) { assert(e instanceof GPError); } // try to append a tag with an already existing tag number try { t = new TLV(0x3221, new ByteString("123456", HEX), TLV.L16); list.append(t); } catch (e) { assert(e instanceof GPError); } appendValue()PrototypeappendValue(Number tag, ByteString value) DescriptionAppends the data to the existing data for the specified tag.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F00050102030405", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 1); // appendValue(Number, Value) list.appendValue(0x7F1F, new ByteString("06070809", HEX)); tlv = list.index(0); assert(tlv.getValue().toString(HEX) == "010203040506070809"); appendValueIndex()PrototypeappendValueIndex(Number index, ByteString value) DescriptionAppends the data to the existing data for the specified zero-based index into the TLVStream.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F00050102030405", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 1); // appendValueIndex(Number, Value) list.appendValueIndex(0, new ByteString("06070809", HEX)); tlv = list.index(0); assert(tlv.getValue().toString(HEX) == "010203040506070809"); deleteByIndex()PrototypedeleteByIndex(Number index) DescriptionDelete the specified TLV from the list using a zero based index.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F000501020304050061000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); // deleteByIndex(Number) list.deleteByIndex(0); assert(list.length == 1); tlv = list.index(0); assert(tlv.getTLV().toString(HEX) == "0061000A00010203040506070809"); deleteByTag()PrototypedeleteByTag(Number tag) DescriptionDelete the specified TLV from the list by tag value.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F000501020304050061000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); // deleteByTag(Number) list.deleteByTag(0x7F1F); assert(list.length == 1); tlv = list.index(0); assert(tlv.getTLV().toString(HEX) == "0061000A00010203040506070809"); findIndex()PrototypeNumber findIndex(Number tag) DescriptionSearches the list for a specified tag, and returns a zero based index for that TLV.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F000501020304050061000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); index_tag_61 = list.findIndex(0x61); assert(typeof(index_tag_61) == "number"); assert(index_tag_61 == 1); index_tag_63 = list.findIndex(0x63); assert(index_tag_63 == -1); find()PrototypeTLV find(Number tag) DescriptionSearches the list for a specified tag, and returns a TLV object.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F000501020304050061000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); tag_61 = list.find(0x61); assert(tag_61 != null); tag_63 = list.find(0x63); assert(tag_63 == null); updateValue()PrototypeupdateValue(Number tag, ByteString value) DescriptionUpdates the data for the specified tag.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F00050102030405", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 1); // appendValue(Number, Value) list.updateValue(0x7F1F, new ByteString("06070809", HEX)); tlv = list.index(0); assert(tlv.getValue().toString(HEX) == "06070809"); updateValueIndex()PrototypeupdateValueIndex(Number index, ByteString value) DescriptionUpdates the data for the specified zero-based index into the TLVStream.Arguments
Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F00050102030405", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 1); // appendValueIndex(Number, Value) list.updateValueIndex(0, new ByteString("06070809", HEX)); tlv = list.index(0); assert(tlv.getValue().toString(HEX) == "06070809"); toByteString()PrototypeByteString toByteString() DescriptionReturns the contents of the entire list, including T, L and V values in a TLV format as a ByteString object.Return
Exceptions
Example// L16 encoded data data = new ByteString("7F1F000501020304050061000A00010203040506070809", HEX); list = new TLVList(data, TLV.L16); assert(list.length == 2); t = list.toByteString(); assert(t != null); assert(t.toString() == data.toString()); © Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany |