asn1

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 16, 2025 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// ParameterType glow data field parameter type.
	ParameterType = "parameter"
	// QualifiedParameterType glow data field qualified parameter type.
	QualifiedParameterType = "qualified_parameter"
	// QualifiedNodeType glow data field qualified node type.
	QualifiedNodeType = "qualified_node"
	// NodeType glow data field node type.
	NodeType = "node"
	// FunctionType glow data field function type.
	FunctionType = "function"

	// EmberGetDirCommand integer for request dir command, based on S101 and glow protocol.
	EmberGetDirCommand = 32
	// EmberGetUnsubscribeCommand integer for request Unsubscribe command, based on S101 and glow protocol.
	EmberGetUnsubscribeCommand = 31

	// RootElementCollectionTag tag for defining glow root element collection encoding command.
	RootElementCollectionTag = 0
	// RootElementTag tag for defining glow root element collection.
	RootElementTag = 11
	// ElementCollectionTag tag for element collection.
	ElementCollectionTag = 4
	// ContextZeroTag tag for top level context.
	ContextZeroTag = 0
	// ContextTagOne tag for context
	// Node means data contains content.
	ContextTagOne = 1
	// ContextTagTwo tag for context
	// Node means data contains children.
	ContextTagTwo = 2
	// QualifiedParameterTag for defining glow qualified parameter tag.
	QualifiedParameterTag = 9
	// QualifiedNodeTag for defining glow qualified node tag.
	QualifiedNodeTag = 10

	// SetTag tag for defining Ember set structure.
	SetTag = 49

	// UniversalObjectTag context universal object tag.
	UniversalObjectTag = 0x0D
	// UTF8StringTag context utf8String object tag.
	UTF8StringTag = 0x0C
)

Variables

View Source
var ErrNoLenByte = errors.New("can not determine length")

ErrNoLenByte error when length of bytes can not be determined.

Functions

func ApplicationByte

func ApplicationByte(num uint8) uint8

ApplicationByte have the same meaning wherever they are seen and used.

func ContextByte

func ContextByte(num uint8) uint8

ContextByte context-specific tags depends on the location where they are seen.

func DecodeAny

func DecodeAny(in []byte, val any) (int, error)

DecodeAny decodes native asn1 value.

func UniversalByte

func UniversalByte(num uint8) uint8

UniversalByte predefined types, the value is returned unchanged.

Types

type Decoder

type Decoder struct {
	// contains filtered or unexported fields
}

Decoder decoder for ASN1 glow data.

func NewDecoder

func NewDecoder(b []byte) *Decoder

NewDecoder creates a new ASN1 Decoder.

func (*Decoder) Bytes

func (c *Decoder) Bytes() []byte

Bytes wrapper to containing decoders data bytes.

func (*Decoder) DecodeInteger

func (c *Decoder) DecodeInteger() (int, error)

DecodeInteger decodes the following integer.

func (*Decoder) DecodeUTF8

func (c *Decoder) DecodeUTF8() (string, error)

DecodeUTF8 decoded the following utf8 data type of glow.

func (*Decoder) DecodeUniversal

func (c *Decoder) DecodeUniversal() ([]int, error)

DecodeUniversal decoded the following universal data type of glow, currently only used for universal path decoding, witch is an array of integers.

func (*Decoder) Len

func (c *Decoder) Len() int

Len Bytes wrapper to containing decoders data bytes.

func (*Decoder) Peek

func (c *Decoder) Peek() (byte, error)

Peek returns the next byte, but does not remove it from the buffer.

func (*Decoder) Read

func (c *Decoder) Read(tag uint8, compareByte func(num uint8) uint8) (*Decoder, bool, error)

Read reads the next glow data block of the appropriate type, it checks the glow tag against the provided compare function and if they match it reads the glow data block and returns it as it's own decoded, original decoder might have more data left, THIS DOES NOT READ ALL THE DATA. If no length byte is found in data returns ALL remaining bytes. Returns True if next element length is unknown.

func (*Decoder) ReadByte

func (c *Decoder) ReadByte() (byte, error)

ReadByte reads one byte from the underlining bytes buffer in decoder.

func (*Decoder) ReadEnd

func (c *Decoder) ReadEnd() (bool, error)

ReadEnd checks if decoder is currently at the end of element and moves the reader over it, if at end.

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

Encoder encoder ASN1 glow data.

func NewEncoder

func NewEncoder() *Encoder

NewEncoder creates a new encoder with an initialized data buffer, but no actual data.

func (*Encoder) GetData

func (c *Encoder) GetData() []byte

GetData returns all data contained in the encoder.

func (*Encoder) WriteCommand

func (c *Encoder) WriteCommand(cmd int) error

WriteCommand writes a get dir command request into the buffer.

func (*Encoder) WriteRequest

func (c *Encoder) WriteRequest(path []int, tag string, cmd int) error

WriteRequest writes a request into the encoder buffer, for the provided element type, currently supports parameters, qualified parameters, nodes qualified nodes and functions.

func (*Encoder) WriteRootTreeRequest

func (c *Encoder) WriteRootTreeRequest() error

WriteRootTreeRequest writes a request for root element collection into the buffer.

func (*Encoder) WriteUniversal

func (c *Encoder) WriteUniversal(path []int)

WriteUniversal writes the provided integer into the buffer as an glow encoded universal value.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL