]> Cypherpunks.ru repositories - govpn.git/commitdiff
Fix handshake peer identification
authorBruno Clermont <bruno@robotinfra.com>
Tue, 24 Jan 2017 05:12:00 +0000 (13:12 +0800)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 24 Jan 2017 07:56:59 +0000 (10:56 +0300)
src/cypherpunks.ru/govpn/handshake.go
src/cypherpunks.ru/govpn/identity.go

index 47fe4e9056f1131d8e2b3e7b361cee0d24c585c6..054c73e32f3718c7293fb575d91e6ea175a1f09b 100644 (file)
@@ -141,8 +141,8 @@ func idTag(id *PeerId, timeSync int, data []byte) []byte {
                panic(err)
        }
        mac.Write(enc)
                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
 }
 
 // Start handshake's procedure from the client. It is the entry point
index 09f7e337b361bb629f1213616567048d5108e9b1..d738c5563e091179bd1e1fa287fb1bbcbd6ef1d9 100644 (file)
@@ -113,9 +113,9 @@ func (mc *MACCache) Find(data []byte) *PeerId {
                mt.l.Lock()
                mt.mac.Reset()
                mt.mac.Write(buf)
                mt.l.Lock()
                mt.mac.Reset()
                mt.mac.Write(buf)
-               mt.mac.Sum(buf[:0])
+               sum := mt.mac.Sum(nil)
                mt.l.Unlock()
                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
                        ppid := PeerId(pid)
                        mc.l.RUnlock()
                        return &ppid