go test: use x/crypto for blake2s now that we have 128-bit mac

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2017-06-06 16:50:20 +02:00
parent 9fbd187288
commit bdbb6298a0

View file

@ -10,10 +10,10 @@ import (
"net" "net"
"time" "time"
"github.com/dchest/blake2s"
"github.com/titanous/noise" "github.com/titanous/noise"
"golang.org/x/net/icmp" "golang.org/x/net/icmp"
"golang.org/x/net/ipv4" "golang.org/x/net/ipv4"
"golang.org/x/crypto/blake2s"
) )
func ipChecksum(buf []byte) uint16 { func ipChecksum(buf []byte) uint16 {
@ -69,10 +69,10 @@ func main() {
initiationPacket[3] = 0 // Reserved initiationPacket[3] = 0 // Reserved
binary.LittleEndian.PutUint32(initiationPacket[4:], 28) // Sender index: 28 (arbitrary) binary.LittleEndian.PutUint32(initiationPacket[4:], 28) // Sender index: 28 (arbitrary)
initiationPacket, _, _ = hs.WriteMessage(initiationPacket, tai64n) initiationPacket, _, _ = hs.WriteMessage(initiationPacket, tai64n)
hasher, _ := blake2s.New(&blake2s.Config{Size: 32}) hasher, _ := blake2s.New256(nil)
hasher.Write([]byte("mac1----")) hasher.Write([]byte("mac1----"))
hasher.Write(theirPublic) hasher.Write(theirPublic)
hasher, _ = blake2s.New(&blake2s.Config{Size: 16, Key: hasher.Sum(nil)}) hasher, _ = blake2s.New128(hasher.Sum(nil))
hasher.Write(initiationPacket) hasher.Write(initiationPacket)
initiationPacket = append(initiationPacket, hasher.Sum(nil)[:16]...) initiationPacket = append(initiationPacket, hasher.Sum(nil)[:16]...)
initiationPacket = append(initiationPacket, make([]byte, 16)...) initiationPacket = append(initiationPacket, make([]byte, 16)...)