bertlv

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2021 License: MIT Imports: 6 Imported by: 0

README

BER-TLV

License Build Status Coverage Status Go Report Card GoDoc Release

Go implementation of the BER TLV encoding that is widely used in APDU requests and responses.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = errors.New("not found")

ErrNotFound is returned when requested tag is not present in TLV structure

Functions

func EncodeInt

func EncodeInt(in int) []byte

EncodeInt encodes an integer to BER format.

func ReadLen

func ReadLen(r io.Reader) (length int, n int, err error)

ReadLen reads length of a tag and return it along with length of a length in bytes and/or an error

func ReadTag

func ReadTag(r io.Reader) (tag int, n int, err error)

ReadTag reads length of a tag and return it along with length of a length in bytes or an error

Types

type TagValue

type TagValue struct {
	T int
	V []byte
}

TagValue pair

func Decode

func Decode(p []byte) ([]TagValue, error)

Decode decodes TLV encoded byte slice into slice of TagValue structs

func Find

func Find(tag int, p []byte) (*TagValue, error)

Find finds first tag (DFS) in the TLV structure represented by p

func (TagValue) Bytes

func (tv TagValue) Bytes() []byte

Bytes encodes TagValue into a byte slice

func (TagValue) IsConstructed

func (tv TagValue) IsConstructed() bool

IsConstructed returns true if the value is constructed type(contains other TLV records)

func (TagValue) Len

func (tv TagValue) Len() []byte

Len returns encoded length of the value

func (TagValue) MarshalJSON

func (tv TagValue) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaller

func (*TagValue) ReadFrom

func (tv *TagValue) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom implements io.ReaderFrom

func (TagValue) String

func (tv TagValue) String() string

func (TagValue) Tag

func (tv TagValue) Tag() []byte

Tag returns encoded tag value (two bytes tags are supported)

func (TagValue) WriteTo

func (tv TagValue) WriteTo(w io.Writer) (n int64, err error)

WriteTo implements io.WriterTo

Jump to

Keyboard shortcuts

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