1 Commits
Author SHA1 Message Date
sneak 2ef7a4ab5d Refuse a signature made when its key was not valid (closes #209)
check / check (push) Failing after 6s
verifySignature lets a key that has expired since verify a signature,
because a manifest outlives its key, but it checked the key only as of
now. It accepted a signature dated after its key expired, after the
key's self-signature or the signing subkey's binding signature expired,
or before the key was made. It now verifies a second time with the
library's clock set to the signature's creation time and refuses the
signature if the key or subkey was not valid then. docs/FORMAT.md
states the rule.

Judgement call: the tests make the refused signatures with the
library's packet API, because openpgp.DetachSign will not sign with a
key that is not valid at its clock's time.

Model: opus-5-5
2026-10-13 19:57:35 +00:00
2 changed files with 13 additions and 7 deletions
+9 -6
View File
@@ -175,12 +175,15 @@ secret key or subkey, since checking the self-signatures of a DSA key or the
numbers of a secret key can take hours when those numbers are very large.
A signature is good only if the key that made it was valid at the signature's
creation time, meaning the key had been made by then and neither it nor its
self-signature had expired. When a subkey made the signature, the same must hold
of the primary key, and of the subkey and its binding signature. A key that has
expired since does not make the signature bad, because a manifest outlives its
key. A signature past its own expiry time is not good, whether or not the key
has expired too.
creation time. The primary key is judged by the newest self-signature on its
primary user ID, and a subkey by its newest binding signature. By the
signature's creation time the primary key and that self-signature must have been
made and neither may have expired, and when a subkey made the signature the same
holds of the subkey and its binding signature. A signature made before that
self-signature or binding signature is not good, even if an older one made the
key valid at that time. A key that has expired since does not make the signature
bad, because a manifest outlives its key. A signature past its own expiry time
is not good, whether or not the key has expired too.
## Deterministic Serialization
+4 -1
View File
@@ -288,7 +288,10 @@ func verifySignature(data, signature, pubKey []byte) (string, error) {
// gives, which above is now. Verifying again as of the signature's
// creation time refuses a signature made before the key or subkey that
// made it was made, after it expired, or after its self-signature or
// binding signature expired.
// binding signature expired. The library judges the primary key by the
// newest self-signature on its primary user ID and a subkey by its
// newest binding signature, so this also refuses a signature made
// before either of those, even if an older one was valid then.
signedAt := &packet.Config{
Time: func() time.Time { return sig.CreationTime },
}