Add GPG signature verification on manifest load
- Implement gpgVerify function that creates a temporary keyring to verify detached signatures against embedded public keys - Signature verification happens during deserialization after hash validation but before decompression - Extract signatureString() as a method on manifest for generating the canonical signature string (MAGIC-UUID-MULTIHASH) - Add --require-signature flag to check command to mandate signature from a specific GPG key ID - Expose IsSigned() and Signer() methods on Checker for signature status
This commit is contained in:
@@ -70,6 +70,10 @@ type Checker struct {
|
||||
fs afero.Fs
|
||||
// manifestPaths is a set of paths in the manifest for quick lookup
|
||||
manifestPaths map[RelFilePath]struct{}
|
||||
// signature info from the manifest
|
||||
signature []byte
|
||||
signer []byte
|
||||
signingPubKey []byte
|
||||
}
|
||||
|
||||
// NewChecker creates a new Checker for the given manifest, base path, and filesystem.
|
||||
@@ -101,6 +105,9 @@ func NewChecker(manifestPath string, basePath string, fs afero.Fs) (*Checker, er
|
||||
files: files,
|
||||
fs: fs,
|
||||
manifestPaths: manifestPaths,
|
||||
signature: m.pbOuter.Signature,
|
||||
signer: m.pbOuter.Signer,
|
||||
signingPubKey: m.pbOuter.SigningPubKey,
|
||||
}, nil
|
||||
}
|
||||
|
||||
@@ -118,6 +125,16 @@ func (c *Checker) TotalBytes() FileSize {
|
||||
return total
|
||||
}
|
||||
|
||||
// IsSigned returns true if the manifest has a signature.
|
||||
func (c *Checker) IsSigned() bool {
|
||||
return len(c.signature) > 0
|
||||
}
|
||||
|
||||
// Signer returns the signer fingerprint if the manifest is signed, nil otherwise.
|
||||
func (c *Checker) Signer() []byte {
|
||||
return c.signer
|
||||
}
|
||||
|
||||
// Check verifies all files against the manifest.
|
||||
// Results are sent to the results channel as files are checked.
|
||||
// Progress updates are sent to the progress channel approximately once per second.
|
||||
|
||||
Reference in New Issue
Block a user