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:
@@ -296,10 +296,10 @@ func Encode(w io.Writer, privateKey *packet.PrivateKey, config *packet.Config) (
|
||||
return nil, errors.UnsupportedError("unknown hash type: " + strconv.Itoa(int(hashType)))
|
||||
}
|
||||
|
||||
h := hashType.New()
|
||||
if h == nil {
|
||||
if !hashType.Available() {
|
||||
return nil, errors.UnsupportedError("unsupported hash type: " + strconv.Itoa(int(hashType)))
|
||||
}
|
||||
h := hashType.New()
|
||||
|
||||
buffered := bufio.NewWriter(w)
|
||||
// start has a \n at the beginning that we don't want here.
|
||||
|
||||
Reference in New Issue
Block a user