diff options
Diffstat (limited to 'src/send.go')
-rw-r--r-- | src/send.go | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/send.go b/src/send.go index 7a2fe44..2db74ba 100644 --- a/src/send.go +++ b/src/send.go @@ -281,17 +281,22 @@ func (device *Device) RoutineEncryption() { // populate header fields - func() { - header := work.buffer[:MessageTransportHeaderSize] + header := work.buffer[:MessageTransportHeaderSize] - fieldType := header[0:4] - fieldReceiver := header[4:8] - fieldNonce := header[8:16] + fieldType := header[0:4] + fieldReceiver := header[4:8] + fieldNonce := header[8:16] - binary.LittleEndian.PutUint32(fieldType, MessageTransportType) - binary.LittleEndian.PutUint32(fieldReceiver, work.keyPair.remoteIndex) - binary.LittleEndian.PutUint64(fieldNonce, work.nonce) - }() + binary.LittleEndian.PutUint32(fieldType, MessageTransportType) + binary.LittleEndian.PutUint32(fieldReceiver, work.keyPair.remoteIndex) + binary.LittleEndian.PutUint64(fieldNonce, work.nonce) + + // pad content to MTU size + + mtu := int(atomic.LoadInt32(&device.mtu)) + for i := len(work.packet); i < mtu; i++ { + work.packet = append(work.packet, 0) + } // encrypt content |