Documentation ¶
Index ¶
- Variables
- func Hash(plainTextR io.Reader, headerR io.Reader, key []byte, h hash.Hash) ([]byte, error)
- func HashWithPassword(plainTextR io.Reader, headerR io.Reader, password []byte, h hash.Hash) ([]byte, error)
- func NewDecryptReader(r io.Reader, key []byte) (d io.ReadCloser, err error)
- func NewDecryptReaderWithPassword(r io.Reader, pass []byte) (d io.ReadCloser, err error)
- func NewEncryptReader(r io.Reader, key []byte) (io.Reader, error)
- func NewEncryptReaderWithPassword(r io.Reader, pass []byte) (io.Reader, error)
- func NewKey() ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
var DecryptErr = errors.New("message corrupt or incorrect password")
var (
// The size of the Header.
HeaderSize = 4 + saltSize + blockSize
)
Functions ¶
func Hash ¶
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 ¶
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 ¶
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 ¶
NewEncryptReader returns an io.Reader wrapping the provided io.Reader.
func NewEncryptReaderWithPassword ¶
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.
Types ¶
This section is empty.