From 9b0af513867fad4aeb3516e4711dd0ea4f5bc90c Mon Sep 17 00:00:00 2001 From: Felix Lange Date: Sat, 18 Feb 2017 09:24:12 +0100 Subject: crypto: add btcec fallback for sign/recover without cgo (#3680) * vendor: add github.com/btcsuite/btcd/btcec * crypto: add btcec fallback for sign/recover without cgo This commit adds a non-cgo fallback implementation of secp256k1 operations. * crypto, core/vm: remove wrappers for sha256, ripemd160 --- whisper/whisperv5/message.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'whisper/whisperv5/message.go') diff --git a/whisper/whisperv5/message.go b/whisper/whisperv5/message.go index a095f7c0c..255ad380d 100644 --- a/whisper/whisperv5/message.go +++ b/whisper/whisperv5/message.go @@ -30,6 +30,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" + "github.com/ethereum/go-ethereum/crypto/ecies" "github.com/ethereum/go-ethereum/logger" "github.com/ethereum/go-ethereum/logger/glog" "golang.org/x/crypto/pbkdf2" @@ -163,7 +164,7 @@ func (msg *SentMessage) encryptAsymmetric(key *ecdsa.PublicKey) error { if !ValidatePublicKey(key) { return fmt.Errorf("Invalid public key provided for asymmetric encryption") } - encrypted, err := crypto.Encrypt(key, msg.Raw) + encrypted, err := ecies.Encrypt(crand.Reader, ecies.ImportECDSAPublic(key), msg.Raw, nil, nil) if err == nil { msg.Raw = encrypted } @@ -293,7 +294,7 @@ func (msg *ReceivedMessage) decryptSymmetric(key []byte, salt []byte, nonce []by // decryptAsymmetric decrypts an encrypted payload with a private key. func (msg *ReceivedMessage) decryptAsymmetric(key *ecdsa.PrivateKey) error { - decrypted, err := crypto.Decrypt(key, msg.Raw) + decrypted, err := ecies.ImportECDSA(key).Decrypt(crand.Reader, msg.Raw, nil, nil) if err == nil { msg.Raw = decrypted } -- cgit v1.2.3