diff options
author | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-27 17:33:06 +0200 |
---|---|---|
committer | Mathias Hall-Andersen <mathias@hall-andersen.dk> | 2017-06-27 17:33:06 +0200 |
commit | 8236f3afa2eca0aae6c5da9560301c04d882c81b (patch) | |
tree | 5babaff66d6709f7f1fcdba69847ac684d1ef3de /src/peer.go | |
parent | eb75ff430d1f78e129bbfe49d612f241ca418df4 (diff) | |
download | wireguard-go-8236f3afa2eca0aae6c5da9560301c04d882c81b.tar.gz wireguard-go-8236f3afa2eca0aae6c5da9560301c04d882c81b.zip |
Implemented MAC1/2 calculation
Diffstat (limited to 'src/peer.go')
-rw-r--r-- | src/peer.go | 11 |
1 files changed, 2 insertions, 9 deletions
diff --git a/src/peer.go b/src/peer.go index 6a879cb..e192b12 100644 --- a/src/peer.go +++ b/src/peer.go @@ -2,7 +2,6 @@ package main import ( "errors" - "golang.org/x/crypto/blake2s" "net" "sync" "time" @@ -19,12 +18,10 @@ type Peer struct { keyPairs KeyPairs handshake Handshake device *Device - macKey [blake2s.Size]byte // Hash(Label-Mac1 || publicKey) - cookie []byte // cookie - cookieExpire time.Time queueInbound chan []byte queueOutbound chan *OutboundWorkQueueElement queueOutboundRouting chan []byte + mac MacStatePeer } func (device *Device) NewPeer(pk NoisePublicKey) *Peer { @@ -35,6 +32,7 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { peer.mutex.Lock() peer.device = device peer.keyPairs.Init() + peer.mac.Init(pk) peer.queueOutbound = make(chan *OutboundWorkQueueElement, OutboundQueueSize) // map public key @@ -53,11 +51,6 @@ func (device *Device) NewPeer(pk NoisePublicKey) *Peer { handshake.mutex.Lock() handshake.remoteStatic = pk handshake.precomputedStaticStatic = device.privateKey.sharedSecret(handshake.remoteStatic) - - // compute mac key - - peer.macKey = blake2s.Sum256(append([]byte(WGLabelMAC1[:]), handshake.remoteStatic[:]...)) - handshake.mutex.Unlock() peer.mutex.Unlock() |