libkey

package
v5.1.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2019 License: BSD-3-Clause, BSD-3-Clause, BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KeyBundleCacheMeasured

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

KeyBundleCacheMeasured delegates to another KeyBundleCache instance but also keeps track of stats.

func NewKeyBundleCacheMeasured

func NewKeyBundleCacheMeasured(delegate kbfsmd.KeyBundleCache, r metrics.Registry) KeyBundleCacheMeasured

NewKeyBundleCacheMeasured creates and returns a new KeyBundleCacheMeasured instance with the given delegate and registry.

func (KeyBundleCacheMeasured) GetTLFReaderKeyBundle

func (b KeyBundleCacheMeasured) GetTLFReaderKeyBundle(
	bundleID kbfsmd.TLFReaderKeyBundleID) (rkb *kbfsmd.TLFReaderKeyBundleV3, err error)

GetTLFReaderKeyBundle implements the KeyBundleCache interface for KeyBundleCacheMeasured.

func (KeyBundleCacheMeasured) GetTLFWriterKeyBundle

func (b KeyBundleCacheMeasured) GetTLFWriterKeyBundle(
	bundleID kbfsmd.TLFWriterKeyBundleID) (wkb *kbfsmd.TLFWriterKeyBundleV3, err error)

GetTLFWriterKeyBundle implements the KeyBundleCache interface for KeyBundleCacheMeasured.

func (KeyBundleCacheMeasured) PutTLFReaderKeyBundle

func (b KeyBundleCacheMeasured) PutTLFReaderKeyBundle(
	bundleID kbfsmd.TLFReaderKeyBundleID, rkb kbfsmd.TLFReaderKeyBundleV3)

PutTLFReaderKeyBundle implements the KeyBundleCache interface for KeyBundleCacheMeasured.

func (KeyBundleCacheMeasured) PutTLFWriterKeyBundle

func (b KeyBundleCacheMeasured) PutTLFWriterKeyBundle(
	bundleID kbfsmd.TLFWriterKeyBundleID, wkb kbfsmd.TLFWriterKeyBundleV3)

PutTLFWriterKeyBundle implements the KeyBundleCache interface for KeyBundleCacheMeasured.

type KeyMetadata

type KeyMetadata interface {
	// TlfID returns the ID of the TLF for which this object holds
	// key info.
	TlfID() tlf.ID

	// TypeForKeying returns the keying type for this MD.
	TypeForKeying() tlf.KeyingType

	// LatestKeyGeneration returns the most recent key generation
	// with key data in this object, or PublicKeyGen if this TLF
	// is public.
	LatestKeyGeneration() kbfsmd.KeyGen

	// GetTlfHandle returns the handle for the TLF. It must not
	// return nil.
	//
	// TODO: Remove the need for this function in this interface,
	// so that kbfsmd.RootMetadata can implement this interface
	// fully.
	GetTlfHandle() *tlfhandle.Handle

	// IsWriter checks that the given user is a valid writer of the TLF
	// right now.
	IsWriter(
		ctx context.Context, checker kbfsmd.TeamMembershipChecker,
		osg idutil.OfflineStatusGetter, uid keybase1.UID,
		verifyingKey kbfscrypto.VerifyingKey) (bool, error)

	// HasKeyForUser returns whether or not the given user has
	// keys for at least one device. Returns an error if the TLF
	// is public.
	HasKeyForUser(user keybase1.UID) (bool, error)

	// GetTLFCryptKeyParams returns all the necessary info to
	// construct the TLF crypt key for the given key generation,
	// user, and device (identified by its crypt public key), or
	// false if not found. This returns an error if the TLF is
	// public.
	GetTLFCryptKeyParams(
		keyGen kbfsmd.KeyGen, user keybase1.UID,
		key kbfscrypto.CryptPublicKey) (
		kbfscrypto.TLFEphemeralPublicKey,
		kbfscrypto.EncryptedTLFCryptKeyClientHalf,
		kbfscrypto.TLFCryptKeyServerHalfID, bool, error)

	// StoresHistoricTLFCryptKeys returns whether or not history keys are
	// symmetrically encrypted; if not, they're encrypted per-device.
	StoresHistoricTLFCryptKeys() bool

	// GetHistoricTLFCryptKey attempts to symmetrically decrypt the
	// key at the given generation using the current generation's
	// TLFCryptKey.
	GetHistoricTLFCryptKey(codec kbfscodec.Codec, keyGen kbfsmd.KeyGen,
		currentKey kbfscrypto.TLFCryptKey) (
		kbfscrypto.TLFCryptKey, error)
}

