MCPcopy Create free account
hub / github.com/encodeous/nylon / Init

Method Init

polyamide/device/cookie.go:44–67  ·  view source on GitHub ↗
(pk NoisePublicKey)

Source from the content-addressed store, hash-verified

42}
43
44func (st *CookieChecker) Init(pk NoisePublicKey) {
45 st.Lock()
46 defer st.Unlock()
47
48 // mac1 state
49
50 func() {
51 hash, _ := blake2s.New256(nil)
52 hash.Write([]byte(WGLabelMAC1))
53 hash.Write(pk[:])
54 hash.Sum(st.mac1.key[:0])
55 }()
56
57 // mac2 state
58
59 func() {
60 hash, _ := blake2s.New256(nil)
61 hash.Write([]byte(WGLabelCookie))
62 hash.Write(pk[:])
63 hash.Sum(st.mac2.encryptionKey[:0])
64 }()
65
66 st.mac2.secretSet = time.Time{}
67}
68
69func (st *CookieChecker) CheckMAC1(msg []byte) bool {
70 st.RLock()

Callers 4

SetPrivateKeyMethod · 0.45
NewDeviceFunction · 0.45
TestCookieMAC1Function · 0.45
NewPeerMethod · 0.45

Calls 1

WriteMethod · 0.65

Tested by 1

TestCookieMAC1Function · 0.36