bertlv

package module
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT Imports: 9 Imported by: 4

README

ASN.1 BER-TLV Parsing and Builder

The project is a simple implementation of ASN.1 BER-TLV parsing and builder in Golang.

Test Coverage: 100%

References

Documentation

Index

Constants

View Source
const (
	Universal       Class = 0b00
	Application     Class = 0b01
	ContextSpecific Class = 0b10
	Private         Class = 0b11
	Primitive       Form  = 0b0
	Constructed     Form  = 0b1
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Class

type Class byte

func (Class) Constructed

func (c Class) Constructed(value uint64) Tag

func (Class) Primitive

func (c Class) Primitive(value uint64) Tag

type Form

type Form byte

func (Form) Application

func (f Form) Application(value uint64) Tag

func (Form) ContextSpecific

func (f Form) ContextSpecific(value uint64) Tag

func (Form) Private

func (f Form) Private(value uint64) Tag

func (Form) Universal

func (f Form) Universal(value uint64) Tag

type Marshaler added in v0.2.3

type Marshaler interface {
	MarshalBERTLV() (*TLV, error)
}

type Reflective added in v0.2.3

type Reflective interface {
	Tag() Tag
}

type TLV

type TLV struct {
	Tag      Tag
	Value    []byte
	Children []*TLV
}

func MarshalValue added in v0.2.0

func MarshalValue(tag Tag, marshaler encoding.BinaryMarshaler) (tlv *TLV, err error)

func NewChildren

func NewChildren(tag Tag, children ...*TLV) *TLV

func NewChildrenIter added in v0.1.5

func NewChildrenIter(tag Tag, children iter.Seq[*TLV]) *TLV

func NewValue

func NewValue(tag Tag, value []byte) *TLV

func (*TLV) At

func (tlv *TLV) At(index int) *TLV

func (*TLV) Bytes

func (tlv *TLV) Bytes() []byte

func (*TLV) Clone added in v0.2.3

func (tlv *TLV) Clone() *TLV

func (*TLV) Find

func (tlv *TLV) Find(tag Tag) (matches []*TLV)

func (*TLV) First

func (tlv *TLV) First(tag Tag) *TLV

func (*TLV) Len added in v0.1.4

func (tlv *TLV) Len() int

func (*TLV) MarshalBERTLV added in v0.2.3

func (tlv *TLV) MarshalBERTLV() (*TLV, error)

func (*TLV) MarshalBinary

func (tlv *TLV) MarshalBinary() ([]byte, error)

func (*TLV) MarshalText

func (tlv *TLV) MarshalText() ([]byte, error)

func (*TLV) MarshalValue added in v0.2.0

func (tlv *TLV) MarshalValue(marshaler encoding.BinaryMarshaler) (err error)

func (*TLV) ReadFrom

func (tlv *TLV) ReadFrom(r io.Reader) (n int64, err error)

func (*TLV) Select

func (tlv *TLV) Select(tags ...Tag) *TLV

func (*TLV) String added in v0.1.2

func (tlv *TLV) String() string

func (*TLV) UnmarshalBERTLV added in v0.2.3

func (tlv *TLV) UnmarshalBERTLV(cloned *TLV) error

func (*TLV) UnmarshalBinary

func (tlv *TLV) UnmarshalBinary(data []byte) error

func (*TLV) UnmarshalText

func (tlv *TLV) UnmarshalText(text []byte) error

func (*TLV) UnmarshalValue added in v0.2.0

func (tlv *TLV) UnmarshalValue(unmarshaler encoding.BinaryUnmarshaler) error

func (*TLV) WriteTo

func (tlv *TLV) WriteTo(w io.Writer) (n int64, err error)

type Tag

type Tag []byte

func NewTag

func NewTag(class Class, form Form, value uint64) Tag

func (*Tag) Application

func (t *Tag) Application() bool

func (*Tag) Class

func (t *Tag) Class() Class

func (*Tag) Constructed

func (t *Tag) Constructed() bool

func (*Tag) ContextSpecific

func (t *Tag) ContextSpecific() bool

func (*Tag) Equal added in v0.2.2

func (t *Tag) Equal(tag Tag) bool

func (*Tag) Form

func (t *Tag) Form() Form

func (*Tag) If added in v0.2.2

func (t *Tag) If(class Class, form Form, value uint64) bool

func (*Tag) Primitive

func (t *Tag) Primitive() bool

func (*Tag) Private

func (t *Tag) Private() bool

func (*Tag) ReadFrom

func (t *Tag) ReadFrom(r io.Reader) (n int64, err error)

func (*Tag) String

func (t *Tag) String() string

func (*Tag) Universal

func (t *Tag) Universal() bool

func (*Tag) Value

func (t *Tag) Value() uint64

type Unmarshaler added in v0.2.3

type Unmarshaler interface {
	UnmarshalBERTLV(*TLV) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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