go1.20.5
GoThrough

asn1.ClassApplication

// ASN.1 class types represent the namespace of the tag. const ClassApplication = 1

asn1.ClassContextSpecific

// ASN.1 class types represent the namespace of the tag. const ClassContextSpecific = 2

asn1.ClassPrivate

// ASN.1 class types represent the namespace of the tag. const ClassPrivate = 3

asn1.ClassUniversal

// ASN.1 class types represent the namespace of the tag. const ClassUniversal = 0

asn1.TagBMPString

// ASN.1 tags represent the type of the following object. const TagBMPString = 30

asn1.TagBitString

// ASN.1 tags represent the type of the following object. const TagBitString = 3

asn1.TagBoolean

// ASN.1 tags represent the type of the following object. const TagBoolean = 1

asn1.TagEnum

// ASN.1 tags represent the type of the following object. const TagEnum = 10

asn1.TagGeneralString

// ASN.1 tags represent the type of the following object. const TagGeneralString = 27

asn1.TagGeneralizedTime

// ASN.1 tags represent the type of the following object. const TagGeneralizedTime = 24

asn1.TagIA5String

// ASN.1 tags represent the type of the following object. const TagIA5String = 22

asn1.TagInteger

// ASN.1 tags represent the type of the following object. const TagInteger = 2

asn1.TagNull

// ASN.1 tags represent the type of the following object. const TagNull = 5

asn1.TagNumericString

// ASN.1 tags represent the type of the following object. const TagNumericString = 18

asn1.TagOID

// ASN.1 tags represent the type of the following object. const TagOID = 6

asn1.TagOctetString

// ASN.1 tags represent the type of the following object. const TagOctetString = 4

asn1.TagPrintableString

// ASN.1 tags represent the type of the following object. const TagPrintableString = 19

asn1.TagSequence

// ASN.1 tags represent the type of the following object. const TagSequence = 16

asn1.TagSet

// ASN.1 tags represent the type of the following object. const TagSet = 17

asn1.TagT61String

// ASN.1 tags represent the type of the following object. const TagT61String = 20

asn1.TagUTCTime

// ASN.1 tags represent the type of the following object. const TagUTCTime = 23

asn1.TagUTF8String

// ASN.1 tags represent the type of the following object. const TagUTF8String = 12

asn1.NullBytes

// NullBytes contains bytes representing the DER-encoded ASN.1 NULL type. var NullBytes = []byte{TagNull, 0}

asn1.NullRawValue

// NullRawValue is a RawValue with its Tag set to the ASN.1 NULL type tag (5). var NullRawValue = RawValue{Tag: TagNull}

asn1.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 Marshal(val any) ([]byte, error)

asn1.MarshalWithParams

// MarshalWithParams allows field parameters to be specified for the // top-level element. The form of the params is the same as the field tags. func MarshalWithParams(val any, params string) ([]byte, error)

asn1.Unmarshal

// Unmarshal parses the DER-encoded ASN.1 data structure b // and uses the reflect package to fill in an arbitrary value pointed at by val. // Because Unmarshal uses the reflect package, the structs // being written to must use upper case field names. If val // is nil or not a pointer, Unmarshal returns an error. // // After parsing b, any bytes that were leftover and not used to fill // val will be returned in rest. When parsing a SEQUENCE into a struct, // any trailing elements of the SEQUENCE that do not have matching // fields in val will not be included in rest, as these are considered // valid elements of the SEQUENCE and not trailing data. // // An ASN.1 INTEGER can be written to an int, int32, int64, // or *big.Int (from the math/big package). // If the encoded value does not fit in the Go type, // Unmarshal returns a parse error. // // An ASN.1 BIT STRING can be written to a BitString. // // An ASN.1 OCTET STRING can be written to a []byte. // // An ASN.1 OBJECT IDENTIFIER can be written to an // ObjectIdentifier. // // An ASN.1 ENUMERATED can be written to an Enumerated. // // An ASN.1 UTCTIME or GENERALIZEDTIME can be written to a time.Time. // // An ASN.1 PrintableString, IA5String, or NumericString can be written to a string. // // Any of the above ASN.1 values can be written to an interface{}. // The value stored in the interface has the corresponding Go type. // For integers, that type is int64. // // An ASN.1 SEQUENCE OF x or SET OF x can be written // to a slice if an x can be written to the slice's element type. // // An ASN.1 SEQUENCE or SET can be written to a struct // if each of the elements in the sequence can be // written to the corresponding element in the struct. // // The following tags on struct fields have special meaning to Unmarshal: // // application specifies that an APPLICATION tag is used // private specifies that a PRIVATE tag is used // default:x sets the default value for optional integer fields (only used if optional is also present) // explicit specifies that an additional, explicit tag wraps the implicit one // optional marks the field as ASN.1 OPTIONAL // set causes a SET, rather than a SEQUENCE type to be expected // tag:x specifies the ASN.1 tag number; implies ASN.1 CONTEXT SPECIFIC // // When decoding an ASN.1 value with an IMPLICIT tag into a string field, // Unmarshal will default to a PrintableString, which doesn't support // characters such as '@' and '&'. To force other encodings, use the following // tags: // // ia5 causes strings to be unmarshaled as ASN.1 IA5String values // numeric causes strings to be unmarshaled as ASN.1 NumericString values // utf8 causes strings to be unmarshaled as ASN.1 UTF8String values // // If the type of the first field of a structure is RawContent then the raw // ASN1 contents of the struct will be stored in it. // // If the name of a slice type ends with "SET" then it's treated as if // the "set" tag was set on it. This results in interpreting the type as a // SET OF x rather than a SEQUENCE OF x. This can be used with nested slices // where a struct tag cannot be given. // // Other ASN.1 types are not supported; if it encounters them, // Unmarshal returns a parse error. func Unmarshal(b []byte, val any) (rest []byte, err error)

asn1.UnmarshalWithParams

// UnmarshalWithParams allows field parameters to be specified for the // top-level element. The form of the params is the same as the field tags. func UnmarshalWithParams(b []byte, val any, params string) (rest []byte, err error)