]> Cypherpunks.ru repositories - udpobfs.git/blob - PROTOCOL
Reset nonces with the new key
[udpobfs.git] / PROTOCOL
1 Protocol is trivial. Both peers have shared 256-bit key.
2 SHA3 is used to derive four more keys from it:
3
4     SHAKE128("go.cypherpunks.ru/udpobfs" || key) ->
5         256-bit InitiatorEncryptionKey ||
6         256-bit InitiatorObfuscationKey ||
7         256-bit ResponderEncryptionKey ||
8         256-bit ResponderObfuscationKey
9
10 Each side has big-endian 64-bit packet number counter, that is used as a
11 nonce. That counter is kept in memory and only its lower 24 bits are
12 sent. When remote side receives 24-bit counter with lower value, then it
13 increments in-memory counter's remaining part. Completely the same as
14 Extended Sequence Numbers are done in IPsec's ESP.
15
16 ChaCha20 is initialised with corresponding EncryptionKey and nonce equal
17 to the full sequence number value. Its first 256-bit of output will be
18 Poly1305's one-time key. Next 256-bits are ignored. Further ones are
19 XORed with the plaintext (UDP's payload). Poly1305 is calculated over
20 the full 64-bit sequence number value and the whole ciphertext. Higher
21 40-bits of the resulting tag with lower 24-bits of the sequence number
22 are prepended to the ciphertext, encrypted with Blowfish:
23
24     Blowfish(Seq || MAC) || Ciphertext
25
26 Blowfish is initialized with ObfuscationKey. 40-bit MAC is rather weak,
27 but enough for obfuscation purposes. 24-bit part of sequence number is
28 enough for medium data-rate transmission where reordering or packets
29 drops may occur.