enc

package
v0.0.0-...-3cef9f2 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeReader

func DecodeReader(r io.Reader, c Codec, key *[32]byte, startingBlockNum int64) io.Reader

DecodeReader applies a Codec's decoding to a given reader, starting at the given startingBlockNum (usually 0).

func EncodeReader

func EncodeReader(r io.Reader, c Codec, key *[32]byte, startingBlockNum int64) io.Reader

EncodeReader applies a Codec's encoding to a given reader, starting at the given startingBlockNum (usually 0).

Types

type Codec

type Codec interface {
	EncodedBlockSize() int
	DecodedBlockSize() int
	Encode(out, in []byte, key *[32]byte, blockNum int64) ([]byte, error)
	Decode(out, in []byte, key *[32]byte, blockNum int64) ([]byte, error)
}

A Codec concisely represents a reversible transformation that might be applied to a data stream, such as encryption.

func Reverse

func Reverse(c Codec) Codec

Reverse returns a new Codec with the opposite data transformation of the provided Codec

type CodecMap

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

func NewCodecMap

func NewCodecMap(defaultCodec Codec) *CodecMap

func (*CodecMap) CodecForPath

func (m *CodecMap) CodecForPath(path string) Codec

func (*CodecMap) Register

func (m *CodecMap) Register(suffix string, c Codec)

type EncWrapper

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

EncWrapper wraps a Backend with encryption.

func NewEncWrapper

func NewEncWrapper(encryption *CodecMap, keyGen KeyGenerator, backend backends.Backend) *EncWrapper

NewEncWrapper returns a new Backend with the provided encryption

func (*EncWrapper) Close

func (e *EncWrapper) Close() error

func (*EncWrapper) Delete

func (e *EncWrapper) Delete(ctx context.Context, path string) error

Delete implements the Backend interface

func (*EncWrapper) Get

func (e *EncWrapper) Get(ctx context.Context, path string, offset, length int64) (io.ReadCloser, error)

Get implements the Backend interface

func (*EncWrapper) List

func (e *EncWrapper) List(ctx context.Context, prefix string,
	cb func(ctx context.Context, path string) error) error

List implements the Backend interface

func (*EncWrapper) Put

func (e *EncWrapper) Put(ctx context.Context, path string, data io.Reader) error

Put implements the Backend interface

type HMACKeyGenerator

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

HMACKeyGenerator is a KeyGenerator that simply SHA256-HMACs the provided root key with any given full path.

func NewHMACKeyGenerator

func NewHMACKeyGenerator(rootKey []byte) *HMACKeyGenerator

func (*HMACKeyGenerator) KeyForPath

func (s *HMACKeyGenerator) KeyForPath(path string) (key [32]byte)

type KeyGenerator

type KeyGenerator interface {
	KeyForPath(path string) [32]byte
}

A KeyGenerator determines the encryption key to use for a given backend path

type SecretboxCodec

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

SecretboxCodec provides the NaCl 'secretbox' encryption scheme as a Codec. Nonces are monotonic with blocks starting with 0.

func NewSecretboxCodec

func NewSecretboxCodec(unencryptedBlockSize int) *SecretboxCodec

NewSecretboxCodec creates a SecretboxCodec with the given unencrypted block size. A good choice here is 16*1024, or 16*1024-secretbox.Overhead, depending on your alignment needs.

func (*SecretboxCodec) Decode

func (s *SecretboxCodec) Decode(out, in []byte, key *[32]byte, blockNum int64) ([]byte, error)

func (*SecretboxCodec) DecodedBlockSize

func (s *SecretboxCodec) DecodedBlockSize() int

func (*SecretboxCodec) Encode

func (s *SecretboxCodec) Encode(out, in []byte, key *[32]byte, blockNum int64) ([]byte, error)

func (*SecretboxCodec) EncodedBlockSize

func (s *SecretboxCodec) EncodedBlockSize() int

Jump to

Keyboard shortcuts

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