cipherfactory

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrEncryptionConfig is used as an error when given string representation if the
	// key can not be interpreted
	ErrInvalidEncryptionConfig = errors.New("invalid encryption config")

	ErrInvalidEncryptionConfigKeyType = fmt.Errorf("%w: wrong key type", ErrInvalidEncryptionConfig)
	ErrInvalidEncryptionConfigKeySize = fmt.Errorf("%w: wrong XChaCha20 key size, expected %d bytes", ErrInvalidEncryptionConfig, chacha20.KeySize+1)
	ErrInvalidEncryptionConfigIVSize  = fmt.Errorf("%w: wrong XChaCha20 iv size, expected %d bytes", ErrInvalidEncryptionConfig, chacha20.NonceSizeX)
)

Functions

func StreamCipherReader

func StreamCipherReader(key Key, iv IV, r io.Reader) (io.Reader, error)

func StreamCipherWriter

func StreamCipherWriter(key Key, iv IV, w io.Writer) (io.Writer, error)

Types

type IV

type IV []byte

IV

type IVGenerator

type IVGenerator interface {
	io.Writer
	Generate() IV
}

func NewIVGenerator

func NewIVGenerator(t common.BlobType) IVGenerator

type Key

type Key []byte

Key with cipher type

func (Key) DefaultIV

func (k Key) DefaultIV() IV

type KeyGenerator

type KeyGenerator interface {
	io.Writer
	Generate() Key
}

func NewKeyGenerator

func NewKeyGenerator(t common.BlobType) KeyGenerator

Jump to

Keyboard shortcuts

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