go.crypto/openpgp: fix hash presence checks.
At some point in the distant past, crypto.Hash.New() changed from returning nil when a hash function wasn't provided, to panicing. Some of the code in openpgp predates this and was still using the nil check. LGTM=bradfitz R=sburford, bradfitz CC=golang-codereviews https://golang.org/cl/104850045
This commit is contained in:
+2
-2
@@ -276,10 +276,10 @@ FindLiteralData:
|
||||
// returns two hashes. The second should be used to hash the message itself and
|
||||
// performs any needed preprocessing.
|
||||
func hashForSignature(hashId crypto.Hash, sigType packet.SignatureType) (hash.Hash, hash.Hash, error) {
|
||||
h := hashId.New()
|
||||
if h == nil {
|
||||
if !hashId.Available() {
|
||||
return nil, nil, errors.UnsupportedError("hash not available: " + strconv.Itoa(int(hashId)))
|
||||
}
|
||||
h := hashId.New()
|
||||
|
||||
switch sigType {
|
||||
case packet.SigTypeBinary:
|
||||
|
||||
Reference in New Issue
Block a user