asn1parser

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateWholeTLVLength

func CalculateWholeTLVLength(tagLength TagLength) int

func ExpectLengthNotGreater

func ExpectLengthNotGreater(expectedLength *big.Int, length *big.Int) error

func ExpectTag

func ExpectTag(expectedTag asn1crypto.Tag, tag asn1crypto.Tag) error

func GetContextSpecificTagId

func GetContextSpecificTagId(tagLength *TagLength) int

func IsContextSpecificTag

func IsContextSpecificTag(tagLength *TagLength) bool

func IsContextSpecificTagWithId

func IsContextSpecificTagWithId(tagId int, tagLength *TagLength) bool

func ParseIssuerRDNSequence

func ParseIssuerRDNSequence(cert *x509.Certificate) (*pkix.RDNSequence, error)

func ParseOctetString

func ParseOctetString(reader Asn1Reader) (ret []byte, err error)

func ParseRDNSequence

func ParseRDNSequence(rdnData []byte) (*pkix.RDNSequence, error)

func ParseSubjectRDNSequence

func ParseSubjectRDNSequence(cert *x509.Certificate) (*pkix.RDNSequence, error)

func ParseUTCTime

func ParseUTCTime(bytes []byte) (*time.Time, error)

func PeekExpectedBigInt

func PeekExpectedBigInt(reader Asn1Reader, sizeOfLength int, offset int) (*big.Int, error)

func PeekExpectedBytes

func PeekExpectedBytes(reader Asn1Reader, byteSize int, offset int) ([]byte, error)

func PeekTag

func PeekTag(reader Asn1Reader, offset int) (*asn1crypto.Tag, error)

func PeekUint8

func PeekUint8(reader Asn1Reader, offset int) (uint8, error)

func ReadBigInt

func ReadBigInt(reader Asn1Reader) (*big.Int, error)

func ReadExpectedBigInt

func ReadExpectedBigInt(reader Asn1Reader, sizeOfLength int) (*big.Int, error)

func ReadExpectedBytes

func ReadExpectedBytes(reader Asn1Reader, byteSize int) ([]byte, error)

func ReadExpectedBytesRecursive

func ReadExpectedBytesRecursive(reader Asn1Reader, byteSize int, byteArray *[]byte, currentPosition int) error

func ReadStruct

func ReadStruct(reader Asn1Reader, value interface{}) error

func ReadTVLBytesWithLimit

func ReadTVLBytesWithLimit(reader Asn1Reader, tagLength TagLength, maxLength int64) ([]byte, error)

func ReadTag

func ReadTag(reader Asn1Reader) (*asn1crypto.Tag, error)

func ReadUint8

func ReadUint8(reader Asn1Reader) (uint8, error)

func ReadUtcTime

func ReadUtcTime(reader Asn1Reader) (*time.Time, error)

Types

type Asn1Reader

type Asn1Reader interface {
	Read(p []byte) (int, error)
	Peek(n int) ([]byte, error)
}

type BitString

type BitString struct {
	Bytes     []byte // bits packed into bytes.
	BitLength int    // length in bits.
}

func ParseBitString

func ParseBitString(reader Asn1Reader) (*BitString, error)

type Length

type Length struct {
	Length     big.Int //number of bytes the value has
	LengthSize int     //number of bytes the length has
}

func PeekLength

func PeekLength(reader Asn1Reader, offset int) (*Length, error)

func ReadLength

func ReadLength(reader Asn1Reader) (*Length, error)

type TagLength

type TagLength struct {
	Tag    asn1crypto.Tag
	Length Length
}

func PeekTagLength

func PeekTagLength(reader Asn1Reader, offset int) (*TagLength, error)

func ReadTagLength

func ReadTagLength(reader Asn1Reader) (*TagLength, error)

func (TagLength) CalculateTLLength

func (l TagLength) CalculateTLLength() *big.Int

Complete length in byte of length of the value

func (TagLength) CalculateTLVLength

func (l TagLength) CalculateTLVLength() *big.Int

Complete length in byte of the tlv record

func (TagLength) CalculateValueLength

func (l TagLength) CalculateValueLength() *big.Int

Complete length in byte of value

Jump to

Keyboard shortcuts

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