verify

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package verify provides image checksum verification for streamed OS images.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HashBytes

func HashBytes(algo Algorithm, data []byte) (string, error)

HashBytes computes the checksum of a byte slice.

Types

type Algorithm

type Algorithm string

Algorithm represents a supported hash algorithm.

const (
	// SHA256 is SHA-256 hash algorithm.
	SHA256 Algorithm = "sha256"
	// SHA512 is SHA-512 hash algorithm.
	SHA512 Algorithm = "sha512"
)

func ParseChecksum

func ParseChecksum(s string) (Algorithm, string, error)

ParseChecksum parses a checksum string in the format "algo:hexhash". It validates that the hash is valid hex and the correct length for the algorithm.

func (Algorithm) DigestSize

func (a Algorithm) DigestSize() int

DigestSize returns the expected digest size in bytes for the algorithm.

func (Algorithm) NewHash

func (a Algorithm) NewHash() (hash.Hash, error)

NewHash creates a new hash.Hash for the given algorithm.

func (Algorithm) Validate

func (a Algorithm) Validate() error

Validate checks if the algorithm is supported.

type ChecksumReader

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

ChecksumReader wraps an io.Reader and computes a running checksum.

func NewChecksumReader

func NewChecksumReader(r io.Reader, checksum string) (*ChecksumReader, error)

NewChecksumReader creates a reader that computes checksum while reading.

func (*ChecksumReader) Actual

func (c *ChecksumReader) Actual() string

Actual returns the computed hex hash after reading.

func (*ChecksumReader) Read

func (c *ChecksumReader) Read(p []byte) (int, error)

Read implements io.Reader.

func (*ChecksumReader) Verify

func (c *ChecksumReader) Verify() error

Verify checks the computed checksum against expected. Must be called after all data has been read.

type VerifyConfig

type VerifyConfig struct {
	Checksum      string `json:"checksum,omitempty"`
	SignatureURL  string `json:"signatureUrl,omitempty"`
	PublicKeyPath string `json:"publicKeyPath,omitempty"`
}

VerifyConfig holds verification configuration.

func (*VerifyConfig) HasChecksum

func (c *VerifyConfig) HasChecksum() bool

HasChecksum returns true if checksum verification is configured.

func (*VerifyConfig) HasSignature

func (c *VerifyConfig) HasSignature() bool

HasSignature returns true if signature verification is configured.

func (*VerifyConfig) Validate

func (c *VerifyConfig) Validate() error

Validate checks the verification config.

Jump to

Keyboard shortcuts

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