fixbuf

package module
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 24, 2019 License: GPL-3.0 Imports: 5 Imported by: 78

README

fixbuf

Fixed length binary encoding of arbitrary structures in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Read

func Read(r io.Reader, c Constructor, objs ...interface{}) error

Read is the default implementation of Encoding interface Read

func Write

func Write(w io.Writer, objs ...interface{}) error

Write is the default implementation of Encoding interface Write

Types

type BinaryEncoding

type BinaryEncoding struct {
	Constructor // Constructor for instantiating abstract types
	// contains filtered or unexported fields
}

BinaryEncoding represents a simple binary encoding suitable for reading and writing fixed-length cryptographic objects. The interface allows reading and writing composite types such as structs, arrays, and slices, but the encoded size of any object must be completely defined by the type and size of the object itself and the ciphersuite in use.

Slices must be instantiated to the correct length before either reading or writing: hence the reader must determine the correct length "out of band" (the encoding supports no transmission of length metadata).

func NewBinaryEncoding

func NewBinaryEncoding(c Constructor) *BinaryEncoding

NewBinaryEncoding returns a BinaryEncoding. The given c Constructor can be nil. In that case, the BinaryEncoding MUST not be used to Read() any structure can contains any interface fields implementing the Marshalling interface, because BinaryEncoding won't be able to create the concrete type of the field.

func (BinaryEncoding) Read

func (e BinaryEncoding) Read(r io.Reader, objs ...interface{}) error

Read a series of binary objects from an io.Reader. The objs must be a list of pointers.

func (BinaryEncoding) Write

func (e BinaryEncoding) Write(w io.Writer, objs ...interface{}) error

Write a data structure containing cryptographic objects, using their built-in binary serialization, to an io.Writer. Supports writing of Points, Scalars, basic fixed-length data types supported by encoding/binary/Write(), and structs, arrays, and slices containing all of these types.

type Constructor

type Constructor interface {
	New(t reflect.Type) interface{}
}

Constructor represents a generic constructor that takes a reflect.Type, typically for an interface type, and constructs some suitable concrete instance of that type. The crypto library uses this capability to support dynamic instantiation of cryptographic objects of the concrete type appropriate for a given abstract.Suite.

type Marshalling

type Marshalling interface {
	// Encode the contents of this object and write it to an io.Writer.
	MarshalTo(w io.Writer) (int, error)

	// Decode the content of this object by reading from an io.Reader.
	UnmarshalFrom(r io.Reader) (int, error)
}

Marshaling is a basic interface representing fixed-length (or known-length) cryptographic objects or structures having a built-in binary encoding.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL