Home page logo
/
Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News

Sponsors


Library asn1.encoder

ASN.1 functions.

Large chunks of this code have been ripped right out from snmp.lua.

Author:
Patrik Karlsson

Copyright© Same as Nmap--See http://nmap.org/book/man-legal.html

Source: http://nmap.org/svn/nselib/asn1.encoder.lua

Functions

ASN1Decoder.decode (self, encStr, pos)

Decodes the ASN.1's built-in simple types

ASN1Decoder.decodeInt (encStr, len, pos)

Decodes an Integer according to ASN.1 basic encoding rules.

ASN1Decoder.decodeLength (encStr, pos)

Decodes length part of encoded value according to ASN.1 basic encoding rules.

ASN1Decoder.decodeOID (self, encStr, len, pos)

Decodes an OID from a sequence of bytes.

ASN1Decoder.decodeSeq (self, encStr, len, pos)

Decodes a sequence according to ASN.1 basic encoding rules.

ASN1Decoder.registerBaseDecoders (self)

Registers the base simple type decoders

ASN1Decoder.registerTagDecoders (self, tagDecoders)

Allows for registration of additional tag decoders

ASN1Decoder.registerTagEncoders (self, tagEncoders)

Allows for registration of additional tag encoders

ASN1Decoder.setStopOnError (self, val)

Tells the decoder to stop if it detects an error while decoding.

ASN1Encoder.encode (self, val)

Encodes a given value according to ASN.1 basic encoding rules for SNMP packet creation.

ASN1Encoder.encodeInt (val)

Encodes an Integer according to ASN.1 basic encoding rules.

ASN1Encoder.encodeLength (len)

Encodes the length part of a ASN.1 encoding triplet using the "primitive, definite-length" method.

ASN1Encoder.encodeSeq (self, seqData)

Encodes an ASN1 sequence

ASN1Encoder.registerBaseEncoders (self)

Registers the base ASN.1 Simple types encoders

BERtoInt (class, constructed, number)

Converts a BER encoded type to a numeric value

intToBER (i)

Converts an integer to a BER encoded type table

Tables

tagDecoders

Table for registering additional tag decoders.

tagEncoders

Table for registering additional tag encoders.



Functions

ASN1Decoder.decode (self, encStr, pos)

Decodes the ASN.1's built-in simple types

Parameters

  • self:
  • encStr: Encoded string.
  • pos: Current position in the string.

Return values:

  1. The position after decoding
  2. The decoded value(s).
ASN1Decoder.decodeInt (encStr, len, pos)

Decodes an Integer according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • len: Length of integer in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The decoded integer.
ASN1Decoder.decodeLength (encStr, pos)

Decodes length part of encoded value according to ASN.1 basic encoding rules.

Parameters

  • encStr: Encoded string.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The length of the following value.
ASN1Decoder.decodeOID (self, encStr, len, pos)

Decodes an OID from a sequence of bytes.

Parameters

  • self:
  • encStr: Encoded string.
  • len: Length of sequence in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The OID as an array.
ASN1Decoder.decodeSeq (self, encStr, len, pos)

Decodes a sequence according to ASN.1 basic encoding rules.

Parameters

  • self:
  • encStr: Encoded string.
  • len: Length of sequence in bytes.
  • pos: Current position in the string.

Return values:

  1. The position after decoding.
  2. The decoded sequence as a table.
ASN1Decoder.registerBaseDecoders (self)

Registers the base simple type decoders

Parameters

  • self:
ASN1Decoder.registerTagDecoders (self, tagDecoders)

Allows for registration of additional tag decoders

Parameters

  • self:
  • tagDecoders: table containing decoding functions

See also:

ASN1Decoder.registerTagEncoders (self, tagEncoders)

Allows for registration of additional tag encoders

Parameters

  • self:
  • tagEncoders: table containing encoding functions

See also:

ASN1Decoder.setStopOnError (self, val)

Tells the decoder to stop if it detects an error while decoding.

This should probably be the default, but some scripts depend on being able to decode stuff while lacking proper ASN1 decoding functions.

Parameters

  • self:
  • val: boolean, true if decoding should stop on error, otherwise false (default)
ASN1Encoder.encode (self, val)

Encodes a given value according to ASN.1 basic encoding rules for SNMP packet creation.

Parameters

  • self:
  • val: Value to be encoded.

Return value:

Encoded value.
ASN1Encoder.encodeInt (val)

Encodes an Integer according to ASN.1 basic encoding rules.

Parameters

  • val: Value to be encoded.

Return value:

Encoded integer.
ASN1Encoder.encodeLength (len)

Encodes the length part of a ASN.1 encoding triplet using the "primitive, definite-length" method.

Parameters

  • len: Length to be encoded.

Return value:

Encoded length value.
ASN1Encoder.encodeSeq (self, seqData)

Encodes an ASN1 sequence

Parameters

  • self:
  • seqData: A string of sequence data

Return value:

ASN.1 BER-encoded sequence
ASN1Encoder.registerBaseEncoders (self)

Registers the base ASN.1 Simple types encoders

  • boolean
  • integer (Lua number)
  • string
  • null (Lua nil)

Parameters

  • self:
BERtoInt (class, constructed, number)

Converts a BER encoded type to a numeric value

This allows it to be used in the encoding function

Parameters

  • class: number - see <code>BERCLASS<code>
  • constructed: boolean (true if constructed, false if primitive)
  • number: numeric

Return value:

number to be used with encode
intToBER (i)

Converts an integer to a BER encoded type table

Parameters

  • i: number containing the value to decode

Return value:

table with the following entries:
  • class
  • constructed
  • primitive
  • number

Tables

tagDecoders

Table for registering additional tag decoders.

Each index is a tag number as a hex string. Values are ASN1 decoder functions.

tagEncoders

Table for registering additional tag encoders.

Each index is a lua type as a string. Values are ASN1 encoder functions.

Nmap Site Navigation

Intro Reference Guide Book Install Guide
Download Changelog Zenmap GUI Docs
Bug Reports OS Detection Propaganda Related Projects
In the Movies In the News
[ Nmap | Sec Tools | Mailing Lists | Site News | About/Contact | Advertising | Privacy ]