|
ActiveTcl User Guide
|
|
|
[ Main table Of Contents | Tcllib Table Of Contents | Tcllib Index ]
asn(n) 0.1 "ASN.1"
asn - ASN.1 BER encoder/decoder
TABLE OF
CONTENTS
SYNOPSIS
DESCRIPTION
PUBLIC API
ENCODER
DECODER
EXAMPLES
KEYWORDS
COPYRIGHT
package require Tcl 8.2
package require asn ?0.2?
The asn package provides partial de-
and encoder commands for BER encoded ASN.1 data.
ASN.1 is a standard Abstract Syntax Notation, and BER
are its Basic Encoding Rules.
See http://asn1.elibel.tm.fr/en/standards/index.htm
for more information about the standard.
Also see http://luca.ntop.org/Teaching/Appunti/asn1.html
for A Layman's Guide to a Subset of ASN.1, BER, and DER,
an RSA Laboratories Technical Note by Burton S. Kaliski Jr.
(Revised November 1, 1993). A text version of this note is part of
the module sources and should be read by any implementor.
- ::asn::asnSequence evalue...
- Takes zero or more encoded values, packs them into an ASN
sequence and returns its encoded binary form.
- ::asn::asnSet evalue...
- Takes zero or more encoded values, packs them into an ASN set
and returns its encoded binary form.
- ::asn::asnApplicationConstr appNumber evalue...
- Takes zero or more encoded values, packs them into an ASN
application construct and returns its encoded binary form.
- ::asn::asnApplication appNumber data
- Takes a single encoded value data, packs it
into an ASN application construct and returns its encoded binary
form.
- ::asn::asnChoice appNumber evalue...
- Takes zero or more encoded values, packs them into an ASN
choice construct and returns its encoded binary form.
- ::asn::asnChoiceConstr appNumber evalue...
- Takes zero or more encoded values, packs them into an ASN
choice construct and returns its encoded binary form.
- ::asn::asnInteger number
- Returns the encoded form of the specified integer number.
- ::asn::asnEnumeration number
- Returns the encoded form of the specified enumeration id number.
- ::asn::asnBoolean bool
- Returns the encoded form of the specified boolean value bool.
- ::asn::asnOctetString string
- Returns the encoded form of the specified string.
General notes:
- All decoder commands take two arguments. These arguments are
variable names, except for ::asn::asnGetResponse. The first variable contains the
encoded ASN value to decode at the beginning, and more, and the
second variable is where the value is stored to. The remainder of
the input after the decoded value is stored back into the
datavariable.
- After extraction the data variable is always modified first,
before by writing the extracted value to its variable. This means
that if both arguments refer to the same variable, it will always
contain the extracted value after the call, and not the remainder
of the input.
- ::asn::asnGetResponse chan data_var
- Reads an encoded ASN sequence from the channel chan and stores it into the variable named by data_var.
- ::asn::asnGetInteger data_var int_var
- Assumes that an encoded integer value is at the front of the
data stored in the variable named data_var,
extracts and stores it into the variable named by int_var. Additionally removes all bytes associated with
the value from the data for further processing by the following
decoder commands.
- ::asn::asnGetEnumeration data_var enum_var
- Assumes that an enumeration id is at the front of the data
stored in the variable named data_var, and
stores it into the variable named by enum_var.
Additionally removes all bytes associated with the value from the
data for further processing by the following decoder commands.
- ::asn::asnGetOctetString data_var string_var
- Assumes that a string is at the front of the data stored in the
variable named data_var, and stores it into the
variable named by string_var. Additionally
removes all bytes associated with the value from the data for
further processing by the following decoder commands.
- ::asn::asnGetPrintableString data_var string_var
- Assumes that a printable string value is at the front of the
data stored in the variable named data_var, and
stores it into the variable named by string_var.
Additionally removes all bytes associated with the value from the
data for further processing by the following decoder commands.
- ::asn::asnGetIA5String data_var string_var
- Assumes that a IA5 (ASCII) string value is at the front of the
data stored in the variable named data_var, and
stores it into the variable named by string_var.
Additionally removes all bytes associated with the value from the
data for further processing by the following decoder commands.
- ::asn::asnGetUTCTime data_var utc_var
- Assumes that a UTC time value is at the front of the data
stored in the variable named data_var, and
stores it into the variable named by utc_var.
The UTC time value is stored as a string, which has to be decoded
with the usual clock scan commands. Additionally removes all bytes
associated with the value from the data for further processing by
the following decoder commands.
- ::asn::asnGetBitString data_var bits_var
- Assumes that a bit string value is at the front of the data
stored in the variable named data_var, and
stores it into the variable named by bits_var as
a string containing only 0 and 1. Additionally removes all bytes
associated with the value from the data for further processing by
the following decoder commands.
- ::asn::asnGetObjectIdentifier
data_var oid_var
- Assumes that a object identifier (OID) value is at the front of
the data stored in the variable named data_var,
and stores it into the variable named by oid_var
as a list of integers. Additionally removes all bytes associated
with the value from the data for further processing by the
following decoder commands.
- ::asn::asnGetBoolean data_var bool_var
- Assumes that a boolean value is at the front of the data stored
in the variable named data_var, and stores it
into the variable named by bool_var.
Additionally removes all bytes associated with the value from the
data for further processing by the following decoder commands.
- ::asn::asnGetNull data_var
- Assumes that a NULL value is at the front of the data stored in
the variable named data_var and removes the
bytes used to encode it from the data.
- ::asn::asnGetSequence data_var sequence_var
- Assumes that an ASN sequence is at the front of the data stored
in the variable named data_var, and stores it
into the variable named by sequence_var.
Additionally removes all bytes associated with the value from the
data for further processing by the following decoder commands.
The data in sequence_var is encoded binary and
has to be further decoded according to the definition of the
sequence, using the decoder commands here.
- ::asn::asnGetSet data_var set_var
- Assumes that an ASN set is at the front of the data stored in
the variable named data_var, and stores it into
the variable named by set_var. Additionally
removes all bytes associated with the value from the data for
further processing by the following decoder commands.
The data in set_var is encoded binary and has
to be further decoded according to the definition of the set, using
the decoder commands here.
- ::asn::asnGetApplication data_var appNumber_var
- Assumes that an ASN application construct is at the front of
the data stored in the variable named data_var,
and stores its id into the variable named by appNumber_var. Additionally removes all bytes associated
with the value from the data for further processing by the
following decoder commands.
It is the responsibility of the caller to decode the remainder of
the application construct based on the id retrieved by this
command, using the decoder commands here.
- ::asn::asnGetContext data_var contextNumber_var
- Assumes that an ASN context tag construct is at the front of
the data stored in the variable named data_var,
and stores its id into the variable named by contextNumber_var. Additionally removes all bytes
associated with the value from the data for further processing by
the following decoder commands.
It is the responsibility of the caller to decode the remainder of
the construct based on the id retrieved by this command, using the
decoder commands here.
Examples for the usage of this package can be found in the
implementation of package ldap.
asn , ber , cer , der , internet , protocol , x.208 , x.209
Copyright © 2004 Andreas Kupries
<andreas_kupries@users.sourceforge.net>
Copyright © 2004 Jochen Loewer <loewerj@web.de>
Copyright © 2004 Michael Schlenker
<mic42@users.sourceforge.net>