keymgt

package
Version: v0.0.0-...-cf48056 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2018 License: BSD-3-Clause Imports: 8 Imported by: 2

Documentation

Overview

Package keymgt implements trivial binary encoding for nacl public/private keys

Index

Constants

View Source
const (
	// SaltField is the salt used for encryption
	SaltField = iota + 1
	// PasswordFlagField shows if a password is set
	PasswordFlagField
	// MyPublicKey is my public key
	MyPublicKey
	// CryptPublicKey is the public key for encryption
	CryptPublicKey
	// Nonce is the nonce for NaCL encryption
	Nonce
	// NaCLBox is the encrypted data
	NaCLBox
	// PrivateKey is the private key
	PrivateKey
	// ExtraData is additional data added to the secret part
	ExtraData
)

Variables

View Source
var (

	// ErrMissingField is returned when fields are missing
	ErrMissingField = errors.New("keymgt: missing fields")
	// ErrMissingPassword is returned if no needed password was given
	ErrMissingPassword = errors.New("keymgt: no password when one was needed")
	// ErrWrongPassword is returned if the private key cannot be decrypted
	ErrWrongPassword = errors.New("keymgt: wrong password")
)

Functions

func GenerateKey

func GenerateKey(password, extradata []byte) (keyfile, mpubkey, mprivkey []byte, err error)

GenerateKey returns a keyfile, optionally encrypted by password. Extradata can be appended

func LoadKey

func LoadKey(keyfile, password []byte) (pubkey, privkey, extradata []byte, err error)

LoadKey returns public and private keys from keyfile, decrypts with password if necessary

func SaveKey

func SaveKey(pubkey, privkey, password, extradata []byte) (keyfile, mpubkey, mprivkey []byte, err error)

SaveKey stores a keypair, optionally encrypted with a password

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL