cipher

package
v0.0.0-...-5fbb372 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2019 License: LGPL-3.0 Imports: 14 Imported by: 0

Documentation

Overview

Copyright (C) 2018 go-gamc authors

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

This file is part of the go-gamc library.

the go-gamc library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

the go-gamc library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with the go-gamc library. If not, see <http://www.gnu.org/licenses/>.

Index

Constants

View Source
const (
	ScryptKDF = "scrypt"
	ScryptR   = 8
	ScryptN   = 1 << 12
	// LightScryptP is the P parameter of Scrypt encryption algorithm, using 4MB
	// memory and taking approximately 100ms CPU time on a modern processor.
	ScryptP = 6
	// ScryptDKLen get derived key length
	ScryptDKLen = 32
)

Variables

View Source
var (
	ErrDecrypt = errors.New("could not decrypt key with given passphrase")
	// ErrKDFInvalid cipher not supported
	ErrKDFInvalid = errors.New("kdf not supported")
	// ErrVersionInvalid version not supported
	ErrVersionInvalid = errors.New("version not supported")
)

Functions

func RandomCSPRNG

func RandomCSPRNG(n int) []byte

RandomCSPRNG a cryptographically secure pseudo-random number generator

Types

type Cipher

type Cipher struct {
	// contains filtered or unexported fields
}

func NewCipher

func NewCipher(alg uint8) *Cipher

func (*Cipher) Decrypt

func (c *Cipher) Decrypt(data []byte, passPhrase []byte) ([]byte, error)

func (*Cipher) DecryptKey

func (c *Cipher) DecryptKey(data []byte, passPhrase []byte) ([]byte, error)

func (*Cipher) Encrypt

func (c *Cipher) Encrypt(data []byte, passPhrase []byte) ([]byte, error)

func (*Cipher) EncryptKey

func (c *Cipher) EncryptKey(addressStr string, data []byte, passPhrase []byte) ([]byte, error)

type Encrypt

type Encrypt interface {
	Encrypt(data []byte, passphrase []byte) ([]byte, error)
	Decrypt(data []byte, passphrase []byte) ([]byte, error)
	EncryptKey(addressStr string, data []byte, passphrase []byte) ([]byte, error)
	DecryptKey(data []byte, passphrase []byte) ([]byte, error)
}

Encrypt interface for encrypt

type Scrypt

type Scrypt struct {
}

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(addressStr string, data []byte, passPhrase []byte) ([]byte, error)

func (*Scrypt) ScryptEncrypt

func (s *Scrypt) ScryptEncrypt(data []byte, passphrase []byte, N, r, p int) ([]byte, error)

Jump to

Keyboard shortcuts

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