rotstore

package
v0.0.0-...-d56d81e Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: 0BSD Imports: 10 Imported by: 0

Documentation

Overview

Package rotstore provides functions for working with a rot store. For details on rot stores, see the "doc" directory in the repository.

Index

Constants

View Source
const (
	DirInternal = "internal"
	DirData     = "data"
)

Store subdirectory names.

Variables

View Source
var (
	IgnoreFiles = []string{
		".DS_Store",
	}
	IgnoreFilesSet = setFromSlice(IgnoreFiles)
)

Files with these base names should be ignored during store operations.

View Source
var (
	TestPassword  = []byte("p1")
	TestKeyParams = keygen.Params{
		Salt:    [16]byte{1, 2, 3},
		Time:    1,
		MemKiB:  1,
		Threads: 1,
	}
	TestKey = keygen.Generate(TestPassword, rotfile.KeySize, TestKeyParams)
)

Values for test stores created using EmptyTestStore.

View Source
var ErrKey = errors.New("invalid key")

ErrKey is returned by func ReadMarker. See the documentation of ReadMarker for details.

View Source
var SkipAll = errors.New("skip all")

Functions

func CreateEmptyStore

func CreateEmptyStore(storepath string, key []byte, params keygen.Params, markerContent []byte) error

CreateEmptyStore creates a new, empty store at storepath.

func CreateKeyParams

func CreateKeyParams(storepath string, p keygen.Params) error

CreateKeyParams creates the "internal/keyparams" file in the store.

func CreateMarker

func CreateMarker(storepath string, key, content []byte) error

CreateMarker creates the "internal/marker" file in the store.

func EmptyTestStore

func EmptyTestStore(t *testing.T) (string, func())

EmptyTestStore creates an empty store that can be used in tests. It returns the path to the store root directory and a cleanup function to remove the store after use.

func GetKey

func GetKey(storepath string, password []byte) ([]byte, error)

GetKey derives and validates the store encryption key from the master password.

func ReadKeyParams

func ReadKeyParams(storepath string) (keygen.Params, error)

ReadKeyParams file decodes the "internal/keyparams" file in the store.

func ReadMarker

func ReadMarker(storepath string, key []byte) error

ReadMarker checks if the "internal/marker" file in the store can be decrypeted successfully with the given key. If the key is incorrect the error will be ErrKey. The function may return other generic errors.

func WalkNames

func WalkNames(storepath string, f WalkFunc) error

WalkNames walks the store data directory, calling the WalkFunc with the name of each file (but not of directories). If the WalkFunc returns SkipAll, then walking of all remaining files and directories is skipped.

Types

type WalkFunc

type WalkFunc func(name string) error

Jump to

Keyboard shortcuts

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