keystore

package
v0.0.0-...-3301e3d Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyExists is the error type returned
	// when the PutKey() method is called with
	// a key that already exists in the keystore
	ErrKeyExists = errors.New("key already exists")

	// ErrKeyNotFound is returned when GetKey(),
	// UpdateKey(), or DeleteKey() is called with
	// an id (or key with id in the case of update)
	// that is not found in the keystore
	ErrKeyNotFound = errors.New("key not found")
)

Functions

This section is empty.

Types

type Keystore

type Keystore interface {
	PutPrivKey(*kms.PrivateKey) error
	GetPrivKey(string) (*kms.PrivateKey, error)
	UpdatePrivKey(*kms.PrivateKey) error
	DeletePrivKey(string) error

	PutPubKey(*kms.PublicKey) error
	GetPubKey(string) (*kms.PublicKey, error)
	DeletePubKey(string) error
}

Keystore represents all the necessary operations to build a key storage solution

type MockKeystore

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

MockKeystore is an in-memory implementation of the Keystore interface

func NewMockKeystore

func NewMockKeystore() *MockKeystore

NewMockKeystore is the constructor for MockKeystore

func (*MockKeystore) DeletePrivKey

func (db *MockKeystore) DeletePrivKey(id string) error

DeletePrivKey deletes a private key from the keystore

func (*MockKeystore) DeletePubKey

func (db *MockKeystore) DeletePubKey(id string) error

DeletePubKey deletes a public key by id from the keystore

func (*MockKeystore) GetPrivKey

func (db *MockKeystore) GetPrivKey(id string) (*kms.PrivateKey, error)

GetPrivKey gets a private key by id from the keystore

func (*MockKeystore) GetPubKey

func (db *MockKeystore) GetPubKey(id string) (*kms.PublicKey, error)

GetPubKey gets a public key by id from the keystore

func (*MockKeystore) PutPrivKey

func (db *MockKeystore) PutPrivKey(k *kms.PrivateKey) error

PutPrivKey adds a private key to the keystore

func (*MockKeystore) PutPubKey

func (db *MockKeystore) PutPubKey(k *kms.PublicKey) error

PutPubKey adds a public key to the keystore

func (*MockKeystore) UpdatePrivKey

func (db *MockKeystore) UpdatePrivKey(k *kms.PrivateKey) error

UpdatePrivKey updates a private key in the keystore

type MongoDBKeystore

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

MongoDBKeystore holds the MongoDBKeystore Collection

func NewMongoDBKeystore

func NewMongoDBKeystore(connStr, dbName, privKeysCollName, pubKeysCollName string) (*MongoDBKeystore, error)

NewMongoDBKeystore initializes MongoDBKeystore connection returns MongoDBKeystore object

func (*MongoDBKeystore) DeletePrivKey

func (db *MongoDBKeystore) DeletePrivKey(id string) error

DeletePrivKey deletes a private key from the database

func (*MongoDBKeystore) DeletePubKey

func (db *MongoDBKeystore) DeletePubKey(id string) error

DeletePubKey deletes a public key from the database

func (*MongoDBKeystore) GetPrivKey

func (db *MongoDBKeystore) GetPrivKey(id string) (*kms.PrivateKey, error)

GetPrivKey gets a private key from the database

func (*MongoDBKeystore) GetPubKey

func (db *MongoDBKeystore) GetPubKey(id string) (*kms.PublicKey, error)

GetPubKey returns a public key by id

func (*MongoDBKeystore) PutPrivKey

func (db *MongoDBKeystore) PutPrivKey(key *kms.PrivateKey) error

PutPrivKey adds a new private key to the database

func (*MongoDBKeystore) PutPubKey

func (db *MongoDBKeystore) PutPubKey(key *kms.PublicKey) error

PutPubKey adds a new public key to the database

func (*MongoDBKeystore) UpdatePrivKey

func (db *MongoDBKeystore) UpdatePrivKey(key *kms.PrivateKey) error

UpdatePrivKey updates a private key in the database

Jump to

Keyboard shortcuts

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