Documentation
¶
Overview ¶
Package asn1 decodes BER-encoded ASN.1 data structures and encodes in DER. Note: DER is a subset of BER. Reference: http://luca.ntop.org/Teaching/Appunti/asn1.html
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( ErrEarlyEOF = asn1.SyntaxError{Msg: "early EOF"} ErrExpectConstructed = asn1.SyntaxError{Msg: "constructed value expected"} ErrExpectPrimitive = asn1.SyntaxError{Msg: "primitive value expected"} ErrUnsupportedLength = asn1.StructuralError{Msg: "length method not supported"} )
Common errors
Functions ¶
func ConvertToDER ¶
ConvertToDER converts BER-encoded ASN.1 data structures to DER-encoded.
Types ¶
type ConstructedValue ¶
type ConstructedValue struct {
// contains filtered or unexported fields
}
ConstructedValue represents a value in constructed encoding.
func (ConstructedValue) Encode ¶
func (v ConstructedValue) Encode(w ValueWriter) error
Encode encodes the constructed value to the value writer in DER.
func (ConstructedValue) EncodedLen ¶
func (v ConstructedValue) EncodedLen() int
EncodedLen returns the length in bytes of the encoded data.
type PrimitiveValue ¶
type PrimitiveValue struct {
// contains filtered or unexported fields
}
PrimitiveValue represents a value in primitive encoding.
func (PrimitiveValue) Encode ¶
func (v PrimitiveValue) Encode(w ValueWriter) error
Encode encodes the primitive value to the value writer in DER.
func (PrimitiveValue) EncodedLen ¶
func (v PrimitiveValue) EncodedLen() int
EncodedLen returns the length in bytes of the encoded data.
type Value ¶
type Value interface {
// Encode encodes the value to the value writer in DER.
Encode(ValueWriter) error
// EncodedLen returns the length in bytes of the encoded data.
EncodedLen() int
}
Value represents an ASN.1 value.
func Decode ¶
func Decode(r ValueReader) (Value, error)
Decode decodes BER-encoded ASN.1 data structures.
func DecodeConstructed ¶
func DecodeConstructed(r ValueReader) (Value, error)
DecodeConstructed decodes a constructed value in BER.
func DecodePrimitive ¶
func DecodePrimitive(r ValueReader) (Value, error)
DecodePrimitive decodes a primitive value in BER.
type ValueReader ¶
type ValueReader interface {
io.Reader
io.ByteScanner
}
ValueReader is the interface for reading a value.
func LimitValueReader ¶
func LimitValueReader(r ValueReader, n int64) ValueReader
LimitValueReader returns a ValueReader, which limits the amount of data returned.
type ValueWriter ¶
type ValueWriter interface {
io.Writer
io.ByteWriter
}
ValueWriter is the interface for writing a value.