aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/envelope.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-12-16 04:54:34 +0800
committerobscuren <geffobscura@gmail.com>2014-12-16 04:55:00 +0800
commit54605d8c8e2c6c4b2619cf392ac430fecd7a4282 (patch)
tree7132aeddef96acf16b4e55be7514f45cbcc71139 /whisper/envelope.go
parent52ca80bdd22004525dd1decbf7f9698380bff2be (diff)
downloaddexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar.gz
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar.bz2
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar.lz
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar.xz
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.tar.zst
dexon-54605d8c8e2c6c4b2619cf392ac430fecd7a4282.zip
During env open check for pub error which indicated unencrypted payload.
Diffstat (limited to 'whisper/envelope.go')
-rw-r--r--whisper/envelope.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/whisper/envelope.go b/whisper/envelope.go
index 683e88128..dc8d3cda4 100644
--- a/whisper/envelope.go
+++ b/whisper/envelope.go
@@ -11,6 +11,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/rlp"
+ "github.com/obscuren/ecies"
)
const (
@@ -76,7 +77,10 @@ func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error) {
message.Payload = data[dataStart:]
if prv != nil {
message.Payload, err = crypto.Decrypt(prv, message.Payload)
- if err != nil {
+ switch err {
+ case ecies.ErrInvalidPublicKey: // Payload isn't encrypted
+ return &message, err
+ default:
return nil, fmt.Errorf("unable to open envelope. Decrypt failed: %v", err)
}
}