ber

package
v0.0.0-...-a8a18e3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Universal   = 0x00
	Application = 0x01
	Context     = 0x02
	Private     = 0x03
)
View Source
const (
	TagEOC              = 0x00
	TagBool             = 0x01
	TagInteger          = 0x02
	TagBitString        = 0x03
	TagOctetString      = 0x04
	TagNULL             = 0x05
	TagObjectIdentifier = 0x06
	TagObjectDescriptor = 0x07
	TagExternal         = 0x08
	TagRealFloat        = 0x09
	TagEnumerated       = 0x0a
	TagEmbeddedPDV      = 0x0b
	TagUTF8String       = 0x0c
	TagRelativeOID      = 0x0d
	TagSequence         = 0x10
	TagSet              = 0x11
	TagNumericString    = 0x12
	TagPrintableString  = 0x13
	TagT61String        = 0x14
	TagVideotexString   = 0x15
	TagIA5String        = 0x16
	TagUTCTime          = 0x17
	TagGeneralizedTime  = 0x18
	TagGraphicString    = 0x19
	TagVisibleString    = 0x1a
	TagGeneralString    = 0x1b
	TagUniversalString  = 0x1c
	TagCharacterString  = 0x1d
	TagBMPString        = 0x1e
)

Variables

This section is empty.

Functions

func EncodeTree

func EncodeTree(tree *Tree) ([]byte, error)

Types

type ASN1RawValue

type ASN1RawValue struct {
	V *asn1.RawValue
}

func (ASN1RawValue) Marshal

func (m ASN1RawValue) Marshal() (*Tree, error)

func (ASN1RawValue) Unmarshal

func (m ASN1RawValue) Unmarshal(tree *Tree) (err error)

type BigInt

type BigInt struct {
	V **big.Int
}

func (BigInt) Marshal

func (m BigInt) Marshal() (*Tree, error)

func (BigInt) Unmarshal

func (m BigInt) Unmarshal(tree *Tree) error

type Check

type Check struct {
	Class int
	Tag   int
	Sub   Marshaler
}

func (Check) Marshal

func (m Check) Marshal() (*Tree, error)

func (Check) Unmarshal

func (m Check) Unmarshal(tree *Tree) (err error)

type Choice

type Choice []Marshaler

func (Choice) Marshal

func (s Choice) Marshal() (*Tree, error)

func (Choice) Unmarshal

func (s Choice) Unmarshal(tree *Tree) (err error)

type DER

type DER struct {
	V *[]byte
}

func (DER) Marshal

func (m DER) Marshal() (*Tree, error)

func (DER) Unmarshal

func (m DER) Unmarshal(tree *Tree) (err error)

type Decoder

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

func NewDecoder

func NewDecoder(r io.Reader) *Decoder

func (*Decoder) Token

func (d *Decoder) Token() (t *Token, err error)

Returns the next token in the input stream. At the end of the input stream, Token returns nil, io.EOF.

type Explicit

type Explicit struct {
	Sub Marshaler
}

func (Explicit) Marshal

func (m Explicit) Marshal() (tree *Tree, err error)

func (Explicit) Unmarshal

func (m Explicit) Unmarshal(tree *Tree) (err error)

type Int64

type Int64 struct {
	V *int64
}

func (Int64) Marshal

func (m Int64) Marshal() (*Tree, error)

func (Int64) Unmarshal

func (m Int64) Unmarshal(tree *Tree) error

type Kind

type Kind int
const (
	Value Kind = iota
	Constructed
	EndConstructed
)

type Marshaler

type Marshaler interface {
	Marshal() (*Tree, error)
	Unmarshal(*Tree) error
}

type ObjectIdentifier

type ObjectIdentifier struct {
	V *asn1.ObjectIdentifier
}

func (ObjectIdentifier) Marshal

func (m ObjectIdentifier) Marshal() (*Tree, error)

func (ObjectIdentifier) Unmarshal

func (m ObjectIdentifier) Unmarshal(tree *Tree) error

type OctetString

type OctetString struct {
	V *[]byte
}

func (OctetString) Marshal

func (m OctetString) Marshal() (*Tree, error)

func (OctetString) Unmarshal

func (m OctetString) Unmarshal(tree *Tree) error

type Optional

type Optional struct {
	Sub Marshaler
}

func (Optional) Marshal

func (m Optional) Marshal() (tree *Tree, err error)

func (Optional) Unmarshal

func (m Optional) Unmarshal(tree *Tree) (err error)

type RawTree

type RawTree struct {
	Tree **Tree
}

func (RawTree) Marshal

func (m RawTree) Marshal() (*Tree, error)

func (RawTree) Unmarshal

func (m RawTree) Unmarshal(tree *Tree) error

type Sequence

type Sequence []Marshaler

func (Sequence) Marshal

func (s Sequence) Marshal() (root *Tree, err error)

func (Sequence) Unmarshal

func (s Sequence) Unmarshal(tree *Tree) (err error)

type StructuralError

type StructuralError struct {
	Msg string
}

A StructuralError suggests that the ASN.1 data is valid, but the Go type which is receiving it doesn't match.

func (StructuralError) Error

func (e StructuralError) Error() string

type SyntaxError

type SyntaxError struct {
	Msg string
}

A SyntaxError suggests that the ASN.1 data is invalid.

func (SyntaxError) Error

func (e SyntaxError) Error() string

type Token

type Token struct {
	Kind  Kind
	Class int
	Tag   int
	Bytes []byte
}

func (*Token) AsBigInt

func (v *Token) AsBigInt() (*big.Int, error)

parseBigInt treats the given bytes as a big-endian, signed integer and returns the result.

func (*Token) AsBitString

func (v *Token) AsBitString() (ret asn1.BitString, err error)

AsBitString parses an ASN.1 bit string from the given byte slice and returns it.

func (*Token) AsBool

func (v *Token) AsBool() (ret bool, err error)

func (*Token) AsGeneralizedTime

func (v *Token) AsGeneralizedTime() (ret time.Time, err error)

AsGeneralizedTime parses the GeneralizedTime from the given byte slice and returns the resulting time.

func (*Token) AsIA5String

func (v *Token) AsIA5String() (ret string, err error)

parseIA5String parses a ASN.1 IA5String (ASCII string) from the given byte slice and returns it.

func (*Token) AsInt32

func (v *Token) AsInt32() (ret int32, err error)

AsInt32 treats the given bytes as a big-endian, signed integer and returns the result.

func (*Token) AsInt64

func (v *Token) AsInt64() (ret int64, err error)

AsInt64 treats the given bytes as a big-endian, signed integer and returns the result.

func (*Token) AsNumericString

func (v *Token) AsNumericString() (ret string, err error)

NumericString

func (*Token) AsObjectIdentifier

func (val *Token) AsObjectIdentifier() (s asn1.ObjectIdentifier, err error)

AsObjectIdentifier parses an OBJECT IDENTIFIER from the given bytes and returns it. An object identifier is a sequence of variable length integers that are assigned in a hierarchy.

func (*Token) AsOctetString

func (v *Token) AsOctetString() (ret []byte, err error)

func (*Token) AsPrintableString

func (v *Token) AsPrintableString() (ret string, err error)

AsPrintableString parses a ASN.1 PrintableString from the given byte array and returns it.

func (*Token) AsT61String

func (v *Token) AsT61String() (ret string, err error)

parseT61String parses a ASN.1 T61String (8-bit clean string) from the given byte slice and returns it.

func (*Token) AsUTCTime

func (v *Token) AsUTCTime() (ret time.Time, err error)

func (*Token) AsUTF8String

func (v *Token) AsUTF8String() (ret string, err error)

parseUTF8String parses a ASN.1 UTF8String (raw UTF-8) from the given byte array and returns it.

func (*Token) AsVisibleString

func (v *Token) AsVisibleString() (ret string, err error)

AsVisibleString parses a ASN.1 VisibleString from the given byte array and returns it.

func (*Token) Universal

func (v *Token) Universal() (ret interface{}, err error)

type Tree

type Tree struct {
	*Token
	Children []*Tree
}

func ASN1Tree

func ASN1Tree(v interface{}) (*Tree, error)

func DecodeTree

func DecodeTree(data []byte) (*Tree, error)

func ParseTree

func ParseTree(d *Decoder) (tree *Tree, err error)

func (*Tree) AsOctetString

func (t *Tree) AsOctetString() (ret []byte, err error)

Jump to

Keyboard shortcuts

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