artifact

package
v0.7.0-rc.13 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0 modules, 0 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 artifact verifies signatures using caller-selected trust anchors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignedSHA256

func SignedSHA256(signedText []byte, name string) (string, error)

SignedSHA256 returns the SHA-256 that a signed checksum list gives for the named file. The list must name the file exactly once.

Types

type Result

type Result struct {
	// Signers counts distinct pinned signers whose signature is accepted.
	Signers int
	// Bad reports a signature that does not match the data.
	Bad bool
	// Revoked lists, in sorted order, pinned primary fingerprints that signed
	// only with a revoked key. Such a signer is never counted.
	Revoked []string
	// Imported reports, for each key file, whether gpg took a pinned key or
	// an update to one from it. A file that is unreadable, is not a key, or
	// holds only other keys is false.
	Imported map[string]bool
	// SignedText is the text of a clearsigned file. It is set only when a
	// pinned signer is accepted and no signature is bad, and holds nothing
	// from outside the signed block.
	SignedText []byte
}

Result is what one signature file proved.

func VerifySignature

func VerifySignature(
	keyFiles []string,
	sigFile, dataFile string,
	pinnedFPs map[string]bool,
) (Result, error)

VerifySignature verifies a GPG signature inside an ephemeral keyring. It imports the key files in the order given and reads gpg's machine-readable output; gpg's exit code and its messages for people are not used.

A pinned signer counts once, by primary-key fingerprint, when gpg reports its signature as good. A signature made with a revoked key or revoked signing subkey never counts, whatever reason or date the revocation gives and whichever key file carried the revocation. An expired key still counts: expiry is not treated as a withdrawal of trust. A signature that has itself expired does not count.

GPG may exit unsuccessfully when another signature uses an unavailable key, as in Syncthing's dual-signed releases. Callers must require their pinned signer threshold and reject Bad, rather than infer trust from exit status.

dataFile == "" means sigFile is CLEARSIGNED (data and signature in one file, e.g. Syncthing's sha256sum.txt.asc). Otherwise the signature is detached and gpg gets both arguments.

A clearsigned file must be exactly one signed block. gpg reports a good signature for a file that also has text before or after the block, and that text is not signed. Callers must read the data from Result.SignedText, never from sigFile.

Directories

Path Synopsis
Package gpgtest builds throwaway OpenPGP keys and signatures with the real gpg program.
Package gpgtest builds throwaway OpenPGP keys and signatures with the real gpg program.

Jump to

Keyboard shortcuts

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