keystorage

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2024 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package keystorage provides the key storage implementation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlgorithmMismatchTag

type AlgorithmMismatchTag struct{}

AlgorithmMismatchTag is used to indicate that the algorithm mismatch error returned.

type AlreadyInitializedTag

type AlreadyInitializedTag struct{}

AlreadyInitializedTag is the error tag returned when the key storage is already initialized.

type HMACMismatchTag

type HMACMismatchTag struct{}

HMACMismatchTag is used to indicate that the mismatch HMAC key storage error returned.

type KeyDecryptionFailureTag

type KeyDecryptionFailureTag struct{}

KeyDecryptionFailureTag is used to indicate that the master key decryption error returned.

type KeyEncryptionFailureTag

type KeyEncryptionFailureTag struct{}

KeyEncryptionFailureTag is used to indicate that the master key encryption error returned.

type KeyStorage

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

KeyStorage is a key storage that can be used to store and retrieve the master key.

func (*KeyStorage) AddKeySlot

func (ks *KeyStorage) AddKeySlot(newSlotID, newSlotPublicKey, oldSlotID, oldSlotPrivateKey string) error

AddKeySlot creates a new master key slot with the given slot id and public key using previus slot and its private key. It cannot be used to update an existing key slot. It is required to call Initialize() or UnmarshalBinary() to initialize the key storage first.

func (*KeyStorage) DeleteKeySlot

func (ks *KeyStorage) DeleteKeySlot(slotID, slotPrivateKey string) error

DeleteKeySlot removes the master key slot with the given slot id.

func (*KeyStorage) GetMasterKey

func (ks *KeyStorage) GetMasterKey(slotID, slotPrivateKey string) ([]byte, error)

GetMasterKey returns the attempts to decrypt the master key slot with the given private key and return the master key.

func (*KeyStorage) Initialize

func (ks *KeyStorage) Initialize(masterKey []byte, slotID, slotPublicKey string) error

Initialize sets the master key for the key storage, encrypts it using public key and stores it in slot id.

func (*KeyStorage) InitializeRnd

func (ks *KeyStorage) InitializeRnd(reader io.Reader, slotID, slotPublicKey string) error

InitializeRnd sets the master key for the key storage, encrypts it using public key and stores it in slot id. It is similar to Initialize() but it generates a random master key.

func (*KeyStorage) MarshalBinary

func (ks *KeyStorage) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (*KeyStorage) UnmarshalBinary

func (ks *KeyStorage) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

type LastKeyTag

type LastKeyTag struct{}

LastKeyTag is used to indicate that the last key slot error returned.

type NotInitializedTag

type NotInitializedTag struct{}

NotInitializedTag is the error tag returned when the key storage is not initialized.

type SlotAlreadyExists

type SlotAlreadyExists struct{}

SlotAlreadyExists is the error tag returned when a key slot already exists.

type SlotNotFoundTag

type SlotNotFoundTag struct{}

SlotNotFoundTag is the error tag returned when a key slot is not found.

type VersionMismatchTag

type VersionMismatchTag struct{}

VersionMismatchTag is used to indicate that the key storage version mismatch error returned.

Jump to

Keyboard shortcuts

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