Skip to content

Commit

Permalink
Allow parsing empty Key Flags subpackets (#214)
Browse files Browse the repository at this point in the history
This is allowed by the spec, which says:

> This subpacket contains a list of binary flags that hold information
> about a key. It is a string of octets, and an implementation MUST NOT
> assume a fixed size. This is so it can grow over time. If a list is
> shorter than an implementation expects, the unstated flags are
> considered to be zero.

And it can be useful to explicitly say that a primary key is not allowed
to be used for any purpose (except certifying subkeys), for example.
  • Loading branch information
twiss committed Jul 8, 2024
1 parent c25e074 commit 196c8f5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions openpgp/packet/signature.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,10 @@ func parseSignatureSubpacket(sig *Signature, subpacket []byte, isHashed bool) (r
}
case keyFlagsSubpacket:
// Key flags, section 5.2.3.21
sig.FlagsValid = true
if len(subpacket) == 0 {
err = errors.StructuralError("empty key flags subpacket")
return
}
sig.FlagsValid = true
if subpacket[0]&KeyFlagCertify != 0 {
sig.FlagCertify = true
}
Expand Down

0 comments on commit 196c8f5

Please sign in to comment.