Documentation
¶
Index ¶
- Variables
- func DecodeBox(ctx context.Context, b []byte, getSecretBoxKey KeyFn, res any) error
- func EncodeBox(ctx context.Context, data any, getSecretBoxKey KeyFn) ([]byte, error)
- func GetSecretBoxKey(ctx context.Context, g *libkb.GlobalContext, reason libkb.EncryptionReason, ...) (fkey [32]byte, err error)
- func GetSecretBoxKeyWithUID(ctx context.Context, g *libkb.GlobalContext, uid keybase1.UID, ...) (fkey [32]byte, err error)
- func IsUnusableData(err error) bool
- type DbFn
- type EncryptedDB
- func (i *EncryptedDB) Delete(ctx context.Context, key libkb.DbKey) error
- func (i *EncryptedDB) DropUnusable(ctx context.Context, key libkb.DbKey, err error) error
- func (i *EncryptedDB) Get(ctx context.Context, key libkb.DbKey, res any) (bool, error)
- func (i *EncryptedDB) GetOrDropUnusable(ctx context.Context, key libkb.DbKey, res any) (bool, error)
- func (i *EncryptedDB) Put(ctx context.Context, key libkb.DbKey, data any) error
- type EncryptedFile
- type KeyFn
Constants ¶
This section is empty.
Variables ¶
var ErrDecryptionFailed = errors.New("failed to decrypt item")
ErrDecryptionFailed is returned when an encrypteddb box fails to decrypt
var ErrUndecodable = errors.New("failed to decode item")
ErrUndecodable wraps msgpack decode failures of a stored box or of its decrypted payload. Like ErrDecryptionFailed it means the stored bytes are unusable, as opposed to a failure to fetch the key.
var ErrUnsupportedVersion = errors.New("unsupported crypto version")
ErrUnsupportedVersion wraps a box written with a newer crypto version than this client can open.
Functions ¶
func GetSecretBoxKey ¶
func GetSecretBoxKey(ctx context.Context, g *libkb.GlobalContext, reason libkb.EncryptionReason, reasonStr string, ) (fkey [32]byte, err error)
func GetSecretBoxKeyWithUID ¶
func IsUnusableData ¶
IsUnusableData reports whether a DecodeBox/Get error means the stored item itself can never be read by this client (as opposed to, say, a failure to fetch the key). Rebuildable caches drop such items; see GetOrDropUnusable.
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) DropUnusable ¶
DropUnusable deletes key when err means the stored bytes can never be read by this client. A nil or transient error, such as a failure to fetch the key, deletes nothing and returns nil.
func (*EncryptedDB) Get ¶
Get a value Decodes into res Returns (found, err). Res is valid only if (found && err == nil)
func (*EncryptedDB) GetOrDropUnusable ¶
func (i *EncryptedDB) GetOrDropUnusable(ctx context.Context, key libkb.DbKey, res any) (bool, error)
GetOrDropUnusable is Get for a rebuildable cache. Unusable stored bytes are deleted and reported as a miss. Any other error is returned and the value is left in place. res is valid only if found && err == nil.
type EncryptedFile ¶
type EncryptedFile struct {
libkb.Contextified
// contains filtered or unexported fields
}
func NewFile ¶
func NewFile(g *libkb.GlobalContext, path string, getSecretBoxKey KeyFn) *EncryptedFile