internal

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2025 License: BSD-3-Clause Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrClosed = errors.New("Handle is closed")
)

Functions

This section is empty.

Types

type Handle

type Handle struct {
	// Immutable
	Params mtc.CAParams
	Path   string

	// Mutable covered by RWLock mux
	Mux            sync.RWMutex
	FLock          lockfile.Lockfile
	Closed         bool
	UmbilicalRoots *x509.CertPool

	// Caches. Access requires either write lock on mux, or a read lock on mux
	// and a lock on cacheMux.
	CacheMux          sync.Mutex
	Indices           map[uint32]*Index            // index files
	BEs               map[uint32]*os.File          // entries files
	EVs               map[uint32]*os.File          // evidence files
	Trees             map[uint32]*Tree             // tree files
	UCs               map[uint32]*frozencas.Handle // umbilical-certificates
	BatchNumbersCache []uint32                     // cache for existing batches
}

Common functionality shared between the state of a Merkle Tree CA and a mirror.

func (*Handle) BEFileFor

func (h *Handle) BEFileFor(batch uint32) (*os.File, error)

Returns file handle to entries file for the given batch.

func (*Handle) BEPath

func (h *Handle) BEPath(number uint32) string

func (*Handle) BatchPath

func (h *Handle) BatchPath(number uint32) string

func (*Handle) BatchesPath

func (h *Handle) BatchesPath() string

func (*Handle) CertificateFor

func (h *Handle) CertificateFor(a mtc.Assertion) (
	*mtc.BikeshedCertificate, error)

Returns the certificate for an issued assertion

func (*Handle) Close

func (h *Handle) Close() error

func (*Handle) CloseBatch

func (h *Handle) CloseBatch(batch uint32) error

Close any (cached) open files for the given batch.

func (*Handle) EVFileFor

func (h *Handle) EVFileFor(batch uint32) (*os.File, error)

Returns file handle to evidence file for the given batch.

func (*Handle) EVPath

func (h *Handle) EVPath(number uint32) string

func (*Handle) EvidenceFor

func (h *Handle) EvidenceFor(a mtc.Assertion) (*mtc.EvidenceList, error)

Returns the evidence for an issued assertion

func (*Handle) GetSignedValidityWindow

func (h *Handle) GetSignedValidityWindow(number uint32) (
	*mtc.SignedValidityWindow, error)

func (*Handle) GetUmbilicalRoots

func (h *Handle) GetUmbilicalRoots() (*x509.CertPool, error)

Returns a copy of the trusted umbilical roots.

Requires write lock on mux.

func (*Handle) IndexFor

func (h *Handle) IndexFor(batch uint32) (*Index, error)

Returns the index for the given batch.

func (*Handle) IndexPath

func (h *Handle) IndexPath(number uint32) string

func (*Handle) LatestBatchPath

func (h *Handle) LatestBatchPath() string

func (*Handle) ListBatchRange

func (h *Handle) ListBatchRange() (mtc.BatchRange, error)

Returns range of batches for which a directory was created.

func (*Handle) LockFolder

func (h *Handle) LockFolder() error

func (*Handle) New

func (h *Handle) New(path string, params mtc.CAParams) error

Set up basic directory structure for a CA or mirror

func (*Handle) Open

func (h *Handle) Open(path string) error

func (*Handle) ParamsPath

func (h *Handle) ParamsPath() string

func (*Handle) TmpPath

func (h *Handle) TmpPath() string

func (*Handle) TreeFor

func (h *Handle) TreeFor(batch uint32) (*Tree, error)

Return the Tree handle for the given batch.

func (*Handle) TreePath

func (h *Handle) TreePath(number uint32) string

func (*Handle) UCFor

func (h *Handle) UCFor(batch uint32) (*frozencas.Handle, error)

Returns the umbilical certificates file for the given batch.

func (*Handle) UCPath

func (h *Handle) UCPath(number uint32) string

func (*Handle) UmbilicalRootsPath

func (h *Handle) UmbilicalRootsPath() string

func (*Handle) UpdateLatest

func (h *Handle) UpdateLatest(number uint32) error

Updates the latest symlink to point to the given batch

type Index

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

Handle to an index

func OpenIndex

func OpenIndex(path string) (*Index, error)

Opens an index

func (*Index) Close

func (h *Index) Close() error

func (*Index) Search

func (h *Index) Search(hash []byte) (*IndexSearchResult, error)

Look up hash in the index. If not found, returns nil.

type IndexBuildEntry

type IndexBuildEntry struct {
	Key            [mtc.HashLen]byte
	Offset         uint64
	EvidenceOffset uint64
}

type IndexBuilder

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

func NewIndexBuilder

func NewIndexBuilder(w io.Writer) *IndexBuilder

func (*IndexBuilder) Finish

func (ib *IndexBuilder) Finish() error

func (*IndexBuilder) Push

func (ib *IndexBuilder) Push(in IndexBuildEntry) error

type IndexSearchResult

type IndexSearchResult struct {
	SequenceNumber uint64
	Offset         uint64
	EvidenceOffset uint64
}

type Tree

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

Handle to a batches tree file. In contrast to mtc.Tree, this doesn't load the whole tree in memory.

func OpenTree

func OpenTree(path string) (*Tree, error)

Opens an index

func (*Tree) AuthenticationPath

func (t *Tree) AuthenticationPath(index uint64) ([]byte, error)

Return authentication path proving that the leaf at the given index is included in the Merkle tree.

func (*Tree) Close

func (h *Tree) Close() error

Jump to

Keyboard shortcuts

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