Documentation ¶
Index ¶
- Constants
- Variables
- func BoolDeserialize(n *Node, params ...Parameter) (bool, error)
- func BytesDeserialize(n *Node, params ...Parameter) ([]byte, error)
- func CheckConstructed(n *Node, params ...Parameter) error
- func CheckNode(n *Node, class int, tag int) error
- func ChoiceDeserializeDER(c Choice, n *Node, params ...Parameter) error
- func ConvertToString(n *Node) (string, error)
- func DecodeNode(data []byte, n *Node) (rest []byte, err error)
- func Deserialize(v interface{}, n *Node, params ...Parameter) error
- func EncodeNode(data []byte, n *Node) (rest []byte, err error)
- func EnumDeserialize(n *Node, params ...Parameter) (int, error)
- func IntDeserialize(n *Node, params ...Parameter) (int64, error)
- func Marshal(v interface{}, params ...Parameter) ([]byte, error)
- func NullDeserialize(n *Node, params ...Parameter) error
- func RandomUTCTime(r *rand.Rand) time.Time
- func StringDeserialize(n *Node, params ...Parameter) (string, error)
- func UTCTimeDeserialize(n *Node, params ...Parameter) (time.Time, error)
- func UintDeserialize(n *Node, params ...Parameter) (uint64, error)
- func Unmarshal(data []byte, v interface{}, params ...Parameter) error
- type Choice
- type Deserializer
- type ErrorUnmarshalBytes
- type ErrorUnmarshalInt
- type ErrorUnmarshalString
- type ErrorUnmarshalUint
- type Explicit
- type Name
- type Node
- func BoolSerialize(b bool, params ...Parameter) (*Node, error)
- func BytesSerialize(bs []byte, params ...Parameter) (*Node, error)
- func ChoiceSerializeDER(c Choice, params ...Parameter) (*Node, error)
- func EnumSerialize(e int, params ...Parameter) (*Node, error)
- func IntSerialize(x int64, params ...Parameter) (*Node, error)
- func NewConstructed(params ...Parameter) (n *Node)
- func NewNode(class int, tag int) *Node
- func NodeByTag(ns []*Node, tag int) *Node
- func NullSerialize(params ...Parameter) (*Node, error)
- func Serialize(v interface{}, params ...Parameter) (*Node, error)
- func StringSerialize(s string, params ...Parameter) (*Node, error)
- func UTCTimeSerialize(t time.Time, params ...Parameter) (*Node, error)
- func UintSerialize(x uint64, params ...Parameter) (*Node, error)
- func (n *Node) GetBool() (bool, error)
- func (n *Node) GetBytes() ([]byte, error)
- func (n *Node) GetClass() int
- func (n *Node) GetEnumerated() (int64, error)
- func (n *Node) GetGeneralizedTime() (time.Time, error)
- func (n *Node) GetInt() (int64, error)
- func (n *Node) GetNodes() ([]*Node, error)
- func (n *Node) GetOid() (string, error)
- func (n *Node) GetReal() (float64, error)
- func (n *Node) GetString() (string, error)
- func (n *Node) GetTag() int
- func (n *Node) GetUTCTime() (time.Time, error)
- func (n *Node) GetUint() (uint64, error)
- func (n *Node) IsConstructed() bool
- func (n *Node) IsPrimitive() bool
- func (n *Node) SetBool(b bool)
- func (n *Node) SetBytes(bs []byte)
- func (n *Node) SetInt(i int64)
- func (n *Node) SetNodes(ns []*Node)
- func (n *Node) SetString(s string)
- func (n *Node) SetUTCTime(t time.Time) error
- func (n *Node) SetUint(u uint64)
- type Optional
- type Parameter
- type Serializer
- type Tag
Constants ¶
View Source
const ( CLASS_UNIVERSAL = 0 CLASS_APPLICATION = 1 CLASS_CONTEXT_SPECIFIC = 2 CLASS_PRIVATE = 3 )
View Source
const ( TAG_END_OF_CONTENT = 0 // 0x00 TAG_BOOLEAN = 1 // 0x01 TAG_INTEGER = 2 // 0x02 TAG_BIT_STRING = 3 // 0x03 TAG_OCTET_STRING = 4 // 0x04 TAG_NULL = 5 // 0x05 TAG_OID = 6 // 0x06 TAG_REAL = 9 //0x09 TAG_ENUMERATED = 10 // 0x0A TAG_UTF8_STRING = 12 // 0x0C TAG_TIME = 14 // 0x0E TAG_SEQUENCE = 16 // 0x10 TAG_SET = 17 // 0x11 TAG_NUMBERIC_STRING = 18 // 0x12 TAG_PRINTABLE_STRING = 19 // 0x13 TAG_T61_STRING = 20 // 0x14 TAG_VIDEOTEX_STRING = 21 // 0x15 TAG_IA5_STRING = 22 // 0x16 TAG_UTC_TIME = 23 // 0x17 TAG_GENERALIZED_TIME = 24 // 0x18 TAG_BMP_STRING = 30 // 0x1E )
Universal types (tags) https://en.wikipedia.org/wiki/X.690#Types Permitted Construction is Primitive or Both
Variables ¶
View Source
var ( ErrNodeIsConstructed = errors.New("node is constructed") ErrNodeIsNotConstructed = errors.New("node is not constructed") )
Functions ¶
func CheckConstructed ¶
func ConvertToString ¶
func Deserialize ¶
func NullDeserialize ¶
Types ¶
type Deserializer ¶
type ErrorUnmarshalBytes ¶
type ErrorUnmarshalBytes struct {
// contains filtered or unexported fields
}
func (ErrorUnmarshalBytes) Bytes ¶
func (e ErrorUnmarshalBytes) Bytes() []byte
func (ErrorUnmarshalBytes) Error ¶
func (e ErrorUnmarshalBytes) Error() string
type ErrorUnmarshalInt ¶
type ErrorUnmarshalInt struct {
// contains filtered or unexported fields
}
func (ErrorUnmarshalInt) Error ¶
func (e ErrorUnmarshalInt) Error() string
type ErrorUnmarshalString ¶
type ErrorUnmarshalString struct {
// contains filtered or unexported fields
}
func (ErrorUnmarshalString) Bytes ¶
func (e ErrorUnmarshalString) Bytes() []byte
func (ErrorUnmarshalString) Error ¶
func (e ErrorUnmarshalString) Error() string
type ErrorUnmarshalUint ¶
type ErrorUnmarshalUint struct {
// contains filtered or unexported fields
}
func (ErrorUnmarshalUint) Error ¶
func (e ErrorUnmarshalUint) Error() string
type Node ¶
type Node struct { Data []byte `json:"-"` // Primitive: (isCompound = false) Value interface{} `json:"value,omitempty"` // Primitive: int/bool/string/time... (isCompound = false) Nodes []*Node `json:"nodes,omitempty"` // Constructed: (isCompound = true) // contains filtered or unexported fields }
func NewConstructed ¶
func NewNode ¶
func (n *Node) MarshalJSON() ([]byte, error) { if !n.constructed { jsonKey, jsonValue, err := n.toJsonKeyValue() if err != nil { fmt.Println("MarshalJSON fail:", err) return nil, err } ret := `{"` + jsonKey + `":"` + jsonValue + `"},` return []byte(ret), nil } else { for i, child := range n.Nodes { if b, err := child.MarshalJSON(); err != nil { fmt.Println("MarshalJSON child fail:", i, err) return nil, err } } } return []byte(strconv.FormatFloat(float64(f), 'f', -1, 64)), nil }
func NullSerialize ¶
func (*Node) GetEnumerated ¶
func (*Node) IsConstructed ¶
func (*Node) IsPrimitive ¶
type Serializer ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.