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 |
TLV - Reference DocumentationImplementation of an immutable TLV object with different encoding formats. Index of MethodsConstants
Properties
ConstructorPrototypeTLV(Number tag, ByteString value, Number encoding) DescriptionCreate a TLV object initialized with the arguments given. TLV objects are composed of a tag, a length and a value field. The binary encoding format for the tag and length can be defined with the encoding parameter. 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
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.encodingMode == TLV.EMV); assert(t.size == 5); t = new TLV(0x0601, new ByteString("2A1234", HEX), TLV.EMV); assert(t.encodingMode == TLV.EMV); assert(t.size == 6); try { // Invalid tag for EMV t = new TLV(0x6FFFFF, new ByteString("2A1234", HEX), TLV.EMV); } catch (e) { assert(e instanceof GPError); } t = new TLV(0x1201, new ByteString("561000", ASCII), TLV.DGI); assert(t.encodingMode == TLV.DGI); assert(t.size == 9); t = new TLV(0x12, new ByteString("561000", ASCII), TLV.DGI); assert(t.encodingMode == TLV.DGI); assert(t.size == 9); t = new TLV(0x3221, new ByteString("123456", HEX), TLV.L16); assert(t.encodingMode == TLV.L16); assert(t.size == 7); t = new TLV(0x32, new ByteString("123456", HEX), TLV.L16); assert(t.encodingMode == TLV.L16); assert(t.size == 7); getL()PrototypeByteString getL() DescriptionReturn the value of the length field of the TLV object.Return
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.getL().toString(HEX) == "03"); // 130 bytes t = new TLV(0x06, new ByteString("00010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809", HEX), TLV.EMV); assert(t.getL().toString(HEX) == "8182"); // 260 bytes t = new TLV(0x06, new ByteString("0001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809", HEX), TLV.EMV); assert(t.getL().toString(HEX) == "820104"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.L16); assert(t.getL().toString(HEX) == "0003"); t = new TLV(0x06, new ByteString("0001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809", HEX), TLV.L16); assert(t.getL().toString(HEX) == "0104"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.DGI); assert(t.getL().toString(HEX) == "03"); t = new TLV(0x06, new ByteString("0001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809000102030405060708090001020304050607080900010203040506070809", HEX), TLV.DGI); assert(t.getL().toString(HEX) == "FF0104"); getLV()PrototypeByteString getLV() DescriptionReturn the combined length and value field of the objectReturn
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.getLV().toString(HEX) == "032A1234"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.L16); assert(t.getLV().toString(HEX) == "00032A1234"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.DGI); assert(t.getLV().toString(HEX) == "032A1234"); getTag()PrototypeNumber getTag() DescriptionReturn the value of the tag field as numeric value-Return
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(typeof(t.getTag()) == "number"); assert(t.getTag() == 0x06); t = new TLV(0x9F03, new ByteString("2A1234", HEX), TLV.EMV); assert(typeof(t.getTag()) == "number"); assert(t.getTag() == 0x9F03); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.L16); assert(t.getTag() == 0x06); t = new TLV(0x061F, new ByteString("2A1234", HEX), TLV.DGI); assert(t.getTag() == 0x061F); getTLV()PrototypeByteString getTLV() DescriptionReturn the concatenation of tag, length and value as a sequence of byte using the encoding mode specified in the constructorReturn
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.getTLV().toString(HEX) == "06032A1234"); t = new TLV(0x1201, new ByteString("561000", ASCII), TLV.DGI); assert(t.getTLV().toString(HEX) == "120106353631303030"); t = new TLV(0x3221, new ByteString("123456", HEX), TLV.L16); assert(t.getTLV().toString(HEX) == "32210003123456"); getTV()PrototypeByteString getTV() DescriptionReturn the field tag and value of the TLV in the specified encoding format.Return
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.getTV().toString(HEX) == "062A1234"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.L16); assert(t.getTV().toString(HEX) == "00062A1234"); t = new TLV(0x061F, new ByteString("2A1234", HEX), TLV.DGI); assert(t.getTV().toString(HEX) == "061F2A1234"); getValue()PrototypeByteString getValue() DescriptionReturn the value field of the TLV objectReturn
Exceptions
Examplet = new TLV(0x06, new ByteString("2A1234", HEX), TLV.EMV); assert(t.getValue().toString(HEX) == "2A1234"); t = new TLV(0x06, new ByteString("2A1234", HEX), TLV.L16); assert(t.getValue().toString(HEX) == "2A1234"); t = new TLV(0x061F, new ByteString("2A1234", HEX), TLV.DGI); assert(t.getValue().toString(HEX) == "2A1234"); © Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany |