marshal

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTruncated     = errors.New("asn1: truncated data")
	ErrUnexpectedTag = errors.New("asn1: unexpected tag")
	ErrIntOverflow   = errors.New("asn1: integer overflows int32")
	ErrInvalidLen    = errors.New("asn1: invalid length encoding")
)

Sentinel errors — no fmt.Errorf allocation on hot path

Functions

func Encode

func Encode(r Result) []byte

Encode serializes a Result back to DER for testing/interop.

func EncodeIdentity

func EncodeIdentity(t int32, data []byte) []byte

EncodeIdentity serializes the pair (int32, []byte)

Types

type Result

type Result struct {
	IsInt bool
	Int32 int32  // valid when IsInt == true
	Str   string // valid when IsInt == false
	Data  []byte // zero-copy reference into input
}

Result holds the decoded payload. IsInt distinguishes the two variants. Data is a zero-copy sub-slice of the input — do not modify input while using it.

func DecodeIdentity

func DecodeIdentity(b []byte) (Result, error)

DecodeIdentity parses a DER SEQUENCE containing either [INTEGER, OCTET STRING] or [UTF8String, OCTET STRING].

Jump to

Keyboard shortcuts

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