codec

package
v0.6.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PlainDecoder

func PlainDecoder(r io.Reader, buf []byte) (int, error)

PlainDecoder reads data directly from the IO reader without modification. The entire buffer will be filled by reading data from the IO reader. This means that the buffer must be of the right length with respect to the data that is being read.

func PlainEncoder

func PlainEncoder(w io.Writer, buf []byte) (int, error)

PlainEncoder writes data directly to the IO writer without modification. The entire buffer is written.

Types

type Decoder

type Decoder func(r io.Reader, buf []byte) (int, error)

A Decoder is a function the decodes bytes from an I/O reader into a byte slice. It returns the number of bytes read, and errors that happen.

func GCMDecoder

func GCMDecoder(session *GCMSession, dec Decoder) Decoder

GCMDEcoder accepts a GCMSession and a decoder that wraps data decryption

func LengthPrefixDecoder

func LengthPrefixDecoder(prefixDec Decoder, bodyDec Decoder) Decoder

LengthPrefixDecoder returns an Decoder that assumes all data is prefixed with a uint32 length. The returned Decoder wraps two other Decoders, one that is used to decode the length prefix, and one that is used to decode the actual data.

type Encoder

type Encoder func(w io.Writer, buf []byte) (int, error)

An Encoder is a function that encodes a byte slice into an I/O writer. It returns the number of bytes written, and errors that happen.

func GCMEncoder

func GCMEncoder(session *GCMSession, enc Encoder) Encoder

GCMEncoder accepts a GCMSession and an encoder that wraps data encryption

func LengthPrefixEncoder

func LengthPrefixEncoder(prefixEnc Encoder, bodyEnc Encoder) Encoder

LengthPrefixEncoder returns an Encoder that prefixes all data with a uint32 length. The returned Encoder wraps two other Encoders, one that is used to encode the length prefix, and one that is used to encode the actual data.

type GCMSession

type GCMSession struct {
	// contains filtered or unexported fields
}

A GCMSession stores the state of a GCM authenticated/encrypted session. This includes the read/write nonces, memory buffers, and the GCM cipher itself.

func NewGCMSession

func NewGCMSession(key [32]byte, self, remote id.Signatory) (*GCMSession, error)

NewGCMSession accepts a symmetric secret key and returns a new GCMSession that is configured using the symmetric secret key.

Jump to

Keyboard shortcuts

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