<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 16, 2017 at 8:18 AM, Matthias-Christian Ott <span dir="ltr"><<a href="mailto:ott@mirix.org" target="_blank">ott@mirix.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span class="gmail-">On 2017-03-15 00:24, Trevor Perrin wrote:<br></span><span class="gmail-">> C is the sort of trick I've seen people do to protect against short<br>
> cycles.  I've never been super-clear what analysis this is based on,<br>
> or whether it's just superstition?<br>
<br>
</span>It makes little sense to me. Can you explain what you mean by "short<br>
cycles"?<br></blockquote><div><br></div><div>I'm not cryptographer either, but here's my layman's understanding: what if there is a sequence where:<br><br></div><div>    K1 = F(K0)<br></div><div>    K2 = F(K1)<br>    ...<br></div><div>    Ki = F(Ki-1)<br></div><div>    K0 = F(Ki)<br></div><div><br></div><div>That's a cycle where you've returned to the original key.  If n is reset to 0 for each rekeying, then this would be fatal to security because the packet-specific keystreams are reused.<br><br></div><div>If n keeps incrementing, then even if there is a cycle in the key generator, the counter nonce will be different when K0 returns and the keystreams will be different.<br><br></div><div>The "XOR n" step turns up a lot in key schedule generation for modern block ciphers: each key schedule round XOR's in the subkey number.  There is a crypto reason for it with some real math behind it.  The Threefish/Skein specification says this:<br><br>"Subkey counter. The subkey counter prevents slide attacks [17, 18] and any other attacks based on identical subkeys. It also provides a defense against rotational cryptanalysis."<br><br></div><div>So "slide attacks" and "rotational cryptanalysis" may be a starting point for further research.  In our case, XOR n won't cost anything so we might as well just do it.<br></div><div><br></div><div>Cheers,<br><br></div><div>Rhys.<br><br></div></div><br></div></div>