From 0604c19d3c61e244bddbbc815c6ff81effd750da Mon Sep 17 00:00:00 2001 From: Daniel Huigens Date: Fri, 22 Nov 2024 17:22:59 +0100 Subject: [PATCH] Fix armoring signatures --- cmd/armor.go | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmd/armor.go b/cmd/armor.go index 6af249d..064c433 100644 --- a/cmd/armor.go +++ b/cmd/armor.go @@ -59,13 +59,21 @@ func armorDecidingType(input []byte) (armored string, err error) { return armorKeys(input, constants.PrivateKeyHeader) } if _, ok := p.(*packet.Signature); ok { - armored, err = armor.ArmorPGPSignature(input) - if err != nil { - return armored, err + // If every packet is a signature packet, armor the input as a + // signature; otherwise, armor it as a message. + for { + if p, err = packets.Next(); err == io.EOF { + return armor.ArmorPGPSignature(input) + } + if err != nil { + break + } + if _, ok := p.(*packet.Signature); !ok { + break + } } } - armored, err = armor.ArmorPGPMessage(input) - return armored, err + return armor.ArmorPGPMessage(input) } func armorKeys(input []byte, armorType string) (armored string, err error) {