v1

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jun 18, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DecryptErr = errors.New("message corrupt or incorrect password")
View Source
var (

	// The size of the Header.
	HeaderSize = 4 + saltSize + blockSize
)

Functions

func Hash

func Hash(plainTextR io.Reader, headerR io.Reader, key []byte, h hash.Hash) ([]byte, error)

Hash hashes the plaintext based on the header of the encrypted file and returns the hash Sum.

func HashWithPassword

func HashWithPassword(plainTextR io.Reader, headerR io.Reader, password []byte, h hash.Hash) ([]byte, error)

HashWithPassword hashes the plaintext based on the header of the encrypted file and returns the hash Sum.

func NewDecryptReader

func NewDecryptReader(r io.Reader, key []byte) (d io.ReadCloser, err error)

NewDecryptReader creates an io.ReadCloser wrapping an io.Reader using a password to derive the AES and HMAC keys. It has to read the entire io.Reader to disk using a temp file so that it can hash the contents to verify that it is safe to decrypt. If the file is athenticated, the DecryptReader will be returned and the resulting bytes will be the plaintext.

func NewDecryptReaderWithPassword

func NewDecryptReaderWithPassword(r io.Reader, pass []byte) (d io.ReadCloser, err error)

NewDecryptReaderWithPassword creates an io.ReadCloser wrapping an io.Reader using a password to derive the AES and HMAC keys. It has to read the entire io.Reader to disk using a temp file so that it can hash the contents to verify that it is safe to decrypt. If the file is athenticated, the DecryptReader will be returned and the resulting bytes will be the plaintext.

func NewEncryptReader

func NewEncryptReader(r io.Reader, key []byte) (io.Reader, error)

NewEncryptReader returns an io.Reader wrapping the provided io.Reader.

func NewEncryptReaderWithPassword

func NewEncryptReaderWithPassword(r io.Reader, pass []byte) (io.Reader, error)

NewEncryptReaderWithPassword returns an io.Reader wrapping the provided io.Reader. It uses a user provided password and a random salt to derive keys. If the key is provided interactively, it should be verified since there is no recovery.

func NewKey

func NewKey() ([]byte, error)

NewKey returns a new random key.

Types

This section is empty.

Jump to

Keyboard shortcuts

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