whisper: fix payload loss in case of plaintext decrypt

This commit is contained in:
Péter Szilágyi
2015-04-21 12:13:57 +03:00
parent 7f48eb8737
commit 87447f9f3f
2 changed files with 109 additions and 4 deletions

View File

@ -120,9 +120,12 @@ func (self *Message) encrypt(key *ecdsa.PublicKey) (err error) {
}
// decrypt decrypts an encrypted payload with a private key.
func (self *Message) decrypt(key *ecdsa.PrivateKey) (err error) {
self.Payload, err = crypto.Decrypt(key, self.Payload)
return
func (self *Message) decrypt(key *ecdsa.PrivateKey) error {
cleartext, err := crypto.Decrypt(key, self.Payload)
if err == nil {
self.Payload = cleartext
}
return err
}
// hash calculates the SHA3 checksum of the message flags and payload.