]> Cypherpunks.ru repositories - govpn.git/commitdiff
Fix an other misusage of .Sum()
authorBruno Clermont <bruno@robotinfra.com>
Tue, 24 Jan 2017 05:54:29 +0000 (13:54 +0800)
committerSergey Matveev <stargrave@stargrave.org>
Tue, 24 Jan 2017 07:57:04 +0000 (10:57 +0300)
src/cypherpunks.ru/govpn/peer.go

index 081ea004b83700d772c12fd11db00468c531d136..792ebe7d7e1606adc0b1d8737db5ff1e7643ca9e 100644 (file)
@@ -56,13 +56,17 @@ func newNonces(key *[32]byte, i uint64) chan *[NonceSize]byte {
        if err != nil {
                panic(err)
        }
        if err != nil {
                panic(err)
        }
+       sum := make([]byte, mac.Size())
        nonces := make(chan *[NonceSize]byte, NonceBucketSize*3)
        go func() {
                for {
                        buf := new([NonceSize]byte)
                        binary.BigEndian.PutUint64(buf[:], i)
                        mac.Write(buf[:])
        nonces := make(chan *[NonceSize]byte, NonceBucketSize*3)
        go func() {
                for {
                        buf := new([NonceSize]byte)
                        binary.BigEndian.PutUint64(buf[:], i)
                        mac.Write(buf[:])
-                       mac.Sum(buf[:0])
+                       sum = mac.Sum(nil)
+                       for index := 0; index < NonceSize; index++ {
+                               buf[index] = sum[index]
+                       }
                        nonces <- buf
                        mac.Reset()
                        i += 2
                        nonces <- buf
                        mac.Reset()
                        i += 2