# Unit asn1util

Description | uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables

## Description

Utilities for handling ASN.1 BER encoding

By this unit you can parse ASN.1 BER encoded data to elements or build back any elements to ASN.1 BER encoded buffer. You can dump ASN.1 BER encoded data to human readable form for easy debugging, too.

Supported element types are: ASN1_BOOL, ASN1_INT, ASN1_OCTSTR, ASN1_NULL, ASN1_OBJID, ASN1_ENUM, ASN1_SEQ, ASN1_SETOF, ASN1_IPADDR, ASN1_COUNTER, ASN1_GAUGE, ASN1_TIMETICKS, ASN1_OPAQUE

For sample of using, look to TSNMPSend or TLDAPSendclass.

## uses

- SysUtils
- Classes
- synautil

## Overview

### Functions and Procedures

`function ASNEncOIDItem(Value: Integer): AnsiString;`
`function ASNDecOIDItem(var Start: Integer; const Buffer: AnsiString): Integer;`
`function ASNEncLen(Len: Integer): AnsiString;`
`function ASNDecLen(var Start: Integer; const Buffer: AnsiString): Integer;`
`function ASNEncInt(Value: Integer): AnsiString;`
`function ASNEncUInt(Value: Integer): AnsiString;`
`function ASNObject(const Data: AnsiString; ASNType: Integer): AnsiString;`
`function ASNItem(var Start: Integer; const Buffer: AnsiString; var ValueType: Integer): AnsiString;`
`function MibToId(Mib: String): AnsiString;`
`function IdToMib(const Id: AnsiString): String;`
`function IntMibToStr(const Value: AnsiString): AnsiString;`
`function ASNdump(const Value: AnsiString): AnsiString;`

### Constants

`ASN1_BOOL = $01;`
`ASN1_INT = $02;`
`ASN1_OCTSTR = $04;`
`ASN1_NULL = $05;`
`ASN1_OBJID = $06;`
`ASN1_ENUM = $0a;`
`ASN1_SEQ = $30;`
`ASN1_SETOF = $31;`
`ASN1_IPADDR = $40;`
`ASN1_COUNTER = $41;`
`ASN1_GAUGE = $42;`
`ASN1_TIMETICKS = $43;`
`ASN1_OPAQUE = $44;`

## Description

### Functions and Procedures

`function ASNEncOIDItem(Value: Integer): AnsiString;`

Encodes OID item to binary form.

`function ASNDecOIDItem(var Start: Integer; const Buffer: AnsiString): Integer;`

Decodes an OID item of the next element in the "Buffer" from the "Start" position.

`function ASNEncLen(Len: Integer): AnsiString;`

Encodes the length of ASN.1 element to binary.

`function ASNDecLen(var Start: Integer; const Buffer: AnsiString): Integer;`

Decodes length of next element in "Buffer" from the "Start" position.

`function ASNEncInt(Value: Integer): AnsiString;`

Encodes a signed integer to ASN.1 binary

`function ASNEncUInt(Value: Integer): AnsiString;`

Encodes unsigned integer into ASN.1 binary

`function ASNObject(const Data: AnsiString; ASNType: Integer): AnsiString;`

Encodes ASN.1 object to binary form.

`function ASNItem(var Start: Integer; const Buffer: AnsiString; var ValueType: Integer): AnsiString;`

Beginning with the "Start" position, decode the ASN.1 item of the next element in "Buffer". Type of item is stored in "ValueType."

`function MibToId(Mib: String): AnsiString;`

Encodes an MIB OID string to binary form.

`function IdToMib(const Id: AnsiString): String;`

Decodes MIB OID from binary form to string form.

`function IntMibToStr(const Value: AnsiString): AnsiString;`

Encodes an one number from MIB OID to binary form. (used internally from MibToId)

`function ASNdump(const Value: AnsiString): AnsiString;`

Convert ASN.1 BER encoded buffer to human readable form for debugging.

### Constants

`ASN1_BOOL = $01;`

`ASN1_INT = $02;`

`ASN1_OCTSTR = $04;`

`ASN1_NULL = $05;`

`ASN1_OBJID = $06;`

`ASN1_ENUM = $0a;`

`ASN1_SEQ = $30;`

`ASN1_SETOF = $31;`

`ASN1_IPADDR = $40;`

`ASN1_COUNTER = $41;`

`ASN1_GAUGE = $42;`

`ASN1_TIMETICKS = $43;`

`ASN1_OPAQUE = $44;`

Generated by PasDoc 0.9.0 on 2012-04-23 21:38:50