asn1

package module
v0.0.0-...-d5d5b3b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

README

ASN1 Go Report Card

ASN1

ASN1 Code Generator

ASN1 Scheme Parser

The ASN1 scheme parser will parse an ASN1 file and return the definition. The definition can be used to parse ASN1 encoded data structures.

Usage

This fragment will parse the ASN1 scheme and return a definition.

r, err := os.Open(arg)
if err != nil {
    panic(err)
}

parser := asn1parser.NewParser(r)

def, err := parser.Parse()
if err != nil {
    panic(err)
}

Sponsors

This project has been made possible by Sentryo and Dutchsec.

Contributors

Parts of the ASN1 decoding have been included from https://github.com/Logicalis/asn1.

Code released under Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	BoolTrue  = Bool{true}
	BoolFalse = Bool{false}
)
View Source
var ErrUnparsedObjects = errors.New("Unparsed objects")

Functions

This section is empty.

Types

type ANY

type ANY []byte

func (*ANY) UnmarshalRawValue

func (s *ANY) UnmarshalRawValue(rv *RawValue) error

type ASNClass

type ASNClass uint
const (
	ClassUniversal       ASNClass = 0x00
	ClassApplication     ASNClass = 0x01
	ClassContextSpecific ASNClass = 0x02
	ClassPrivate         ASNClass = 0x03
)

ASN.1 class tags.

type ASNTag

type ASNTag struct {
	Class ASNClass
	Value ASNValue
}

func Tag

func Tag(class ASNClass, value ASNValue) ASNTag

type ASNValue

type ASNValue uint
var (
	TagEoc              ASNValue = 0x00
	TagBoolean          ASNValue = 0x01
	TagInteger          ASNValue = 0x02
	TagBitString        ASNValue = 0x03
	TagOctetString      ASNValue = 0x04
	TagNull             ASNValue = 0x05
	TagOid              ASNValue = 0x06
	TagObjectDescriptor ASNValue = 0x07
	TagExternal         ASNValue = 0x08
	TagSequence         ASNValue = 0x10
	TagSet              ASNValue = 0x11
	TagPrintableString  ASNValue = 0x13
	TagT61String        ASNValue = 0x14
	TagIA5String        ASNValue = 0x16
	TagVisibleString    ASNValue = 26
	TagUTCTime          ASNValue = 0x17
)

ASN.1 universal tag numbers.

type BitString

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

BitString is the structure to use when you want an ASN.1 BIT STRING type. A bit string is padded up to the nearest byte in memory and the number of valid bits is recorded. Padding bits will be zero.

func NewBitString

func NewBitString() BitString

BIT STRING

func (BitString) At

func (b BitString) At(i int) int

At returns the bit at the given index. If the index is out of range it returns 0.

func (BitString) RightAlign

func (b BitString) RightAlign() []byte

RightAlign returns a slice where the padding bits are at the beginning. The slice may share memory with the BitString.

func (*BitString) UnmarshalRawValue

func (s *BitString) UnmarshalRawValue(rv *RawValue) error

type Bool

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

func (*Bool) UnmarshalRawValue

func (s *Bool) UnmarshalRawValue(rv *RawValue) error

type FloatingPoint

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

func (*FloatingPoint) UnmarshalRawValue

func (s *FloatingPoint) UnmarshalRawValue(rv *RawValue) error

type GeneralString

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

func (*GeneralString) UnmarshalRawValue

func (s *GeneralString) UnmarshalRawValue(rv *RawValue) error

type GeneralizedTime

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

func (*GeneralizedTime) UnmarshalRawValue

func (s *GeneralizedTime) UnmarshalRawValue(rv *RawValue) error

type GraphicString

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

func (*GraphicString) UnmarshalRawValue

func (s *GraphicString) UnmarshalRawValue(rv *RawValue) error

type IA5String

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

func (*IA5String) UnmarshalRawValue

func (s *IA5String) UnmarshalRawValue(rv *RawValue) error

type Integer

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

func (Integer) Int64

func (s Integer) Int64() int64

func (*Integer) UnmarshalRawValue

func (s *Integer) UnmarshalRawValue(rv *RawValue) error

type Null

type Null struct{}

Null is used to encode and decode ASN.1 NULLs.

func (*Null) UnmarshalRawValue

func (s *Null) UnmarshalRawValue(rv *RawValue) error

type ObjectDescriptor

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

func (*ObjectDescriptor) UnmarshalRawValue

func (s *ObjectDescriptor) UnmarshalRawValue(rv *RawValue) error

type ObjectIdentifier

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

func (*ObjectIdentifier) UnmarshalRawValue

func (s *ObjectIdentifier) UnmarshalRawValue(rv *RawValue) error

type OctetString

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

func (*OctetString) String

func (s *OctetString) String() string

func (*OctetString) UnmarshalRawValue

func (s *OctetString) UnmarshalRawValue(rv *RawValue) error

type Oid

type Oid []uint

Oid is used to encode and decode ASN.1 OBJECT IDENTIFIERs.

func (Oid) Cmp

func (oid Oid) Cmp(other Oid) int

Cmp returns zero if both Oids are the same, a negative value if oid lexicographically precedes other and a positive value otherwise.

func (Oid) String

func (oid Oid) String() string

String returns the dotted representation of oid.

type ParseError

type ParseError struct {
	Msg string
}

ParseError is returned by the package to indicate that the given data is invalid.

func (*ParseError) Error

func (e *ParseError) Error() string

Error returns the error message of a ParseError.

type PrintableString

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

func (*PrintableString) UnmarshalRawValue

func (s *PrintableString) UnmarshalRawValue(rv *RawValue) error

type RawValue

type RawValue struct {
	Tag         ASNTag
	Constructed bool
	Indefinite  bool
	Content     []byte
}

func DecodeRawValue

func DecodeRawValue(reader io.Reader) (*RawValue, error)

type Real

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

func (*Real) UnmarshalRawValue

func (s *Real) UnmarshalRawValue(rv *RawValue) error

type SyntaxError

type SyntaxError struct {
	Msg string
}

SyntaxError is returned by the package to indicate that the given value or struct is invalid.

func (*SyntaxError) Error

func (e *SyntaxError) Error() string

Error returns the error message of a SyntaxError.

type T61String

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

func (*T61String) UnmarshalRawValue

func (s *T61String) UnmarshalRawValue(rv *RawValue) error

type UTCTime

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

func (*UTCTime) UnmarshalRawValue

func (s *UTCTime) UnmarshalRawValue(rv *RawValue) error

type UTF8String

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

func (*UTF8String) UnmarshalRawValue

func (s *UTF8String) UnmarshalRawValue(rv *RawValue) error

type VisibleString

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

func (*VisibleString) String

func (s *VisibleString) String() string

func (*VisibleString) UnmarshalRawValue

func (s *VisibleString) UnmarshalRawValue(rv *RawValue) error

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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