diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-29 22:05:37 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-29 22:05:37 +0800 |
commit | 4044a8cea44cd4cee3a8ddaf51a76b71c9d22042 (patch) | |
tree | 1aa3776381e8e117b66e4a8ed1bf83e29d966ff1 /crypto/ecies/ecies.go | |
parent | c541b38fb36587d23c60f5e2f2b9b3c8700ec489 (diff) | |
parent | 61be63bb9b8527bb3e2357ad35a0f4ef29304da1 (diff) | |
download | go-tangerine-1.3.4.tar go-tangerine-1.3.4.tar.gz go-tangerine-1.3.4.tar.bz2 go-tangerine-1.3.4.tar.lz go-tangerine-1.3.4.tar.xz go-tangerine-1.3.4.tar.zst go-tangerine-1.3.4.zip |
Merge pull request #2258 from obscuren/release/1.3.4v1.3.4
Homestead Release Candidate
Diffstat (limited to 'crypto/ecies/ecies.go')
-rw-r--r-- | crypto/ecies/ecies.go | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/crypto/ecies/ecies.go b/crypto/ecies/ecies.go index a3b520dd5..3443a1c1a 100644 --- a/crypto/ecies/ecies.go +++ b/crypto/ecies/ecies.go @@ -191,11 +191,9 @@ func concatKDF(hash hash.Hash, z, s1 []byte, kdLen int) (k []byte, err error) { // messageTag computes the MAC of a message (called the tag) as per // SEC 1, 3.5. func messageTag(hash func() hash.Hash, km, msg, shared []byte) []byte { - if shared == nil { - shared = make([]byte, 0) - } mac := hmac.New(hash, km) mac.Write(msg) + mac.Write(shared) tag := mac.Sum(nil) return tag } @@ -242,9 +240,11 @@ func symDecrypt(rand io.Reader, params *ECIESParams, key, ct []byte) (m []byte, return } -// Encrypt encrypts a message using ECIES as specified in SEC 1, 5.1. If -// the shared information parameters aren't being used, they should be -// nil. +// Encrypt encrypts a message using ECIES as specified in SEC 1, 5.1. +// +// s1 and s2 contain shared information that is not part of the resulting +// ciphertext. s1 is fed into key derivation, s2 is fed into the MAC. If the +// shared information parameters aren't being used, they should be nil. func Encrypt(rand io.Reader, pub *PublicKey, m, s1, s2 []byte) (ct []byte, err error) { params := pub.Params if params == nil { |