keypairs

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WipeGlobalKeyPairsIfValid

func WipeGlobalKeyPairsIfValid()

Types

type KeyPairStore

type KeyPairStore interface {
	Count() int
	CreateNewKeyPair(name string) (*security.KeyPairInfo, error)
	GetKeyPairInfo(name string) *security.KeyPairInfo
	LoadKeyPairStoreFromFile(key []byte, filePath string) error
	RemoveKeyPair(name string) (bool, error)
	RenameKeyPair(currentName, newName string) (found bool, err error)
	SaveKeyPairStore(key []byte, storeFilePath string) error
	SaveKeyPairStoreToOrigin(key []byte) error
	SetPassword(newPassword []byte)
	Walk(sort bool, walkFunc KeyPairStoreWalkFunc)
	WipeData()
}
var GlobalKeyPairStore KeyPairStore

func NewKeypairStore

func NewKeypairStore() KeyPairStore

func NewKeypairStoreFromFile

func NewKeypairStoreFromFile(key []byte, filePath string) (KeyPairStore, error)

func NewKeypairStoreWithKeypair

func NewKeypairStoreWithKeypair(name string) (KeyPairStore, *security.KeyPairInfo, error)

type KeyPairStoreWalkFunc

type KeyPairStoreWalkFunc func(kpi *security.KeyPairInfo)

type SimpleKeyPairStore

type SimpleKeyPairStore struct {

	// KeyPairs stores the key data in a map for native lookups
	KeyPairs map[string]*security.KeyPairInfo

	// StoreKey stores the key used to read the keystore into this struct to use for future writes
	StoreKey []byte `msgpack:"-"`

	// OriginFilePath stores the filepath from a prior file load for future saves after keypair changes
	OriginFilePath string `msgpack:"-"`
	// contains filtered or unexported fields
}

SimpleKeyPairStore will be the storage file for the local account key pairs created in this profile

func (*SimpleKeyPairStore) Count

func (kps *SimpleKeyPairStore) Count() int

func (*SimpleKeyPairStore) CreateNewKeyPair

func (kps *SimpleKeyPairStore) CreateNewKeyPair(name string) (*security.KeyPairInfo, error)

func (*SimpleKeyPairStore) GetKeyPairInfo

func (kps *SimpleKeyPairStore) GetKeyPairInfo(name string) *security.KeyPairInfo

func (*SimpleKeyPairStore) Initialize

func (kps *SimpleKeyPairStore) Initialize() error

Initialize does the following... - Clears the store - Creates and stores a new keypair with the name "default"

func (*SimpleKeyPairStore) ListKeyPairs

func (kps *SimpleKeyPairStore) ListKeyPairs() []*security.KeyPairInfo

func (*SimpleKeyPairStore) LoadKeyPairStoreFromFile

func (kps *SimpleKeyPairStore) LoadKeyPairStoreFromFile(key []byte, storeFilePath string) error

LoadKeyPairStoreFromFile checks the marker byte. If it is 0, then the file is NOT encrypted and the key is ignored. If it is NOT 0, then it attempts to decrypt the file data. The data is loaded into a keypair store. Then the receiver kp store is updated in place. This is a replacement pattern. If a key is provided, it overwrites kps.StoreKey. Otherwise, StoreKey is used if is set.

func (*SimpleKeyPairStore) RemoveKeyPair

func (kps *SimpleKeyPairStore) RemoveKeyPair(name string) (bool, error)

func (*SimpleKeyPairStore) RenameKeyPair

func (kps *SimpleKeyPairStore) RenameKeyPair(currentName, newName string) (found bool, err error)

func (*SimpleKeyPairStore) SaveKeyPairStore

func (kps *SimpleKeyPairStore) SaveKeyPairStore(key []byte, storeFilePath string) error

SaveKeyPairStore writes the keypair data to the file path provided. If key is provided, it will take priority over the kps.KeyPairStoreKey value. If key is nil, kps.KeyPairStoreKey will be used, if it is set. If neither key nor kps.KeyPairStoreKey are set, it will be written out unencrypted.

func (*SimpleKeyPairStore) SaveKeyPairStoreToOrigin

func (kps *SimpleKeyPairStore) SaveKeyPairStoreToOrigin(key []byte) error

func (*SimpleKeyPairStore) SetPassword

func (kps *SimpleKeyPairStore) SetPassword(newPassword []byte)

func (*SimpleKeyPairStore) Walk

func (kps *SimpleKeyPairStore) Walk(sortInfo bool, walkFunc KeyPairStoreWalkFunc)

func (*SimpleKeyPairStore) WipeData

func (kps *SimpleKeyPairStore) WipeData()

Jump to

Keyboard shortcuts

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