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 |
ASN1 - Reference DocumentationImplementation of support for ASN.1 data structures using DER encoding rule Index of Methods
Constants
Properties
ConstructorPrototypeASN1(Number tag) ASN1(Number tag, ByteString value) ASN1(Number tag, ASN1 object*) ASN1(ByteString encoded) ASN1(String name, Number tag) ASN1(String name, Number tag, ByteString value) ASN1(String name, Number tag, ASN1 object*) ASN1(String name, ByteString encoded) DescriptionCreate an ASN.1 object, either primitive or constructed. The constructor without a value or with a list of TLV objects will create a constructed object, which can be further completed using the add() method. The constructor with a value field will create a primitive, immutuable objectArguments
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); assert(t instanceof ASN1); assert(t.tag == ASN1.SEQUENCE); assert(t.length == 0); assert(t.value.toString(HEX) == ""); assert(t.tagclass == ASN1.UNIVERSAL); assert(t.tagnumber == 16); assert(t.isconstructed); assert(t.size == 2); assert(t.elements == 0); t = new ASN1("singleSequence", ASN1.SEQUENCE); print(t); t = new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX)); assert(t instanceof ASN1); assert(t.tag == ASN1.OBJECT_IDENTIFIER); assert(t.length == 3); assert(t.value.toString(HEX) == "2A1200"); assert(t.tagclass == ASN1.UNIVERSAL); assert(t.tagnumber == 6); assert(!t.isconstructed); assert(t.size == 5); t = new ASN1("objectIdentifier", ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX)); print(t); t = new ASN1(new ByteString("06022A11", HEX)); assert(t instanceof ASN1); assert(t.tag == ASN1.OBJECT_IDENTIFIER); assert(t.length == 2); assert(t.value.toString(HEX) == "2A11"); assert(t.tagclass == ASN1.UNIVERSAL); assert(t.tagnumber == 6); assert(!t.isconstructed); assert(t.size == 4); t = new ASN1("fromByteString", new ByteString("06022A11", HEX)); print(t); t = new ASN1(ASN1.SEQUENCE, new ASN1(ASN1.OCTET_STRING, new ByteString("Hello World", ASCII)), new ASN1(ASN1.GeneralizedTime, new ByteString("20051010120000Z", ASCII))); assert(t instanceof ASN1); assert(t.tag == ASN1.SEQUENCE); assert(t.elements == 2); assert(t.tagclass == ASN1.UNIVERSAL); assert(t.tagnumber == 16); assert(t.isconstructed); assert(t.size == 32); t = new ASN1("complexSequence", ASN1.SEQUENCE, new ASN1(ASN1.OCTET_STRING, new ByteString("Hello World", ASCII)), new ASN1(ASN1.GeneralizedTime, new ByteString("20051010120000Z", ASCII))); print(t); root = new X509("root.cer"); bs = root.getBytes(); print(bs); t = new ASN1(bs); assert(t instanceof ASN1); print(t); add()PrototypeASN1 add(ASN1 object*) ASN1 add(Number index, ASN1 object*) DescriptionAdd one or more ASN.1 objects to a constructed object at index or at the end.Arguments
Return
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX)), new ASN1(ASN1.PrintableString, new ByteString("Hello World", ASCII))); t.add(0, new ASN1(ASN1.INTEGER, new ByteString("01", HEX))); get()PrototypeASN1 get(Number index) DescriptionGet ASN.1 object at zero based index from constructed object. This method does not provide a copy of the element, but a reference to it. Changes to the element will have an effect in parent objects or other instances obtained with the get() method Arguments
Return
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); t.add(new ASN1(ASN1.OCTET_STRING, new ByteString("ÄÖÜ", UTF8))); n = t.get(0); assert(n instanceof ASN1); assert(n.tag == ASN1.OBJECT_IDENTIFIER); assert(n.length == 3); n = t.get(1); assert(n instanceof ASN1); assert(n.tag == ASN1.OCTET_STRING); assert(n.length == 6); find()PrototypeASN1 find(Number tag) ASN1 find(Number tag, Number index) ASN1 find(Number tag, ASN1 cursor) DescriptionFind ASN1 object with matching tag. The method can be called with an object after which the search will start. The constant value null indicates the beginning of the list. This method does not provide a copy of the element, but a reference to it. Changes to the element will have an effect in parent objects or other instances obtained with the get() method Arguments
Return
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); t.add(new ASN1(ASN1.OCTET_STRING, new ByteString("ÄÖÜ", UTF8))); t.add(new ASN1(ASN1.INTEGER, new ByteString("00", HEX))); t.add(new ASN1(ASN1.INTEGER, new ByteString("0000", HEX))); n = t.find(ASN1.OBJECT_IDENTIFIER); assert(n instanceof ASN1); assert(n.tag == ASN1.OBJECT_IDENTIFIER); n = t.find(ASN1.INTEGER); assert(n instanceof ASN1); assert(n.tag == ASN1.INTEGER); assert(n.length == 1); n = t.find(ASN1.INTEGER, n); assert(n instanceof ASN1); assert(n.tag == ASN1.INTEGER); assert(n.length == 2); n = t.find(ASN1.INTEGER, n); assert(n == null); n = t.find(ASN1.OBJECT_IDENTIFIER, n); assert(n instanceof ASN1); assert(n.tag == ASN1.OBJECT_IDENTIFIER); n = t.find(ASN1.INTEGER, 1); assert(n instanceof ASN1); assert(n.tag == ASN1.INTEGER); assert(n.length == 1); n = t.find(ASN1.INTEGER, 3); assert(n instanceof ASN1); assert(n.tag == ASN1.INTEGER); assert(n.length == 2); n = t.find(ASN1.OBJECT_IDENTIFIER, 0); assert(n instanceof ASN1); assert(n.tag == ASN1.OBJECT_IDENTIFIER); remove()Prototypevoid remove(Number index) DescriptionRemove ASN.1 object at zero based index from constructed object. Arguments
Return
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); t.add(new ASN1(ASN1.OCTET_STRING, new ByteString("ÄÖÜ", UTF8))); t.remove(0); n = t.get(0); assert(n instanceof ASN1); assert(n.tag == ASN1.OCTET_STRING); assert(n.length == 6); getBytes()PrototypeByteString getBytes() DescriptionReturn the DER encoded ASN.1 objectReturn
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); assert(t.getBytes().toString(HEX) == "300506032A1200"); getDate()PrototypeDate getDate() DescriptionReturn the value field of a primitive ASN.1 object as a date. This usually works for for GeneralizedTime objects which store date and time in ISO8601 format.Return
Exceptions
Example// Local time t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929113422", ASCII)); d = t.getDate(); print(d); assert(d.toString().substr(0,24) == "Thu Sep 29 2005 11:34:22"); // UTC time t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929113422Z", ASCII)); d = t.getDate(); assert(d.getTime() == 1127993662000); // CEST time t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929133422+0200", ASCII)); d = t.getDate(); assert(d.getTime() == 1127993662000); // Local time with millisecond t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929113422.1", ASCII)); d = t.getDate(); assert(d.toString().substr(0,24) == "Thu Sep 29 2005 11:34:22"); // UTC time with millisecond t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929113422.1Z", ASCII)); d = t.getDate(); assert(d.getTime() == 1127993662001); // CEST time with millisecond t = new ASN1(ASN1.GeneralizedTime, new ByteString("20050929133422.1+0200", ASCII)); d = t.getDate(); assert(d.getTime() == 1127993662001); setName()PrototypesetName(String name) DescriptionAssign a name to the ASN.1 object.Return
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.setName("testObject"); print(t.toString()); ASN1.defineObjectIdentifier()PrototypedefineObjectIdentifier(String name, String definition) DescriptionAdd a definition for a symbolic object identifier to the internal registry. The definition may be recursive and can use the dotted or spaced format. Return
Exceptions
ExampleASN1.defineObjectIdentifier("openscdp-test", "1.3.6.1.4.1.24991.0"); ASN1.defineObjectIdentifier("openscdp-test-sub1", "openscdp-test.4"); ASN1.defineObjectIdentifier("openscdp-test-sub2", "openscdp-test branch(5)"); var b = new ByteString("openscdp-test-sub2", OID); print(b); assert(b.toString(OID) == "1.3.6.1.4.1.24991.0.5"); toString()PrototypeString toString() DescriptionDump the contents of the ASN.1 objectReturn
Exceptions
Examplet = new ASN1(ASN1.SEQUENCE); t.add(new ASN1(ASN1.OBJECT_IDENTIFIER, new ByteString("2A1200", HEX))); print(t.toString()); © Copyright 2003 - 2010 CardContact Software & System Consulting, Minden, Germany |