itu(3) | Library Functions Manual | itu(3) |
itu - standard telecom module
The Standard Telecom module is an original implementation of various standards managed by the International Telecommunictaion Union (ITU). At the heart of this module is the Abstract Syntax Notation (ASN.1) which is widely used to model data records and store certificates.
Abstract syntax notation
The abstract syntax notation (ASN.1) is standardized by the ITU to express a
normal form of communication. The ASN.1 is in fact the de-facto standard for
representing X509 certificate and is the only justification to provide the
support for such complex representation.
Encoding rules
This implementation supports all encoding forms as defined by the ITU, namely
the Basic Encoding Rule (BER), the Canonical Encoding Rule (CER) and the
Distinguished Encoding Rule (DER). The DER form is by far the most widely
used.
ASN objects
All objects as defined by the ITU are supported in this implementation,
including the ability to create custom OID.
Object | Description |
AsnBoolean | Boolean primitive |
AsnInteger | Integer primitive |
AsnBits | Bit string |
AsnOctets | Octet string |
AsnBmp | Bmp string |
AsnIas | IA5 string |
AsnNums | Numeric string |
AsnPrts | Printable string |
AsnUtfs | Unicode string |
AsnUnvs | Universal string |
AsneNull | Null primitive |
AsneEoc | End-of-Content primitive |
AsnGtm | Generalized time primitive |
AsnUtc | Utc time primitive |
AsnSequence | Asn node Sequence |
AsnSet | Asn node Set |
AsnOid | Asn object identifier Set |
AsnRoid | Asn object relative identifier Set |
Using ASN.1 objects
Using ASN.1 object is particularly straightfoward. One can directly creates a
particular object by invoking the appropriate constructor.
# create an asn boolean node trans abn (afnix:itu:AsnBoolean true) # check the node type assert true (afnix:itu:asn-node-p abn) assert true (afnix:itu:asn-boolean-p abn)
Writing the object can be done into a buffer or an output stream. Note that the default encoding is the DER encoding.
# write into a buffer trans buf (Buffer) abn:write buf # check the buffer content assert "0101FF" (buf:format)
Building an ASN.1 representation can be achieved by parsing a buffer or an input stream. This is done by filling a buffer and requesting a buffer node mapping.
# parse the buffer and check const anb (afnix:itu:AsnBuffer buf) # map the node to a boolean trans abn (anb:node-map) # check the node assert true (afnix:itu:asn-node-p abn) assert true (afnix:itu:asn-boolean-p abn)
With more complex structure, it is likely that a sequence object will be returned by the buffer node mapper. Once the sequence object is created, each node can be accessed by index like any other container.
AsnNode
The AsnNode class is the base class used to represent the asn tree. The
structure of the node is defined in ITU-T X.690 recommendation. This
implementation supports 64 bits tag number with natural machine length
encoding. The Canonical Encoding Rule (CER) and Distinguished Encoding Rule
(DER) are defined by the class. Since ASN.1 provides several encoding
schemes, the class is designed to be as generic as possible but does not
provides the mechanism for changing from one representation to another
although it is perfectly valid to read a DER representation and write it in
the CER form.
Predicate
Inheritance
Constants
Methods
AsnOctets
The AsnOctets class is the asn object class that encodes the octet string
type. This type can be encoded either as a primitive or as constructed at
sender's option. In CER form, the primitive form is used when the content
length is less than 1000 octets, and the constructed form is used otherwise.
The DER form will always use the primitive form.
Predicate
Inheritance
Constructors
Methods
AsnBuffer
The AsnBuffer class is the asn object class that provides a generic
implementation of an asn structure. The class acts as a simple encoder and
decoder with special facilities to retarget the buffer content.
Predicate
Inheritance
Constructors
Methods
AsnNull
The AsnNull class is the asn object class that encodes the null primitive.
This primitive has a unique encoding. The length is always 0 and there is no
content octet.
Predicate
Inheritance
Constructors
AsnEoc
The AsnEoc class is the asn object class that encodes the eoc or
end-of-content primitive. This primitive is almost never used but its
encoding is used with the indefinite length encoding.
Predicate
Inheritance
Constructors
AsnBoolean
The AsnBoolean class is the asn object class that encodes the boolean
primitive. This primitive has a unique encoding with the CER or DER rule,
but the BER rule can support any byte value for the true value.
Predicate
Inheritance
Constructors
Methods
AsnInteger
The AsnInteger class is the asn object class that encodes the integer
primitive. This primitive has a unique encoding with the CER or DER rule.
All encoding use a signed 2-complement form.
Predicate
Inheritance
Constructors
Methods
AsnBits
The AsnBits class is the asn object class that encodes the bit string type.
This type can be encoded either as a primitive or as constructed at sender's
option. In CER form, the primitive form is used when the content length is
less than 1000 octets, and the constructed form is used otherwise. The DER
form will always use the primitive form.
Predicate
Inheritance
Constructors
Methods
AsnBmps
The AsnBmps class is the asn object class that encodes the asn bmp string
primitive also known as the UCS-2 type string. This string is implemented,
after conversion as an octet string. Consequently the rules for encoding in
CER and DER modes are applied.
Predicate
Inheritance
Constructors
Methods
AsnIas
The AsnIas class is the asn object class that encodes the IA5 string
primitive. This string is implemented, after conversion as an octet string.
Consequently the rules for encoding in CER and DER modes are applied.
Predicate
Inheritance
Constructors
Methods
AsnNums
The AsnNums class is the asn object class that encodes the asn numeric string
primitive. This string is implemented, after conversion as an octet string.
Consequently the rules for encoding in CER and DER modes are applied.
Predicate
Inheritance
Constructors
Methods
AsnPrts
The AsnPrts class is the asn object class that encodes the asn printable
string primitive. This string is implemented, after conversion as an octet
string. Consequently the rules for encoding in CER and DER modes are
applied.
Predicate
Inheritance
Constructors
Methods
AsnUtfs
The AsnUtfs class is the asn object class that encodes the asn utf string
primitive. This string is implemented as an octet string. Consequently the
rules for encoding in CER and DER modes are applied.
Predicate
Inheritance
Constructors
Methods
AsnUnvs
The AsnUnvs class is the asn object class that encodes the universal string
primitive also known as the UCS-4 type string. This string is implemented,
after conversion as an octet string. Consequently the rules for encoding in
CER and DER modes are applied.
Predicate
Inheritance
Constructors
Methods
AsnGtm
The AsnGtm class is the asn object class that encodes the generalized time
primitive. This primitive is encoded from its equivalent string
representation. Although, the constructed mode is authorized, it does not
make that much sense to use it.
Predicate
Inheritance
Constructors
Methods
AsnUtc
The AsnUtc class is the asn object class that encodes the utc time primitive.
This primitive is encoding from its equivalent string representation.
Although, the constructed mode is authorized, it does not make that much
sense to use it.
Predicate
Inheritance
Constructors
Methods
AsnSequence
The AsnSequence class is the asn object class that encodes the sequence
constructed type. The order of elements is preserved in the encoding of the
sequence.
Predicate
Inheritance
Constructors
Methods
AsnSet
The AsnSet class is the asn object class that encodes the set constructed
type. The order of elements is not important in a set.
Predicate
Inheritance
Constructors
Methods
Oid
The Oid class is a base class that represents the X500 object identifier which
is used in the ASN.1 encoding and in the X509 standard. An oid is simply
represented by a vector of subidentifiers.
Predicate
Inheritance
Constructors
Methods
AsnOid
The AsnOid class is the asn object class that encodes the object identifier
primitive. This primitive has a unique encoding with the CER or DER rule.
The oid is built as a vector of subidentifiers (sid). Each sid is
represented as an octa (64 bits) value.
Predicate
Inheritance
Constructors
Methods
AsnRoid
The AsnRoid class is the asn object class that encodes the object relative
identifier primitive. This primitive has a unique encoding with the CER or
DER rule. The oid is built as a vector of subidentifiers (sid). Each sid is
represented as an octa (64 bits) value. The difference with the oid object
is to be found in the encoding of the first 2 sid.
Predicate
Inheritance
Constructors
Methods
Functions
AFNIX | AFNIX Module |