KeyMetadata is an interface for something that holds key information. This is usually implemented by RootMetadata.

type KeyOps

type KeyOps interface {
	// GetTLFCryptKeyServerHalf gets a server-side key half for a
	// device given the key half ID.
	GetTLFCryptKeyServerHalf(ctx context.Context,
		serverHalfID kbfscrypto.TLFCryptKeyServerHalfID,
		cryptPublicKey kbfscrypto.CryptPublicKey) (
		kbfscrypto.TLFCryptKeyServerHalf, error)

	// PutTLFCryptKeyServerHalves stores a server-side key halves for a
	// set of users and devices.
	PutTLFCryptKeyServerHalves(ctx context.Context,
		keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error

	// DeleteTLFCryptKeyServerHalf deletes a server-side key half for a
	// device given the key half ID.
	DeleteTLFCryptKeyServerHalf(ctx context.Context,
		uid keybase1.UID, key kbfscrypto.CryptPublicKey,
		serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error
}

KeyOps fetches server-side key halves from the key server.

type KeyOpsConfig

type KeyOpsConfig interface {
	KeyServer() KeyServer
	KBPKI() idutil.KBPKI
}

KeyOpsConfig is a config object containing the outside helper instances needed by KeyOps.

type KeyOpsStandard

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

KeyOpsStandard implements the KeyOps interface and relays get/put requests for server-side key halves from/to the key server.

func NewKeyOpsStandard

func NewKeyOpsStandard(config KeyOpsConfig) *KeyOpsStandard

NewKeyOpsStandard creates a new KeyOpsStandard instance.

func (*KeyOpsStandard) DeleteTLFCryptKeyServerHalf

func (k *KeyOpsStandard) DeleteTLFCryptKeyServerHalf(
	ctx context.Context, uid keybase1.UID, key kbfscrypto.CryptPublicKey,
	serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error

DeleteTLFCryptKeyServerHalf is an implementation of the KeyOps interface.

func (*KeyOpsStandard) GetTLFCryptKeyServerHalf

GetTLFCryptKeyServerHalf is an implementation of the KeyOps interface.

func (*KeyOpsStandard) PutTLFCryptKeyServerHalves

func (k *KeyOpsStandard) PutTLFCryptKeyServerHalves(
	ctx context.Context,
	keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error

PutTLFCryptKeyServerHalves is an implementation of the KeyOps interface.

type KeyServer

type KeyServer interface {
	// GetTLFCryptKeyServerHalf gets a server-side key half for a
	// device given the key half ID.
	GetTLFCryptKeyServerHalf(ctx context.Context,
		serverHalfID kbfscrypto.TLFCryptKeyServerHalfID,
		cryptPublicKey kbfscrypto.CryptPublicKey) (
		kbfscrypto.TLFCryptKeyServerHalf, error)

	// PutTLFCryptKeyServerHalves stores a server-side key halves for a
	// set of users and devices.
	PutTLFCryptKeyServerHalves(ctx context.Context,
		keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error

	// DeleteTLFCryptKeyServerHalf deletes a server-side key half for a
	// device given the key half ID.
	DeleteTLFCryptKeyServerHalf(ctx context.Context,
		uid keybase1.UID, key kbfscrypto.CryptPublicKey,
		serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error

	// Shutdown is called to free any KeyServer resources.
	Shutdown()
}

KeyServer fetches/writes server-side key halves from/to the key server.

type KeyServerConfig

type KeyServerConfig interface {
	Codec() kbfscodec.Codec
	KBPKI() idutil.KBPKI
}

KeyServerConfig is a config object containing the outside helper instances needed by KeyServerLocal.

type KeyServerLocal

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

KeyServerLocal puts/gets key server halves in/from a local leveldb instance.

func NewKeyServerDir

func NewKeyServerDir(
	config KeyServerConfig, log logger.Logger, dirPath string) (
	*KeyServerLocal, error)

NewKeyServerDir constructs a new KeyServerLocal that stores its data in the given directory.

func NewKeyServerMemory

func NewKeyServerMemory(config KeyServerConfig, log logger.Logger) (
	*KeyServerLocal, error)

NewKeyServerMemory returns a KeyServerLocal with an in-memory leveldb instance.

func NewKeyServerTempDir

func NewKeyServerTempDir(
	config KeyServerConfig, log logger.Logger) (*KeyServerLocal, error)

NewKeyServerTempDir constructs a new KeyServerLocal that stores its data in a temp directory which is cleaned up on shutdown.

func (*KeyServerLocal) CopyWithConfigAndLogger

func (ks *KeyServerLocal) CopyWithConfigAndLogger(
	config KeyServerConfig, log logger.Logger) *KeyServerLocal

CopyWithConfigAndLogger copies a key server but swaps the config and the logger.

func (*KeyServerLocal) DeleteTLFCryptKeyServerHalf

func (ks *KeyServerLocal) DeleteTLFCryptKeyServerHalf(ctx context.Context,
	_ keybase1.UID, _ kbfscrypto.CryptPublicKey,
	serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) error

DeleteTLFCryptKeyServerHalf implements the KeyServer interface for KeyServerLocal.

func (*KeyServerLocal) GetTLFCryptKeyServerHalf

func (ks *KeyServerLocal) GetTLFCryptKeyServerHalf(
	ctx context.Context, serverHalfID kbfscrypto.TLFCryptKeyServerHalfID,
	key kbfscrypto.CryptPublicKey) (
	serverHalf kbfscrypto.TLFCryptKeyServerHalf, err error)

GetTLFCryptKeyServerHalf implements the KeyServer interface for KeyServerLocal.

func (*KeyServerLocal) PutTLFCryptKeyServerHalves

func (ks *KeyServerLocal) PutTLFCryptKeyServerHalves(ctx context.Context,
	keyServerHalves kbfsmd.UserDeviceKeyServerHalves) error

PutTLFCryptKeyServerHalves implements the KeyServer interface for KeyServerLocal.

func (*KeyServerLocal) Shutdown

func (ks *KeyServerLocal) Shutdown()

Shutdown implements the KeyServer interface for KeyServerLocal.

type KeyServerMeasured

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

KeyServerMeasured delegates to another KeyServer instance but also keeps track of stats.

func NewKeyServerMeasured

func NewKeyServerMeasured(delegate KeyServer, r metrics.Registry) KeyServerMeasured

NewKeyServerMeasured creates and returns a new KeyServerMeasured instance with the given delegate and registry.

func (KeyServerMeasured) DeleteTLFCryptKeyServerHalf

func (b KeyServerMeasured) DeleteTLFCryptKeyServerHalf(ctx context.Context,
	uid keybase1.UID, key kbfscrypto.CryptPublicKey,
	serverHalfID kbfscrypto.TLFCryptKeyServerHalfID) (err error)

DeleteTLFCryptKeyServerHalf implements the KeyServer interface for KeyServerMeasured.

func (KeyServerMeasured) GetTLFCryptKeyServerHalf

func (b KeyServerMeasured) GetTLFCryptKeyServerHalf(ctx context.Context,
	serverHalfID kbfscrypto.TLFCryptKeyServerHalfID, key kbfscrypto.CryptPublicKey) (
	serverHalf kbfscrypto.TLFCryptKeyServerHalf, err error)

GetTLFCryptKeyServerHalf implements the KeyServer interface for KeyServerMeasured.

func (KeyServerMeasured) PutTLFCryptKeyServerHalves

func (b KeyServerMeasured) PutTLFCryptKeyServerHalves(ctx context.Context,
	keyServerHalves kbfsmd.UserDeviceKeyServerHalves) (err error)

PutTLFCryptKeyServerHalves implements the KeyServer interface for KeyServerMeasured.

func (KeyServerMeasured) Shutdown

func (b KeyServerMeasured) Shutdown()

Shutdown implements the KeyServer interface for KeyServerMeasured.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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