From 4aabb698d496590e16f6219a55f82bf420f38003 Mon Sep 17 00:00:00 2001 From: Lukas Burkhalter Date: Wed, 22 Nov 2023 09:44:18 +0100 Subject: [PATCH] fix(armor/clearsign): Address review comments --- openpgp/armor/armor.go | 6 ++---- openpgp/armor/encode.go | 1 - openpgp/clearsign/clearsign.go | 22 ---------------------- 3 files changed, 2 insertions(+), 27 deletions(-) diff --git a/openpgp/armor/armor.go b/openpgp/armor/armor.go index 21d4efb97..e0a677f28 100644 --- a/openpgp/armor/armor.go +++ b/openpgp/armor/armor.go @@ -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" @@ -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 diff --git a/openpgp/armor/encode.go b/openpgp/armor/encode.go index d9117c145..112f98b83 100644 --- a/openpgp/armor/encode.go +++ b/openpgp/armor/encode.go @@ -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 { diff --git a/openpgp/clearsign/clearsign.go b/openpgp/clearsign/clearsign.go index 4ef54049b..d736d6c11 100644 --- a/openpgp/clearsign/clearsign.go +++ b/openpgp/clearsign/clearsign.go @@ -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) -}