encrypteddb

package
v0.0.0-...-48c56db Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2021 License: BSD-3-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDecryptionFailed = errors.New("failed to decrypt item")

ErrDecryptionFailed is returned when an encrypteddb box fails to decrypt

Functions

func DecodeBox

func DecodeBox(ctx context.Context, b []byte, getSecretBoxKey KeyFn,
	res interface{}) error

func EncodeBox

func EncodeBox(ctx context.Context, data interface{}, getSecretBoxKey KeyFn) ([]byte, error)

func GetSecretBoxKey

func GetSecretBoxKey(ctx context.Context, g *libkb.GlobalContext,
	reason libkb.EncryptionReason, reasonStr string) (fkey [32]byte, err error)

func GetSecretBoxKeyWithUID

func GetSecretBoxKeyWithUID(ctx context.Context, g *libkb.GlobalContext, uid keybase1.UID,
	reason libkb.EncryptionReason, reasonStr string) (fkey [32]byte, err error)

Types

type DbFn

type DbFn func(g *libkb.GlobalContext) *libkb.JSONLocalDb

type EncryptedDB

type EncryptedDB struct {
	libkb.Contextified
	// contains filtered or unexported fields
}

Handle to a db that encrypts values using nacl secretbox. Does not encrypt keys. Not threadsafe.

func New

func New(g *libkb.GlobalContext, getDB DbFn, getSecretBoxKey KeyFn) *EncryptedDB

func (*EncryptedDB) Delete

func (i *EncryptedDB) Delete(ctx context.Context, key libkb.DbKey) error

func (*EncryptedDB) Get

func (i *EncryptedDB) Get(ctx context.Context, key libkb.DbKey, res interface{}) (bool, error)

Get a value Decodes into res Returns (found, err). Res is valid only if (found && err == nil)

func (*EncryptedDB) Put

func (i *EncryptedDB) Put(ctx context.Context, key libkb.DbKey, data interface{}) error

type EncryptedFile

type EncryptedFile struct {
	libkb.Contextified
	// contains filtered or unexported fields
}

func NewFile

func NewFile(g *libkb.GlobalContext, path string, getSecretBoxKey KeyFn) *EncryptedFile

func (*EncryptedFile) Get

func (f *EncryptedFile) Get(ctx context.Context, res interface{}) error

func (*EncryptedFile) Put

func (f *EncryptedFile) Put(ctx context.Context, data interface{}) error

func (*EncryptedFile) Remove

func (f *EncryptedFile) Remove(ctx context.Context) error

type KeyFn

type KeyFn func(context.Context) ([32]byte, error)

Jump to

Keyboard shortcuts

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