keyring

package
v1.8.4 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2018 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PrivateKey

type PrivateKey struct {
	PublicKey
	Encrypted     bool
	EncryptedData []byte

	Nonce [nonceLength]byte // for private key encryption

	Salt []byte // for KDF
	// contains filtered or unexported fields
}

PrivateKey is a private key part of a keypair

func GenerateKeypair

func GenerateKeypair(passphrase string) (*PrivateKey, error)

GenerateKeypair generates a new keypair

func (*PrivateKey) Decrypt

func (p *PrivateKey) Decrypt(passphrase string) error

Decrypt decrypts the private key

func (*PrivateKey) Encrypt

func (p *PrivateKey) Encrypt(passphrase string) error

Encrypt encrypts the private key material with the given passphrase

func (*PrivateKey) PrivateKey

func (p *PrivateKey) PrivateKey() [keyLength]byte

PrivateKey returns the decrypted private key material

type PublicKey

type PublicKey struct {
	CreationTime time.Time
	PubKeyAlgo   PublicKeyAlgorithm
	PublicKey    [32]byte
	Identity     *xcpb.Identity
}

PublicKey is the public part of a keypair

func (PublicKey) Fingerprint

func (p PublicKey) Fingerprint() string

Fingerprint calculates the unique ID of a public key

type PublicKeyAlgorithm

type PublicKeyAlgorithm uint8

PublicKeyAlgorithm is a type of public key algorithm

const (
	// PubKeyNaCl is a NaCl (Salt) based public key
	PubKeyNaCl PublicKeyAlgorithm = iota
)

type Pubring

type Pubring struct {
	File string

	sync.Mutex
	// contains filtered or unexported fields
}

Pubring is a public key ring

func LoadPubring

func LoadPubring(file string, sec *Secring) (*Pubring, error)

LoadPubring loads an existing keyring from disk. If the file is not found an empty keyring is returned.

func NewPubring

func NewPubring(sec *Secring) *Pubring

NewPubring initializes a new public key ring

func (*Pubring) Contains

func (p *Pubring) Contains(fp string) bool

Contains checks if a given key is in the keyring

func (*Pubring) Export

func (p *Pubring) Export(id string) ([]byte, error)

Export marshals a single key

func (*Pubring) Get

func (p *Pubring) Get(id string) *PublicKey

Get returns a single key

func (*Pubring) Import

func (p *Pubring) Import(buf []byte) error

Import unmarshals and inserts and previously exported key

func (*Pubring) KeyIDs

func (p *Pubring) KeyIDs() []string

KeyIDs returns a list of all key IDs

func (*Pubring) Remove

func (p *Pubring) Remove(id string) error

Remove deletes a single key

func (*Pubring) Save

func (p *Pubring) Save() error

Save writes the keyring to the previously set location on disk

func (*Pubring) Set

func (p *Pubring) Set(pk *PublicKey) error

Set inserts a key, possibly overwriting and existing entry

type Secring

type Secring struct {
	File string

	sync.Mutex
	// contains filtered or unexported fields
}

Secring is private key ring

func LoadSecring

func LoadSecring(file string) (*Secring, error)

LoadSecring loads an existing secring from disk. If the file is not found an empty keyring is returned

func NewSecring

func NewSecring() *Secring

NewSecring initializes and a new secring

func (*Secring) Contains

func (p *Secring) Contains(fp string) bool

Contains returns true if the given key is found in the keyring

func (*Secring) Export

func (p *Secring) Export(id string, withPrivate bool) ([]byte, error)

Export marshals a single private key

func (*Secring) Get

func (p *Secring) Get(id string) *PrivateKey

Get returns a single key

func (*Secring) Import

func (p *Secring) Import(buf []byte) error

Import unmarshals and imports a previously exported key

func (*Secring) KeyIDs

func (p *Secring) KeyIDs() []string

KeyIDs returns a list of key IDs

func (*Secring) Remove

func (p *Secring) Remove(id string) error

Remove deletes the given key

func (*Secring) Save

func (p *Secring) Save() error

Save writes the keyring to the previously set location on disk

func (*Secring) Set

func (p *Secring) Set(pk *PrivateKey) error

Set inserts a single key

Jump to

Keyboard shortcuts

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