From 8deaf99f98548064f51a3fe5a163456257c089bb Mon Sep 17 00:00:00 2001 From: Bruno Clermont Date: Tue, 24 Jan 2017 13:12:00 +0800 Subject: [PATCH] Fix handshake peer identification --- src/cypherpunks.ru/govpn/handshake.go | 4 ++-- src/cypherpunks.ru/govpn/identity.go | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/cypherpunks.ru/govpn/handshake.go b/src/cypherpunks.ru/govpn/handshake.go index 47fe4e9..054c73e 100644 --- a/src/cypherpunks.ru/govpn/handshake.go +++ b/src/cypherpunks.ru/govpn/handshake.go @@ -141,8 +141,8 @@ func idTag(id *PeerId, timeSync int, data []byte) []byte { panic(err) } mac.Write(enc) - mac.Sum(enc[:0]) - return enc + sum := mac.Sum(nil) + return sum[len(sum)-8:] } // Start handshake's procedure from the client. It is the entry point diff --git a/src/cypherpunks.ru/govpn/identity.go b/src/cypherpunks.ru/govpn/identity.go index 09f7e33..d738c55 100644 --- a/src/cypherpunks.ru/govpn/identity.go +++ b/src/cypherpunks.ru/govpn/identity.go @@ -113,9 +113,9 @@ func (mc *MACCache) Find(data []byte) *PeerId { mt.l.Lock() mt.mac.Reset() mt.mac.Write(buf) - mt.mac.Sum(buf[:0]) + sum := mt.mac.Sum(nil) mt.l.Unlock() - if subtle.ConstantTimeCompare(buf, data[len(data)-8:]) == 1 { + if subtle.ConstantTimeCompare(sum[len(sum)-8:], data[len(data)-8:]) == 1 { ppid := PeerId(pid) mc.l.RUnlock() return &ppid -- 2.44.0