Documentation ¶
Index ¶
- Variables
- func GetBitString(srcBytes []byte, bitsOffset uint, numBits uint) (dstBytes []byte, err error)
- func GetBitsValue(srcBytes []byte, bitsOffset uint, numBits uint) (value uint64, err error)
- func Marshal(val interface{}, choiceMap map[string]map[int]reflect.Type, ...) ([]byte, error)
- func MarshalWithParams(val interface{}, params string, choiceMap map[string]map[int]reflect.Type, ...) ([]byte, error)
- func Unmarshal(b []byte, value interface{}, choiceMap map[string]map[int]reflect.Type, ...) error
- func UnmarshalWithParams(b []byte, value interface{}, params string, ...) error
Constants ¶
This section is empty.
Variables ¶
var ( // BitStringType is the type of BitString BitStringType = reflect.TypeOf(asn1.BitString{}) )
Functions ¶
func GetBitString ¶
GetBitString is to get BitString with desire size from source byte array with bit offset
func GetBitsValue ¶
GetBitsValue is to get Value with desire bits from source byte array with bit offset
func Marshal ¶
func Marshal(val interface{}, choiceMap map[string]map[int]reflect.Type, canonicalChoiceMap map[string]map[int64]reflect.Type) ([]byte, error)
Marshal returns the ASN.1 encoding of val.
func MarshalWithParams ¶
func MarshalWithParams(val interface{}, params string, choiceMap map[string]map[int]reflect.Type, canonicalChoiceMap map[string]map[int64]reflect.Type) ([]byte, error)
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 Unmarshal ¶
func Unmarshal(b []byte, value interface{}, choiceMap map[string]map[int]reflect.Type, canonicalChoiceMap map[string]map[int64]reflect.Type) error
Unmarshal parses the APER-encoded ASN.1 data structure b and uses the reflect package to fill in an arbitrary value pointed at by value. Because Unmarshal uses the reflect package, the structs being written to must use upper case field names.
An ASN.1 INTEGER can be written to an int, int32, int64, 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.
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 can be written to a slice if an x can be written to the slice's element type.
An ASN.1 SEQUENCE 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:
optional OPTIONAL tag in SEQUENCE sizeExt specifies that size is extensible valueExt specifies that value is extensible sizeLB set the minimum value of size constraint sizeUB set the maximum value of value constraint valueLB set the minimum value of size constraint valueUB set the maximum value of value constraint default sets the default value openType specifies the open Type referenceFieldName the string of the reference field for this type (only if openType used) referenceFieldValue the corresponding value of the reference field for this type (only if openType used)
Other ASN.1 types are not supported; if it encounters them, Unmarshal returns a parse error.
func UnmarshalWithParams ¶
func UnmarshalWithParams(b []byte, value interface{}, params string, choiceMap map[string]map[int]reflect.Type, canonicalChoiceMap map[string]map[int64]reflect.Type) error
UnmarshalWithParams allows field parameters to be specified for the top-level element. The form of the params is the same as the field tags.
Types ¶
This section is empty.