X-Git-Url: http://www.git.cypherpunks.ru/?a=blobdiff_plain;f=src%2Fcypherpunks.ru%2Fgovpn%2Fpeer.go;h=213e8174786df4db45d72abfa40a20043851b9a4;hb=da9420230cd4ed2ff1d8685c96b99043e529da62;hp=fc361790237df8cfa17876864089757018c0faa7;hpb=b97d37d9494cf064a50d30b4936393eeab32b0e1;p=govpn.git diff --git a/src/cypherpunks.ru/govpn/peer.go b/src/cypherpunks.ru/govpn/peer.go index fc36179..213e817 100644 --- a/src/cypherpunks.ru/govpn/peer.go +++ b/src/cypherpunks.ru/govpn/peer.go @@ -28,7 +28,7 @@ import ( "sync/atomic" "time" - "github.com/dchest/blake2b" + "golang.org/x/crypto/blake2b" "golang.org/x/crypto/poly1305" "golang.org/x/crypto/salsa20" ) @@ -52,7 +52,10 @@ const ( func newNonces(key *[32]byte, i uint64) chan *[NonceSize]byte { macKey := make([]byte, 32) salsa20.XORKeyStream(macKey, make([]byte, 32), make([]byte, 8), key) - mac := blake2b.NewMAC(NonceSize, macKey) + mac, err := blake2b.New256(macKey) + if err != nil { + panic(err) + } nonces := make(chan *[NonceSize]byte, NonceBucketSize*3) go func() { for { @@ -202,13 +205,13 @@ func newPeer(isClient bool, addr string, conn io.Writer, conf *PeerConf, key *[S } if isClient { - peer.noncesT = newNonces(peer.key, 1 + 2) - peer.noncesR = newNonces(peer.key, 0 + 2) - peer.noncesExpect = newNonces(peer.key, 0 + 2) + peer.noncesT = newNonces(peer.key, 1+2) + peer.noncesR = newNonces(peer.key, 0+2) + peer.noncesExpect = newNonces(peer.key, 0+2) } else { - peer.noncesT = newNonces(peer.key, 0 + 2) - peer.noncesR = newNonces(peer.key, 1 + 2) - peer.noncesExpect = newNonces(peer.key, 1 + 2) + peer.noncesT = newNonces(peer.key, 0+2) + peer.noncesR = newNonces(peer.key, 1+2) + peer.noncesExpect = newNonces(peer.key, 1+2) } peer.NonceExpect = make([]byte, NonceSize)