<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On 18 October 2017 at 15:51, D. Hugh Redelmeier <span dir="ltr"><<a href="mailto:hugh@mimosa.com" target="_blank">hugh@mimosa.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">| From: Andrew Cagney <<a href="mailto:andrew.cagney@gmail.com">andrew.cagney@gmail.com</a>><br>
| To: Libreswan Development List <<a href="mailto:swan-dev@lists.libreswan.org">swan-dev@lists.libreswan.org</a>><br>
<span class=""><br>
| - icookie+zero-cookie (we probably shouldn't include the zero-cookie in the<br>
| hash but it should do no harm :-)<br>
| - icookie+rcookie<br>
|<br>
| these use:<br>
|<br>
|         for (j = 0; j < COOKIE_SIZE; j++)<br>
|                 i = i * 407 + icookie[j] + rcookie[j];<br>
|<br>
| where 407 isn't prime (does anyone know where 407 came from? if not I'll<br>
| change that to a prime 521 which I'm choosing randomly) and I'll change the<br>
| math to:<br>
|<br>
|       i * 521 + icookie << 8 + rcookie<br>
|<br>
| So that we don't allow the cookies to cancel out (I could reply with<br>
| rcookie = 255 - icookie making the hash very non-random),<br>
<br>
</span>I'm surely responsible for the hash.  I'm sure that I had a reason for<br>
407 but if their is no comment, that reason is lost.  I think that I<br>
wanted it to be in the middle of the range (256,512).<br>
<br></blockquote><div><br></div><div>So if I concatenate the two bytes, something between 32k and 64k would be better.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Faster hashing could be done by treating the cookies as a sequence of<br>
uint32_t values.  I don't think that there has to be an alignment<br>
problem since the cookies are at the start of a packet.<br>
<br></blockquote><div> </div><div>That might be interesting.  But from my pov, later.<br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
How should one combine the values?  A commutative operation (^ or + or<br>
+) hashes permutations to the same value, which seems questionable.<br>
<br></blockquote><div><br></div><div>Ideally it should be viewed as a very large integer.</div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
To prevent some attacks, it might be good to mix in something private.<br>
That private thing ought to be determined once per run of pluto.  (If<br>
it changes in the middle of a run, the has table would need to be<br>
rehashed.  This is pointless if an attacker could deduce the private<br>
thing, say by a timing attack.<br>
<br><br></blockquote><div>I don't think it is worth it.  Our half is always random so only when they carefully construct some strange sequence of cookies resulting in a single hash things will get slow.   And if that happens the code requiring an initial cookie exchange would kick in.</div><div><br></div><div>Andrew</div><div><br></div></div><br></div></div>