1 Commits
Author SHA1 Message Date
sneak 1bd1455a7b Refuse a signature made when its key was not valid (closes #209)
check / check (push) Canceled after 0s
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 18:35:09 +00:00
2 changed files with 7 additions and 13 deletions

No files matched your search

+6 -9
View File
@@ -175,15 +175,12 @@ 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. 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 A signature is good only if the key that made it was valid at the signature's
creation time. The primary key is judged by the newest self-signature on its creation time, meaning the key had been made by then and neither it nor its
primary user ID, and a subkey by its newest binding signature. By the self-signature had expired. When a subkey made the signature, the same must hold
signature's creation time the primary key and that self-signature must have been of the primary key, and of the subkey and its binding signature. A key that has
made and neither may have expired, and when a subkey made the signature the same expired since does not make the signature bad, because a manifest outlives its
holds of the subkey and its binding signature. A signature made before that key. A signature past its own expiry time is not good, whether or not the key
self-signature or binding signature is not good, even if an older one made the has expired too.
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 ## Deterministic Serialization
+1 -4
View File
@@ -288,10 +288,7 @@ func verifySignature(data, signature, pubKey []byte) (string, error) {
// gives, which above is now. Verifying again as of the signature's // gives, which above is now. Verifying again as of the signature's
// creation time refuses a signature made before the key or subkey that // 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 // made it was made, after it expired, or after its self-signature or
// binding signature expired. The library judges the primary key by the // binding signature expired.
// 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{ signedAt := &packet.Config{
Time: func() time.Time { return sig.CreationTime }, Time: func() time.Time { return sig.CreationTime },
} }