benilla-re systems structs docs

WowConnection

struct · net · 304 bytes

Meaning
Holds one socket connection: state, handler, receive buffer, send queue and header cipher
Confidence
verified, proof one
Finding
net/wire#header-cipher

Finding: Header cipher in net: the wire

Once armed, the connection ciphers the first h + 4 bytes of every packet it sends and the first h + 2 bytes of every packet it receives, h being that packet's size-header length: the size header and the opcode. Bodies stay in clear. With a 40-byte key K, an index j and a feedback byte f, one state per direction:

  • send: c = (K[j] ^ p) + f, then f = c;
  • receive: p = K[j] ^ (c − f), then f = c;
  • after each byte, j = (j + 1) mod 40. Arithmetic is modulo 256.

The index and feedback carry over from packet to packet. Arming zeroes both states.

The derivation is in the doc.

Fields 15

offsetsizetypenamemeaningconfidencefinding
0x00104uint32_tm_stateHolds the socket state: 5 connected, 6 closed, 7 closingverified, proof onenet/wire#sending
0x001c4uint8_t *m_recvBufferHolds the receive bufferverified, proof onenet/wire#receive-loop
0x00204uint32_tm_recvFillHolds the count of bytes in the receive bufferverified, proof onenet/wire#receive-loop
0x00244uint32_tm_recvCapacityHolds the receive buffer's size, grown by 1024verified, proof onenet/wire#receive-loop
0x007816uint8_t[16]m_peerAddressHolds the peer socket address read when the connection comes upverified, proof onenet/wire#connecting
0x008816uint8_t[16]m_localAddressHolds the local socket address read when the connection comes upverified, proof onenet/wire#connecting
0x01201uint8_tm_cipherArmedHolds 1 while the header cipher is armedverified, proof onenet/wire#header-cipher
0x01211uint8_tm_sendIndexHolds the send key index, 0 to 39verified, proof onenet/wire#header-cipher
0x01221uint8_tm_sendFeedbackHolds the last ciphertext byte sentverified, proof onenet/wire#header-cipher
0x01231uint8_tm_sendSpanHolds the bytes after the size header that are ciphered on send, 4verified, proof onenet/wire#header-cipher
0x01241uint8_tm_recvIndexHolds the receive key index, 0 to 39verified, proof onenet/wire#header-cipher
0x01251uint8_tm_recvFeedbackHolds the last ciphertext byte receivedverified, proof onenet/wire#header-cipher
0x01261uint8_tm_recvSpanHolds the bytes after the size header that are deciphered on receive, 2verified, proof onenet/wire#header-cipher
0x01271uint8_tm_keyLengthHolds the key length, 40verified, proof onenet/wire#header-cipher
0x01284uint8_t *m_keyHolds the key, the NetClient's 40 bytes at +0x48verified, proof onenet/wire#header-cipher