v1

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2020 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

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

	// The overhead added to the file by using this library.
	// Overhead + len(plaintext) == len(ciphertext)
	Overhead = HeaderSize + hmacSize
)
View Source
var DecryptErr = errors.New("message corrupt or incorrect password")

Functions

func Hash

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

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

func NewDecryptReader

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

NewDecryptReader creates an io.ReadCloser wrapping an io.Reader. 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, pass []byte) (io.Reader, error)

NewEncryptReader 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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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