/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
return nil
}
buf := make([]byte, 8)
+ sum := make([]byte, 32)
mc.l.RLock()
for pid, mt := range mc.cache {
copy(buf, data)
mt.l.Lock()
mt.mac.Reset()
mt.mac.Write(buf)
- mt.mac.Sum(buf[:0])
+ mt.mac.Sum(sum[:0])
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