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

Method RoutineDecryption

polyamide/device/receive.go:237–266  ·  view source on GitHub ↗
(id int)

Source from the content-addressed store, hash-verified

235}
236
237func (device *Device) RoutineDecryption(id int) {
238 var nonce [chacha20poly1305.NonceSize]byte
239
240 defer device.Log.Verbosef("Routine: decryption worker %d - stopped", id)
241 device.Log.Verbosef("Routine: decryption worker %d - started", id)
242
243 for elemsContainer := range device.queue.decryption.c {
244 for _, elem := range elemsContainer.elems {
245 // split message into fields
246 counter := elem.packet[MessageTransportOffsetCounter:MessageTransportOffsetContent]
247 content := elem.packet[MessageTransportOffsetContent:]
248
249 // decrypt and release to consumer
250 var err error
251 elem.counter = binary.LittleEndian.Uint64(counter)
252 // copy counter to nonce
253 binary.LittleEndian.PutUint64(nonce[0x4:0xc], elem.counter)
254 elem.packet, err = elem.keypair.receive.Open(
255 content[:0],
256 nonce[:],
257 content,
258 nil,
259 )
260 if err != nil {
261 elem.packet = nil
262 }
263 }
264 elemsContainer.Unlock()
265 }
266}
267
268/* Handles incoming packets related to handshake
269 */

Callers 1

NewDeviceFunction · 0.80

Implementers 4

NativeTunpolyamide/tun/tun_linux.go
netTunpolyamide/tun/netstack/tun.go
chTunpolyamide/tun/tuntest/tuntest.go
fakeTUNDeviceSizedpolyamide/device/device_test.go

Calls 1

OpenMethod · 0.65

Tested by

no test coverage detected