cosmetic: reformat
This commit is contained in:
1 parent
f217d7badf
commit
e414f6d059
1 file changed
+38
-43
+38
-43
@@ -350,54 +350,49 @@ bits of the nonce, which is treated as an offset from the "established
|
|||||||
nonce". The lifecycle of a nonce for UDP is:
|
nonce". The lifecycle of a nonce for UDP is:
|
||||||
|
|
||||||
1. A fresh nonce is generated and the most significant 177 bits are
|
1. A fresh nonce is generated and the most significant 177 bits are
|
||||||
sent to the receiving peer over the TCP connection. These upper most
|
sent to the receiving peer over the TCP connection. These upper
|
||||||
177 bits are used for the next 2^15 (32768) UDP messages. This is the
|
most 177 bits are used for the next 2^15 (32768) UDP messages. This
|
||||||
"established nonce".
|
is the "established nonce".
|
||||||
|
2. Each UDP message carries the lowest 15 bits as a unique
|
||||||
2. Each UDP message carries the lowest 15 bits as a unique counter. Thus
|
counter. Thus the lowest 15 bits are combined with (appended to)
|
||||||
the lowest 15 bits are combined with (appended to) the uppermost 177
|
the uppermost 177 bits to form the unique nonce for that message.
|
||||||
bits to form the unique nonce for that message.
|
|
||||||
|
|
||||||
3. Once the sending side has sent the 16384'th message on the current
|
3. Once the sending side has sent the 16384'th message on the current
|
||||||
nonce (50% of the way through the available range), it generates a new
|
nonce (50% of the way through the available range), it generates a
|
||||||
nonce (upper 177 bits only) and sends that over the TCP connection,
|
new nonce (upper 177 bits only) and sends that over the TCP
|
||||||
thus hopefully ensuring it arrives and is ready before it is
|
connection, thus hopefully ensuring it arrives and is ready before
|
||||||
needed. The sending side will switch to using the new nonce once the
|
it is needed. The sending side will switch to using the new nonce
|
||||||
full 32768 messages of the current nonce have been used. At this
|
once the full 32768 messages of the current nonce have been
|
||||||
point, the sending side resets the offset to 0.
|
used. At this point, the sending side resets the offset to 0.
|
||||||
|
|
||||||
4. The receiving side must deal with the fact that UDP is unreliable
|
4. The receiving side must deal with the fact that UDP is unreliable
|
||||||
and unordered. The receiving side keeps track of the highest offset
|
and unordered. The receiving side keeps track of the highest offset
|
||||||
seen for each established nonce. The condition to switching to the new
|
seen for each established nonce. The condition to switching to the
|
||||||
nonce it has received via the TCP connection is: the highest offset
|
new nonce it has received via the TCP connection is: the highest
|
||||||
seen for the current nonce must be above 24576 (75% of the available
|
offset seen for the current nonce must be above 24576 (75% of the
|
||||||
range) _and_ the current message just received must have an offset
|
available range) _and_ the current message just received must have
|
||||||
less than 8192 (25% of the available range) _and_ the new offset must
|
an offset less than 8192 (25% of the available range) _and_ the new
|
||||||
be less than 8192 messages *ahead* of the highest seen offset so far
|
offset must be less than 8192 messages *ahead* of the highest seen
|
||||||
(assuming modulo 32768). If these conditions are met, the highest
|
offset so far (assuming modulo 32768). If these conditions are met,
|
||||||
offset is set to the offset of the current message and the new nonce
|
the highest offset is set to the offset of the current message and
|
||||||
is used. If those conditions are not met, the receiving side continues
|
the new nonce is used. If those conditions are not met, the
|
||||||
with the current nonce (according to the rules below), updating the
|
receiving side continues with the current nonce (according to the
|
||||||
highest offset seen as appropriate. Thus in order for the nonce to not
|
rules below), updating the highest offset seen as appropriate. Thus
|
||||||
be updated correctly would require a loss of at least 8192 messages.
|
in order for the nonce to not be updated correctly would require a
|
||||||
|
loss of at least 8192 messages.
|
||||||
5. When the receiving side switches to the new nonce, it does not
|
5. When the receiving side switches to the new nonce, it does not
|
||||||
discard the old nonce. If the highest offset seen is below 8192 (25% of
|
discard the old nonce. If the highest offset seen is below 8192
|
||||||
the range) _and_ the current message offset is above 24576 (75% of the
|
(25% of the range) _and_ the current message offset is above 24576
|
||||||
range), _and_ the current message offset is less than 8192 behind the
|
(75% of the range), _and_ the current message offset is less than
|
||||||
highest seen nonce (assuming modulo 32768), then the current message is
|
8192 behind the highest seen nonce (assuming modulo 32768), then
|
||||||
decoded with the old nonce.
|
the current message is decoded with the old nonce.
|
||||||
|
|
||||||
6. In the remaining cases, the current message is only decoded if its
|
6. In the remaining cases, the current message is only decoded if its
|
||||||
offset is within 8192 either side of the highest seen offset.
|
offset is within 8192 either side of the highest seen offset.
|
||||||
|
|
||||||
7. To avoid replay attacks, the receiving side keeps a set of which
|
7. To avoid replay attacks, the receiving side keeps a set of which
|
||||||
offsets have been used with the current and previous nonce. If the
|
offsets have been used with the current and previous nonce. If the
|
||||||
offset doesn't exist in the set, and the message can be correctly
|
offset doesn't exist in the set, and the message can be correctly
|
||||||
decoded, the offset is added to the relevant set (thus we avoid
|
decoded, the offset is added to the relevant set (thus we avoid
|
||||||
poisoning attacks). If the offset already exists in the set, or the
|
poisoning attacks). If the offset already exists in the set, or the
|
||||||
message cannot be correctly decoded, the message is not processed
|
message cannot be correctly decoded, the message is not processed
|
||||||
further.
|
further.
|
||||||
|
|
||||||
### Further reading
|
### Further reading
|
||||||
More details on the inner workings of weave can be found in the
|
More details on the inner workings of weave can be found in the
|
||||||
|
|||||||
Reference in new issue
Block a user