summaryrefslogtreecommitdiffhomepage
path: root/src/cookie.go
diff options
context:
space:
mode:
authorMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-27 17:33:06 +0200
committerMathias Hall-Andersen <mathias@hall-andersen.dk>2017-06-27 17:33:06 +0200
commit8236f3afa2eca0aae6c5da9560301c04d882c81b (patch)
tree5babaff66d6709f7f1fcdba69847ac684d1ef3de /src/cookie.go
parenteb75ff430d1f78e129bbfe49d612f241ca418df4 (diff)
Implemented MAC1/2 calculation
Diffstat (limited to 'src/cookie.go')
-rw-r--r--src/cookie.go39
1 files changed, 0 insertions, 39 deletions
diff --git a/src/cookie.go b/src/cookie.go
deleted file mode 100644
index a6987a2..0000000
--- a/src/cookie.go
+++ /dev/null
@@ -1,39 +0,0 @@
-package main
-
-import (
- "errors"
- "golang.org/x/crypto/blake2s"
-)
-
-func CalculateCookie(peer *Peer, msg []byte) {
- size := len(msg)
-
- if size < blake2s.Size128*2 {
- panic(errors.New("bug: message too short"))
- }
-
- startMac1 := size - (blake2s.Size128 * 2)
- startMac2 := size - blake2s.Size128
-
- mac1 := msg[startMac1 : startMac1+blake2s.Size128]
- mac2 := msg[startMac2 : startMac2+blake2s.Size128]
-
- peer.mutex.RLock()
- defer peer.mutex.RUnlock()
-
- // set mac1
-
- func() {
- mac, _ := blake2s.New128(peer.macKey[:])
- mac.Write(msg[:startMac1])
- mac.Sum(mac1[:0])
- }()
-
- // set mac2
-
- if peer.cookie != nil {
- mac, _ := blake2s.New128(peer.cookie)
- mac.Write(msg[:startMac2])
- mac.Sum(mac2[:0])
- }
-}