package cryptobyte

Import Path
	vendor/golang.org/x/crypto/cryptobyte (on golang.org and go.dev)

Dependency Relation
	imports 7 packages, and imported by 3 packages

Involved Source Files
	    asn1.go
	    builder.go
	d-> string.go

Exported Type Names

type Builder (struct) A Builder builds byte strings from fixed-length and length-prefixed values. Builders either allocate space as needed, or are ‘fixed’, which means that they write into a given buffer and produce an error if it's exhausted. The zero value is a usable Builder that allocates space as needed. Simple values are marshaled and appended to a Builder using methods on the Builder. Length-prefixed values are marshaled by providing a BuilderContinuation, which is a function that writes the inner contents of the value to a given Builder. See the documentation for BuilderContinuation for details. (*T) AddASN1(tag asn1.Tag, f BuilderContinuation) (*T) AddASN1BigInt(n *big.Int) (*T) AddASN1BitString(data []byte) (*T) AddASN1Boolean(v bool) (*T) AddASN1Enum(v int64) (*T) AddASN1GeneralizedTime(t time.Time) (*T) AddASN1Int64(v int64) (*T) AddASN1Int64WithTag(v int64, tag asn1.Tag) (*T) AddASN1NULL() (*T) AddASN1ObjectIdentifier(oid encoding_asn1.ObjectIdentifier) (*T) AddASN1OctetString(bytes []byte) (*T) AddASN1Uint64(v uint64) (*T) AddBytes(v []byte) (*T) AddUint16(v uint16) (*T) AddUint16LengthPrefixed(f BuilderContinuation) (*T) AddUint24(v uint32) (*T) AddUint24LengthPrefixed(f BuilderContinuation) (*T) AddUint32(v uint32) (*T) AddUint32LengthPrefixed(f BuilderContinuation) (*T) AddUint8(v uint8) (*T) AddUint8LengthPrefixed(f BuilderContinuation) (*T) AddValue(v MarshalingValue) (*T) Bytes() ([]byte, error) (*T) BytesOrPanic() []byte (*T) MarshalASN1(v interface{}) (*T) SetError(err error) (*T) Unwrite(n int) func NewBuilder(buffer []byte) *Builder func NewFixedBuilder(buffer []byte) *Builder func MarshalingValue.Marshal(b *Builder) error
type BuilderContinuation (func) BuilderContinuation is a continuation-passing interface for building length-prefixed byte sequences. Builder methods for length-prefixed sequences (AddUint8LengthPrefixed etc) will invoke the BuilderContinuation supplied to them. The child builder passed to the continuation can be used to build the content of the length-prefixed sequence. For example: parent := cryptobyte.NewBuilder() parent.AddUint8LengthPrefixed(func (child *Builder) { child.AddUint8(42) child.AddUint8LengthPrefixed(func (grandchild *Builder) { grandchild.AddUint8(5) }) }) It is an error to write more bytes to the child than allowed by the reserved length prefix. After the continuation returns, the child must be considered invalid, i.e. users must not store any copies or references of the child that outlive the continuation. If the continuation panics with a value of type BuildError then the inner error will be returned as the error from Bytes. If the child panics otherwise then Bytes will repanic with the same value. func (*Builder).AddASN1(tag asn1.Tag, f BuilderContinuation) func (*Builder).AddUint16LengthPrefixed(f BuilderContinuation) func (*Builder).AddUint24LengthPrefixed(f BuilderContinuation) func (*Builder).AddUint32LengthPrefixed(f BuilderContinuation) func (*Builder).AddUint8LengthPrefixed(f BuilderContinuation)
type BuildError (struct) BuildError wraps an error. If a BuilderContinuation panics with this value, the panic will be recovered and the inner error will be returned from Builder.Bytes. Err error
type MarshalingValue (interface) A MarshalingValue marshals itself into a Builder. (T) Marshal(b *Builder) error func (*Builder).AddValue(v MarshalingValue)
type String ([]) String represents a string of bytes. It provides methods for parsing fixed-length and length-prefixed values from it. (*T) CopyBytes(out []byte) bool (T) Empty() bool (T) PeekASN1Tag(tag asn1.Tag) bool (*T) ReadASN1(out *String, tag asn1.Tag) bool (*T) ReadASN1BitString(out *encoding_asn1.BitString) bool (*T) ReadASN1BitStringAsBytes(out *[]byte) bool (*T) ReadASN1Boolean(out *bool) bool (*T) ReadASN1Bytes(out *[]byte, tag asn1.Tag) bool (*T) ReadASN1Element(out *String, tag asn1.Tag) bool (*T) ReadASN1Enum(out *int) bool (*T) ReadASN1GeneralizedTime(out *time.Time) bool (*T) ReadASN1Int64WithTag(out *int64, tag asn1.Tag) bool (*T) ReadASN1Integer(out interface{}) bool (*T) ReadASN1ObjectIdentifier(out *encoding_asn1.ObjectIdentifier) bool (*T) ReadAnyASN1(out *String, outTag *asn1.Tag) bool (*T) ReadAnyASN1Element(out *String, outTag *asn1.Tag) bool (*T) ReadBytes(out *[]byte, n int) bool (*T) ReadOptionalASN1(out *String, outPresent *bool, tag asn1.Tag) bool (*T) ReadOptionalASN1Boolean(out *bool, defaultValue bool) bool (*T) ReadOptionalASN1Integer(out interface{}, tag asn1.Tag, defaultValue interface{}) bool (*T) ReadOptionalASN1OctetString(out *[]byte, outPresent *bool, tag asn1.Tag) bool (*T) ReadUint16(out *uint16) bool (*T) ReadUint16LengthPrefixed(out *String) bool (*T) ReadUint24(out *uint32) bool (*T) ReadUint24LengthPrefixed(out *String) bool (*T) ReadUint32(out *uint32) bool (*T) ReadUint8(out *uint8) bool (*T) ReadUint8LengthPrefixed(out *String) bool (*T) Skip(n int) bool (*T) SkipASN1(tag asn1.Tag) bool (*T) SkipOptionalASN1(tag asn1.Tag) bool func (*String).ReadAnyASN1(out *String, outTag *asn1.Tag) bool func (*String).ReadAnyASN1Element(out *String, outTag *asn1.Tag) bool func (*String).ReadASN1(out *String, tag asn1.Tag) bool func (*String).ReadASN1Element(out *String, tag asn1.Tag) bool func (*String).ReadOptionalASN1(out *String, outPresent *bool, tag asn1.Tag) bool func (*String).ReadUint16LengthPrefixed(out *String) bool func (*String).ReadUint24LengthPrefixed(out *String) bool func (*String).ReadUint8LengthPrefixed(out *String) bool
Exported Values
func NewBuilder(buffer []byte) *Builder NewBuilder creates a Builder that appends its output to the given buffer. Like append(), the slice will be reallocated if its capacity is exceeded. Use Bytes to get the final buffer.
func NewFixedBuilder(buffer []byte) *Builder NewFixedBuilder creates a Builder that appends its output into the given buffer. This builder does not reallocate the output buffer. Writes that would exceed the buffer's capacity are treated as an error.