privacy

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSaltLen      = errors.New("invalid salt length")
	ErrUninitialisedSalt   = errors.New("uninitialised salt")
	ErrUninitialisedMethod = errors.New("cipher method type uninitialised")
	//ErrCannotReadMagicBytes = errors.New("cannot read magic bytes")	//no usage for now
	ErrInvalidReadFlow      = errors.New("func ReadMagic should be called before calling Read")
	ErrInvalidKeyState      = errors.New("func GenerateKey should be called first")
	ErrInvalidSegmentLength = errors.New("segment length is too long")
)
View Source
var ErrInvalidParameter = errors.New("invalid parameter")

Functions

This section is empty.

Types

type CipherMethodType

type CipherMethodType byte
const (
	Uninitialised   CipherMethodType = 0x00
	XChaCha20Simple CipherMethodType = 0x01
	AES256GCMSimple CipherMethodType = 0x02

	DefaultCipherMethod = XChaCha20Simple
)

type InvalidCipherMethod

type InvalidCipherMethod []byte

func (InvalidCipherMethod) Error

func (i InvalidCipherMethod) Error() string

type KeyGen

type KeyGen interface {
	json.Marshaler
	GenerateKey(password, salt []byte) []byte
}

func NewArgon2

func NewArgon2() KeyGen

func NewArgon2WithParams

func NewArgon2WithParams(time, memory uint32, threads uint8) (k KeyGen, err error)

type Privacy

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

func (*Privacy) GenerateKey

func (p *Privacy) GenerateKey(passphrase string) error

func (*Privacy) GetSegmentSize

func (p *Privacy) GetSegmentSize() uint32

func (*Privacy) NewSalt

func (p *Privacy) NewSalt() error

func (*Privacy) SetSalt

func (p *Privacy) SetSalt(salt []byte) error

func (*Privacy) SetSegmentSize

func (p *Privacy) SetSegmentSize(size uint32)

type Reader

type Reader struct {
	*Privacy
	// contains filtered or unexported fields
}

func NewPrivacyReader

func NewPrivacyReader(reader io.Reader) *Reader

func NewPrivacyReaderWithKeyGen

func NewPrivacyReaderWithKeyGen(reader io.Reader, keygen KeyGen) *Reader

func (*Reader) Read

func (r *Reader) Read(b []byte) (n int, err error)

func (*Reader) ReadMagic

func (r *Reader) ReadMagic() (err error)

type WriteCloser

type WriteCloser struct {
	*Privacy
	// contains filtered or unexported fields
}

func NewPrivacyWriteCloser

func NewPrivacyWriteCloser(wc io.WriteCloser, cmType CipherMethodType) *WriteCloser

func NewPrivacyWriteCloserWithKeyGen

func NewPrivacyWriteCloserWithKeyGen(wc io.WriteCloser, cmType CipherMethodType, keygen KeyGen) *WriteCloser

func NewPrivacyWriterCloserDefault

func NewPrivacyWriterCloserDefault(wc io.WriteCloser) *WriteCloser

func (*WriteCloser) Close

func (wc *WriteCloser) Close() (err error)

func (*WriteCloser) Write

func (wc *WriteCloser) Write(b []byte) (n int, err error)

Jump to

Keyboard shortcuts

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