Skip to content

Commit

Permalink
feat: Expose canonical write for gopenpgpg
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Jul 19, 2023
1 parent b0e833d commit e752bf4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions openpgp/canonical_text.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ func NewCanonicalTextHash(h hash.Hash) hash.Hash {
return &canonicalTextHash{h, 0}
}

// NewCanonicalTextWriter reformats text written to it into the canonical
// form. See RFC 4880, section 5.2.1.
func NewCanonicalTextWriter(w io.Writer) io.Writer {
return &canonicalTextWriter{w, 0}
}

type canonicalTextHash struct {
h hash.Hash
s int
Expand Down Expand Up @@ -63,3 +69,12 @@ func (cth *canonicalTextHash) Size() int {
func (cth *canonicalTextHash) BlockSize() int {
return cth.h.BlockSize()
}

type canonicalTextWriter struct {
w io.Writer
s int
}

func (tw *canonicalTextWriter) Write(buf []byte) (int, error) {
return writeCanonical(tw.w, buf, &tw.s)
}

0 comments on commit e752bf4

Please sign in to comment.