util

package
v0.7.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: BSD-3-Clause Imports: 15 Imported by: 13 modules, 13 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package util provides helpers shared by the go-tuf packages, such as hashing, length and version checks for metadata and target files.

Deprecated: The legacy go-tuf module is deprecated in favour of github.com/theupdateframework/go-tuf/v2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AtomicallyWriteFile

func AtomicallyWriteFile(filename string, data []byte, perm os.FileMode) error

func BytesMatchLenAndHashes added in v0.3.1

func BytesMatchLenAndHashes(fetched []byte, length int64, hashes data.Hashes) error

func FileMetaEqual

func FileMetaEqual(actual data.FileMeta, expected data.FileMeta) error

func GenerateFileMeta

func GenerateFileMeta(r io.Reader, hashAlgorithms ...string) (data.FileMeta, error)

func GenerateSnapshotFileMeta

func GenerateSnapshotFileMeta(r io.Reader, hashAlgorithms ...string) (data.SnapshotFileMeta, error)

func GenerateTargetFileMeta

func GenerateTargetFileMeta(r io.Reader, hashAlgorithms ...string) (data.TargetFileMeta, error)

func GenerateTimestampFileMeta

func GenerateTimestampFileMeta(r io.Reader, hashAlgorithms ...string) (data.TimestampFileMeta, error)

func HashedPaths

func HashedPaths(p string, hashes data.Hashes) []string

func NormalizeTarget

func NormalizeTarget(p string) string

func SnapshotFileMetaEqual

func SnapshotFileMetaEqual(actual data.SnapshotFileMeta, expected data.SnapshotFileMeta) error

func TargetFileMetaEqual

func TargetFileMetaEqual(actual data.TargetFileMeta, expected data.TargetFileMeta) error

func TimestampFileMetaEqual

func TimestampFileMetaEqual(actual data.TimestampFileMeta, expected data.TimestampFileMeta) error

func VersionEqual added in v0.3.1

func VersionEqual(actual int64, expected int64) error

func VersionedPath

func VersionedPath(p string, version int64) string

Types

type ErrNoCommonHash

type ErrNoCommonHash struct {
	Expected data.Hashes
	Actual   data.Hashes
}

func (ErrNoCommonHash) Error

func (e ErrNoCommonHash) Error() string

type ErrUnknownHashAlgorithm

type ErrUnknownHashAlgorithm struct {
	Name string
}

func (ErrUnknownHashAlgorithm) Error

func (e ErrUnknownHashAlgorithm) Error() string

type ErrWrongHash

type ErrWrongHash struct {
	Type     string
	Expected data.HexBytes
	Actual   data.HexBytes
}

func (ErrWrongHash) Error

func (e ErrWrongHash) Error() string

type ErrWrongLength

type ErrWrongLength struct {
	Expected int64
	Actual   int64
}

func (ErrWrongLength) Error

func (e ErrWrongLength) Error() string

type ErrWrongVersion

type ErrWrongVersion struct {
	Expected int64
	Actual   int64
}

func (ErrWrongVersion) Error

func (e ErrWrongVersion) Error() string

type PassphraseFunc

type PassphraseFunc func(role string, confirm bool, change bool) ([]byte, error)

Jump to

Keyboard shortcuts

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