Documentation
¶
Overview ¶
Package artifact verifies signatures using caller-selected trust anchors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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.