tlv

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2023 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Overview

Package tlv implements various version (ASN.1 BER, Simple, Compact) TLV encoding using in ISO 7816-4.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidTag   = errors.New("invalid tag")
	ErrTagToBig     = errors.New("tag is too big for this encoding")
	ErrValueToLarge = errors.New("valye to large for this encoding")
)
View Source
var ErrNotConstructed = errors.New("tag is not constructed but contains children")

Functions

func EncodeBER

func EncodeBER(tvs ...TagValue) (buf []byte, err error)

func EncodeCompact

func EncodeCompact(tvs ...TagValue) (buf []byte, err error)

func EncodeSimple

func EncodeSimple(tvs ...TagValue) (buf []byte, err error)

Types

type Class

type Class byte
const (
	ClassUniversal   Class = 0b00
	ClassApplication Class = 0b01
	ClassContext     Class = 0b10
	ClassPrivate     Class = 0b11
)

type Tag

type Tag uint // In theory ISO 7816-4 also supports 3-byte tags

func (Tag) Class

func (t Tag) Class() Class

func (Tag) IsConstructed

func (t Tag) IsConstructed() bool

type TagValue

type TagValue struct {
	Tag        Tag
	Value      []byte
	Children   []TagValue
	SkipLength bool
}

func DecodeBER

func DecodeBER(buf []byte) (tvs []TagValue, err error)

func DecodeCompact

func DecodeCompact(buf []byte) (tvs []TagValue, err error)

func DecodeSimple

func DecodeSimple(buf []byte) (tvs []TagValue, err error)

func New

func New(t Tag, values ...any) (tv TagValue)

func (TagValue) MarshalBER

func (tv TagValue) MarshalBER() (buf []byte, err error)

func (*TagValue) UnmarshalBER

func (tv *TagValue) UnmarshalBER(buf []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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