cipher

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Argon2KDF name
	Argon2KDF = "argon2id"

	StandardArgon2Time = 4

	StandardArgon2Memory = 256 * 1024

	StandardArgon2Threads = 4

	// Argon2DKLen get derived key length
	Argon2DKLen = 64

	Argon2CipherName = "aes-256-ctr"
)
View Source
const (
	// BalloonKDF name
	BalloonKDF = "balloon"

	StandardBalloonTime = 16

	StandardBalloonSpace = 8 * 1024

	// BalloonDKLen get derived key length
	BalloonDKLen = 64

	BalloonCipherName = "aes-256-ctr"
)
View Source
const (
	// ScryptKDF name
	ScryptKDF = "scrypt"

	// StandardScryptN N parameter of Scrypt encryption algorithm
	StandardScryptN = 1 << 17

	// StandardScryptR r parameter of Scrypt encryption algorithm
	StandardScryptR = 8

	// StandardScryptP p parameter of Scrypt encryption algorithm
	StandardScryptP = 1

	// ScryptDKLen get derived key length
	ScryptDKLen = 32

	ScryptCipherName = "aes-128-ctr"
)

Variables

View Source
var (
	// ErrVersionInvalid version not supported
	ErrVersionInvalid = errors.New("version not supported")

	// ErrKDFInvalid cipher not supported
	ErrKDFInvalid = errors.New("kdf not supported")

	// ErrCipherInvalid cipher not supported
	ErrCipherInvalid = errors.New("cipher not supported")

	// ErrDecrypt decrypt failed
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
)

Functions

This section is empty.

Types

type Argon2

type Argon2 struct {
	Time    uint32
	Memory  uint32
	Threads uint8
}

func NewArgon2

func NewArgon2() *Argon2

func (*Argon2) Decrypt

func (a *Argon2) Decrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Argon2) DecryptKey

func (a *Argon2) DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)

func (*Argon2) Encrypt

func (a *Argon2) Encrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Argon2) EncryptKey

func (a *Argon2) EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)

type Balloon

type Balloon struct {
	Time  uint64
	Space uint64
}

func NewBalloon

func NewBalloon() *Balloon

func (*Balloon) Decrypt

func (b *Balloon) Decrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Balloon) DecryptKey

func (b *Balloon) DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)

func (*Balloon) Encrypt

func (b *Balloon) Encrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Balloon) EncryptKey

func (b *Balloon) EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)

type Cipher

type Cipher interface {
	Encrypt(data []byte, passphrase []byte) ([]byte, error)

	EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)

	Decrypt(data []byte, passphrase []byte) ([]byte, error)

	DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)
}

type Scrypt

type Scrypt struct {
	N int
	R int
	P int
}

func NewScrypt

func NewScrypt() *Scrypt

func (*Scrypt) Decrypt

func (s *Scrypt) Decrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Scrypt) DecryptKey

func (s *Scrypt) DecryptKey(keyjson []byte, passphrase []byte) ([]byte, error)

func (*Scrypt) Encrypt

func (s *Scrypt) Encrypt(data []byte, passphrase []byte) ([]byte, error)

func (*Scrypt) EncryptKey

func (s *Scrypt) EncryptKey(address string, data []byte, passphrase []byte) ([]byte, error)

Jump to

Keyboard shortcuts

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