aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/message.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-04-21 17:13:57 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-04-28 15:49:04 +0800
commit87447f9f3f99cc59d58b029fff39fc39142f1281 (patch)
tree8ae1ea6692004e7a8e72626103da35aa3de52ede /whisper/message.go
parent7f48eb8737878e352a65475382532db26f9fbc52 (diff)
downloadgo-tangerine-87447f9f3f99cc59d58b029fff39fc39142f1281.tar.gz
go-tangerine-87447f9f3f99cc59d58b029fff39fc39142f1281.tar.zst
go-tangerine-87447f9f3f99cc59d58b029fff39fc39142f1281.zip
whisper: fix payload loss in case of plaintext decrypt
Diffstat (limited to 'whisper/message.go')
-rw-r--r--whisper/message.go9
1 files changed, 6 insertions, 3 deletions
diff --git a/whisper/message.go b/whisper/message.go
index 2b92d515c..a80380a92 100644
--- a/whisper/message.go
+++ b/whisper/message.go
@@ -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.