diff options
author | gluk256 <gluk256@users.noreply.github.com> | 2016-12-02 03:09:22 +0800 |
---|---|---|
committer | Felix Lange <fjl@twurst.com> | 2016-12-02 03:09:22 +0800 |
commit | 2dcf75a722f193ef5528f5af8fb4fd7c5824fded (patch) | |
tree | a30e617df7e75bc8afd3d38cf3388b2bb986479a /whisper/whisperv5/message.go | |
parent | 671fd94e256fb33761dc3b0ae2b8b6374d1d9576 (diff) | |
download | go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.gz go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.bz2 go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.lz go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.xz go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.tar.zst go-tangerine-2dcf75a722f193ef5528f5af8fb4fd7c5824fded.zip |
whisper/shhapi, whisper/whisperv5: refactoring (#3364)
* Filter refactoring
* API tests added + bugfix
* fixed the error logs
* FilterID fixed
* test cases fixed
* key generation updated
* POW updated
* got rid of redundant stuff
Diffstat (limited to 'whisper/whisperv5/message.go')
-rw-r--r-- | whisper/whisperv5/message.go | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/whisper/whisperv5/message.go b/whisper/whisperv5/message.go index 680d1f8a2..f3812b1d8 100644 --- a/whisper/whisperv5/message.go +++ b/whisper/whisperv5/message.go @@ -130,7 +130,7 @@ func (msg *SentMessage) appendPadding(params *MessageParams) { panic("please fix the padding algorithm before releasing new version") } buf := make([]byte, padSize) - randomize(buf[1:]) // change to: err = mrand.Read(buf[1:]) + randomize(buf[1:]) buf[0] = byte(padSize) if params.Padding != nil { copy(buf[1:], params.Padding) @@ -208,7 +208,10 @@ func (msg *SentMessage) encryptSymmetric(key []byte) (salt []byte, nonce []byte, _, err = crand.Read(nonce) if err != nil { return nil, nil, err + } else if !validateSymmetricKey(nonce) { + return nil, nil, errors.New("crypto/rand failed to generate nonce") } + msg.Raw = aesgcm.Seal(nil, nonce, msg.Raw, nil) return salt, nonce, nil } |