Documentation
¶
Overview ¶
Package asn1 implements parsing of DER-encoded ASN.1 data structures, as defined in ITU-T Rec X.690.
See also “A Layman's Guide to a Subset of ASN.1, BER, and DER,” http://luca.ntop.org/Teaching/Appunti/asn1.html.
Index ¶
- Constants
- Variables
- func Marshal(val any) ([]byte, error)
- func MarshalWithParams(val any, params string) ([]byte, error)
- func Unmarshal(b []byte, val any) (rest []byte, err error)
- func UnmarshalWithParams(b []byte, val any, params string) (rest []byte, err error)
- type BitString
- type Enumerated
- type Flag
- type ObjectIdentifier
- type RawContent
- type RawValue
- type StructuralError
- type SyntaxError
Constants ¶
const ( TagBoolean = 1 TagInteger = 2 TagBitString = 3 TagOctetString = 4 TagNull = 5 TagOID = 6 TagEnum = 10 TagUTF8String = 12 TagSequence = 16 TagSet = 17 TagNumericString = 18 TagPrintableString = 19 TagT61String = 20 TagIA5String = 22 TagUTCTime = 23 TagGeneralizedTime = 24 TagGeneralString = 27 TagBMPString = 30 )
ASN.1 tags represent the type of the following object.
const ( ClassUniversal = 0 ClassApplication = 1 ClassContextSpecific = 2 ClassPrivate = 3 )
ASN.1 class types represent the namespace of the tag.
Variables ¶
var NullBytes = []byte{TagNull, 0}
NullBytes contains bytes representing the DER-encoded ASN.1 NULL type.
var NullRawValue = RawValue{Tag: TagNull}
NullRawValue is a RawValue with its Tag set to the ASN.1 NULL type tag (5).
Functions ¶
func Marshal ¶
Marshal returns the ASN.1 encoding of val.
In addition to the struct tags recognised by Unmarshal, the following can be used:
ia5: causes strings to be marshaled as ASN.1, IA5String values omitempty: causes empty slices to be skipped printable: causes strings to be marshaled as ASN.1, PrintableString values utf8: causes strings to be marshaled as ASN.1, UTF8String values utc: causes time.Time to be marshaled as ASN.1, UTCTime values generalized: causes time.Time to be marshaled as ASN.1, GeneralizedTime values
func MarshalWithParams ¶ added in go1.10
MarshalWithParams allows field parameters to be specified for the top-level element. The form of the params is the same as the field tags.