cryptoutil

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2021 License: MIT Imports: 14 Imported by: 0

README

cryptoutil

GoDoc cryptoutil is a wrapper for some commonly used crypto functions

Documentation

Index

Constants

View Source
const (
	SaltLen   = 32
	KeyLen    = 32
	NonceLen  = 24
	ScryptLen = 24
)

Variables

View Source
var ScryptConfigHigh = ScryptConfig{
	N: 1 << uint64(19),
	R: 8,
	P: 1,
}

ScryptConfigHigh requires 512MB RAM for less than 5 seconds (i7).

View Source
var ScryptConfigLow = ScryptConfig{
	N: 1 << uint64(17),
	R: 8,
	P: 1,
}

ScryptConfigLow requires 128MB RAM for about a second (i7).

View Source
var ScryptConfigMid = ScryptConfig{
	N: 1 << uint64(18),
	R: 8,
	P: 1,
}

ScryptConfigMid requires 256MB RAM for less than 5 seconds (i7).

View Source
var ScryptConfigParanoid = ScryptConfig{
	N: 1 << uint64(20),
	R: 8,
	P: 1,
}

ScryptConfigParanoid requires 1GB RAM for about 5 seconds (i7).

View Source
var ScryptConfigRealtime = ScryptConfig{
	N: 1 << uint64(15),
	R: 8,
	P: 1,
}

ScryptConfigRealtime requires 32MB RAM for under a second (i7).

Functions

func Decrypt

func Decrypt(key *[KeyLen]byte, data []byte) ([]byte, error)

panics if key is nil

func Encrypt

func Encrypt(key *[KeyLen]byte, data []byte) ([]byte, error)

func GenerateSalt

func GenerateSalt() ([]byte, error)

Types

type Entity added in v0.0.2

type Entity struct {
	PGP *openpgp.Entity
}

func CreateEntity added in v0.0.2

func CreateEntity(name, comment, email string) (*Entity, error)

func LoadEntity added in v0.0.2

func LoadEntity(b []byte) (*Entity, error)

func (*Entity) Encrypt added in v0.0.2

func (e *Entity) Encrypt(r io.Reader) ([]byte, error)

func (*Entity) PrivateKey added in v0.0.2

func (e *Entity) PrivateKey() ([]byte, error)

func (*Entity) PublicKey added in v0.0.2

func (e *Entity) PublicKey() ([]byte, error)

func (*Entity) Sign added in v0.0.2

func (e *Entity) Sign(r io.Reader) ([]byte, error)

func (*Entity) UserID added in v0.0.2

func (e *Entity) UserID() *packet.UserId

func (*Entity) Verify added in v0.0.2

func (e *Entity) Verify(r io.Reader, signature []byte) error

type PublicKey added in v0.0.2

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

func LoadPublicKey added in v0.0.2

func LoadPublicKey(b []byte) (*PublicKey, error)

func (*PublicKey) Verify added in v0.0.2

func (pub *PublicKey) Verify(r io.Reader, signature []byte) error

type ScryptConfig

type ScryptConfig struct {
	// CPU/memory cost parameter (logN)
	N uint64 `json:"n"`

	// block size parameter (octets)
	R uint64 `json:"r"`

	// parallelisation parameter (positive int)
	P uint64 `json:"p"`
}

func DecodeScryptConfig

func DecodeScryptConfig(data []byte) (ScryptConfig, error)

func (ScryptConfig) Decrypt

func (config ScryptConfig) Decrypt(password string, data []byte) ([]byte, error)

func (ScryptConfig) Derive

func (config ScryptConfig) Derive(salt []byte, password string) (*[KeyLen]byte, error)

func (ScryptConfig) Encode

func (config ScryptConfig) Encode() []byte

func (ScryptConfig) Encrypt

func (config ScryptConfig) Encrypt(password string, data []byte) ([]byte, error)

func (ScryptConfig) MemoryRequiredMB

func (config ScryptConfig) MemoryRequiredMB() int

func (ScryptConfig) String

func (config ScryptConfig) String() string

func (ScryptConfig) TimeRequiredMS

func (config ScryptConfig) TimeRequiredMS() (int, error)

Jump to

Keyboard shortcuts

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