crypt

package module
v0.0.0-...-65899cf Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2015 License: ISC Imports: 11 Imported by: 28

README

crypt

Package crypt provides password-based encryption and decryption of data streams.

Documentation

Overview

Package crypt provides password-based encryption and decryption of data streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Crypter

type Crypter struct {
	HashFunc func() hash.Hash
	HashSize int
	Key      Key
	BufSize  int
}

Crypter encrypt/decrypts with AES (Rijndael) in cipher block counter mode (CTR) and authenticate with HMAC-SHA.

func (*Crypter) Decrypt

func (c *Crypter) Decrypt(dst io.Writer, src io.Reader) (err error)

Decrypt decrypts from src until either EOF is reached on src or an error occurs. A successful Decrypt returns err == nil, not err == EOF.

func (*Crypter) Encrypt

func (c *Crypter) Encrypt(dst io.Writer, src io.Reader) (err error)

Encrypt encrypts from src until either EOF is reached on src or an error occurs. A successful Encrypt returns err == nil, not err == EOF.

type Key

type Key interface {
	// Derive returns the AES key and HMAC-SHA key, for the given password,
	// salt combination.
	Derive(salt []byte) (aesKey, hmacKey []byte)

	// Size returns the key-size. Key-size should either 16, 24, or 32 to
	// select AES-128, AES-192, or AES-256.
	Size() int

	// Reset resets/flushes the key.
	Reset()
}

Key defines the key derivation function interface.

func NewPbkdf2Key

func NewPbkdf2Key(password []byte, size int) Key

NewPbkdf2Key returns the key derivation function PBKDF2 as defined in RFC 2898.

func NewScryptKey

func NewScryptKey(password []byte, size int) Key

NewScryptKey returns the scrypt key derivation function as defined in Colin Percival's paper "Stronger Key Derivation via Sequential Memory-Hard Functions".

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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