Skip to content

Commit

Permalink
fix: add ending newlines to clear/detached signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
calmh committed Jan 6, 2025
1 parent de36e04 commit 2cd886a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion internal/pgp/pgp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
openpgp "github.com/ProtonMail/go-crypto/openpgp/v2"
)

var newline = []byte{'\n'}

type Signer struct {
entities []*openpgp.Entity
}
Expand Down Expand Up @@ -48,7 +50,11 @@ func (s *Signer) DetachSign(in Seekable, out io.Writer, asciiArmour bool) error
if asciiArmour {
return openpgp.ArmoredDetachSign(out, s.entities, in, &openpgp.SignParams{Config: cfg})
}
return openpgp.DetachSign(out, s.entities, in, cfg)
if err := openpgp.DetachSign(out, s.entities, in, cfg); err != nil {
return err
}
_, err := out.Write(newline)
return err
}

func (s *Signer) ClearSign(in Seekable, out io.Writer) error {
Expand All @@ -67,5 +73,8 @@ func (s *Signer) ClearSign(in Seekable, out io.Writer) error {
if _, err := io.Copy(w, in); err != nil {
return err
}
if _, err := w.Write(newline); err != nil {
return err
}
return w.Close()
}

0 comments on commit 2cd886a

Please sign in to comment.