]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/cypherpunks.ru/govpn/peer.go
Do not allocate memory in each iteration
[govpn.git] / src / cypherpunks.ru / govpn / peer.go
index 792ebe7d7e1606adc0b1d8737db5ff1e7643ca9e..7bb978c8d0548b6e1e03f37f2a8d31d17e97f8e2 100644 (file)
@@ -63,10 +63,8 @@ func newNonces(key *[32]byte, i uint64) chan *[NonceSize]byte {
                        buf := new([NonceSize]byte)
                        binary.BigEndian.PutUint64(buf[:], i)
                        mac.Write(buf[:])
-                       sum = mac.Sum(nil)
-                       for index := 0; index < NonceSize; index++ {
-                               buf[index] = sum[index]
-                       }
+                       mac.Sum(sum[0:])
+                       copy(buf[:], sum)
                        nonces <- buf
                        mac.Reset()
                        i += 2