cryptoutil

package module
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2019 License: MIT Imports: 14 Imported by: 0

README

cryptoutil

collection of 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 Identity

type Identity struct {
	Entity *openpgp.Entity
}

func CreateIdentity

func CreateIdentity(name, comment, email string) (*Identity, error)

func LoadIdentity

func LoadIdentity(b []byte) (*Identity, error)

func (*Identity) Encode

func (i *Identity) Encode() ([]byte, error)

func (*Identity) PublicKey

func (i *Identity) PublicKey() ([]byte, error)

func (*Identity) Sign

func (i *Identity) Sign(r io.Reader) ([]byte, error)

func (*Identity) UserID

func (i *Identity) UserID() *packet.UserId

func (*Identity) Verify

func (i *Identity) 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