diff options
author | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-24 19:57:57 +0800 |
---|---|---|
committer | Jeffrey Wilcke <jeffrey@ethereum.org> | 2016-02-24 19:57:57 +0800 |
commit | 483feb0d3f015f103f80dbaf2aca9a130f5d964c (patch) | |
tree | 8137bf41be9b84bc6797ec55c861332b2efc3ab1 /p2p/discover/udp.go | |
parent | 1415669ac31cf8f06d107e06681b95c2b5e1c040 (diff) | |
parent | 139f6a0f4c1b3358a92bdfb5637878b2c97eba78 (diff) | |
download | dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.gz dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.bz2 dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.lz dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.xz dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.tar.zst dexon-483feb0d3f015f103f80dbaf2aca9a130f5d964c.zip |
Merge pull request #2242 from jimenezrick/upstream-crypto
Closes #2241: Use Keccak-256 from golang.org/x/crypto/sha3 and mention explicitly
Diffstat (limited to 'p2p/discover/udp.go')
-rw-r--r-- | p2p/discover/udp.go | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/p2p/discover/udp.go b/p2p/discover/udp.go index 03fa0c348..74758b6fd 100644 --- a/p2p/discover/udp.go +++ b/p2p/discover/udp.go @@ -466,7 +466,7 @@ func encodePacket(priv *ecdsa.PrivateKey, ptype byte, req interface{}) ([]byte, return nil, err } packet := b.Bytes() - sig, err := crypto.Sign(crypto.Sha3(packet[headSize:]), priv) + sig, err := crypto.Sign(crypto.Keccak256(packet[headSize:]), priv) if err != nil { glog.V(logger.Error).Infoln("could not sign packet:", err) return nil, err @@ -475,7 +475,7 @@ func encodePacket(priv *ecdsa.PrivateKey, ptype byte, req interface{}) ([]byte, // add the hash to the front. Note: this doesn't protect the // packet in any way. Our public key will be part of this hash in // The future. - copy(packet, crypto.Sha3(packet[macSize:])) + copy(packet, crypto.Keccak256(packet[macSize:])) return packet, nil } @@ -527,11 +527,11 @@ func decodePacket(buf []byte) (packet, NodeID, []byte, error) { return nil, NodeID{}, nil, errPacketTooSmall } hash, sig, sigdata := buf[:macSize], buf[macSize:headSize], buf[headSize:] - shouldhash := crypto.Sha3(buf[macSize:]) + shouldhash := crypto.Keccak256(buf[macSize:]) if !bytes.Equal(hash, shouldhash) { return nil, NodeID{}, nil, errBadHash } - fromID, err := recoverNodeID(crypto.Sha3(buf[headSize:]), sig) + fromID, err := recoverNodeID(crypto.Keccak256(buf[headSize:]), sig) if err != nil { return nil, NodeID{}, hash, err } @@ -593,7 +593,7 @@ func (req *findnode) handle(t *udp, from *net.UDPAddr, fromID NodeID, mac []byte // (which is a much bigger packet than findnode) to the victim. return errUnknownNode } - target := crypto.Sha3Hash(req.Target[:]) + target := crypto.Keccak256Hash(req.Target[:]) t.mutex.Lock() closest := t.closest(target, bucketSize).entries t.mutex.Unlock() |