Skip to content

Commit

Permalink
fix(armor/clearsign): Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
lubux committed Nov 22, 2023
1 parent 0c44431 commit 4aabb69
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 27 deletions.
6 changes: 2 additions & 4 deletions openpgp/armor/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// Package armor implements OpenPGP ASCII Armor, see RFC 4880. OpenPGP Armor is
// very similar to PEM except that it has an additional CRC checksum.
package armor // import "github.com/ProtonMail/go-crypto/v2/openpgp/armor"
package armor // import "github.com/ProtonMail/go-crypto/openpgp/armor"

import (
"bufio"
Expand Down Expand Up @@ -100,9 +100,7 @@ func (l *lineReader) Read(p []byte) (n int, err error) {
return
}

// openpgpReader passes Read calls to the underlying base64 decoder, but keeps
// a running CRC of the resulting data and checks the CRC against the value
// found by the lineReader at EOF.
// openpgpReader passes Read calls to the underlying base64 decoder.
type openpgpReader struct {
lReader *lineReader
b64Reader io.Reader
Expand Down
1 change: 0 additions & 1 deletion openpgp/armor/encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ var armorEndOfLineOut = []byte("-----\n")

const crc24Init = 0xb704ce
const crc24Poly = 0x1864cfb
const crc24Mask = 0xffffff

// crc24 calculates the OpenPGP checksum as specified in RFC 4880, section 6.1
func crc24(crc uint32, d []byte) uint32 {
Expand Down
22 changes: 0 additions & 22 deletions openpgp/clearsign/clearsign.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,25 +476,3 @@ func nameOfHash(h crypto.Hash) string {
}
return ""
}

// nameToHash returns a hash for a given OpenPGP name, or 0
// if the name isn't known. See RFC 4880, section 9.4.
func nameToHash(h string) crypto.Hash {
switch h {
case "SHA1":
return crypto.SHA1
case "SHA224":
return crypto.SHA224
case "SHA256":
return crypto.SHA256
case "SHA384":
return crypto.SHA384
case "SHA512":
return crypto.SHA512
case "SHA3-256":
return crypto.SHA3_256
case "SHA3-512":
return crypto.SHA3_512
}
return crypto.Hash(0)
}

0 comments on commit 4aabb69

Please sign in to comment.