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

Method ConsumeReply

polyamide/device/cookie.go:194–213  ·  view source on GitHub ↗
(msg *MessageCookieReply)

Source from the content-addressed store, hash-verified

192}
193
194func (st *CookieGenerator) ConsumeReply(msg *MessageCookieReply) bool {
195 st.Lock()
196 defer st.Unlock()
197
198 if !st.mac2.hasLastMAC1 {
199 return false
200 }
201
202 var cookie [blake2s.Size128]byte
203
204 xchapoly, _ := chacha20poly1305.NewX(st.mac2.encryptionKey[:])
205 _, err := xchapoly.Open(cookie[:0], msg.Nonce[:], msg.Cookie[:], st.mac2.lastMAC1[:])
206 if err != nil {
207 return false
208 }
209
210 st.mac2.cookieSet = time.Now()
211 st.mac2.cookie = cookie
212 return true
213}
214
215func (st *CookieGenerator) AddMacs(msg []byte) {
216 size := len(msg)

Callers 2

RoutineHandshakeMethod · 0.80
TestCookieMAC1Function · 0.80

Calls 1

OpenMethod · 0.65

Tested by 1

TestCookieMAC1Function · 0.64