aboutsummaryrefslogtreecommitdiffstats
path: root/whisper/envelope.go
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2015-01-02 17:30:27 +0800
committerobscuren <geffobscura@gmail.com>2015-01-02 17:30:27 +0800
commit0fb1bcd32192b8bf05a328b955a08da4cefe0180 (patch)
tree67460b927eb41b2876e8e6b7eb9dece494dbd088 /whisper/envelope.go
parent8da07e91e40c1d1bb43763b7e959ae92e5770af2 (diff)
parenta4dc12f12c7a06f5e28d5b1e760249875ef7a8c5 (diff)
downloaddexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar.gz
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar.bz2
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar.lz
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar.xz
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.tar.zst
dexon-0fb1bcd32192b8bf05a328b955a08da4cefe0180.zip
Merge branch 'poc8' into docbranch
Diffstat (limited to 'whisper/envelope.go')
-rw-r--r--whisper/envelope.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/whisper/envelope.go b/whisper/envelope.go
index 683e88128..066e20f6a 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 (
@@ -73,10 +74,15 @@ func (self *Envelope) Open(prv *ecdsa.PrivateKey) (msg *Message, err error) {
message.Flags = data[0]
message.Signature = data[1:66]
}
- message.Payload = data[dataStart:]
+
+ payload := data[dataStart:]
if prv != nil {
- message.Payload, err = crypto.Decrypt(prv, message.Payload)
- if err != nil {
+ message.Payload, err = crypto.Decrypt(prv, payload)
+ switch err {
+ case ecies.ErrInvalidPublicKey: // Payload isn't encrypted
+ message.Payload = payload
+ return &message, err
+ default:
return nil, fmt.Errorf("unable to open envelope. Decrypt failed: %v", err)
}
}