Skip to content

Commit 5a7e470

Browse files
ebiggerszx2c4
authored andcommitted
Documentation: siphash: disambiguate HalfSipHash algorithm from hsiphash functions
Fix the documentation for the hsiphash functions to avoid conflating the HalfSipHash algorithm with the hsiphash functions, since these functions actually implement either HalfSipHash or SipHash, and random.c now uses HalfSipHash (in a very special way) without the hsiphash functions. Signed-off-by: Eric Biggers <[email protected]> Signed-off-by: Jason A. Donenfeld <[email protected]>
1 parent 2fbfeb4 commit 5a7e470

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

Documentation/security/siphash.rst

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,25 @@ even scarier, uses an easily brute-forcable 64-bit key (with a 32-bit output)
121121
instead of SipHash's 128-bit key. However, this may appeal to some
122122
high-performance `jhash` users.
123123

124+
HalfSipHash support is provided through the "hsiphash" family of functions.
125+
124126
.. warning::
125-
Do not ever use HalfSipHash except for as a hashtable key function, and
126-
only then when you can be absolutely certain that the outputs will never
127-
be transmitted out of the kernel. This is only remotely useful over
128-
`jhash` as a means of mitigating hashtable flooding denial of service
127+
Do not ever use the hsiphash functions except for as a hashtable key
128+
function, and only then when you can be absolutely certain that the outputs
129+
will never be transmitted out of the kernel. This is only remotely useful
130+
over `jhash` as a means of mitigating hashtable flooding denial of service
129131
attacks.
130132

131-
Generating a HalfSipHash key
132-
============================
133+
On 64-bit kernels, the hsiphash functions actually implement SipHash-1-3, a
134+
reduced-round variant of SipHash, instead of HalfSipHash-1-3. This is because in
135+
64-bit code, SipHash-1-3 is no slower than HalfSipHash-1-3, and can be faster.
136+
Note, this does *not* mean that in 64-bit kernels the hsiphash functions are the
137+
same as the siphash ones, or that they are secure; the hsiphash functions still
138+
use a less secure reduced-round algorithm and truncate their outputs to 32
139+
bits.
140+
141+
Generating a hsiphash key
142+
=========================
133143

134144
Keys should always be generated from a cryptographically secure source of
135145
random numbers, either using get_random_bytes or get_random_once::
@@ -139,8 +149,8 @@ random numbers, either using get_random_bytes or get_random_once::
139149

140150
If you're not deriving your key from here, you're doing it wrong.
141151

142-
Using the HalfSipHash functions
143-
===============================
152+
Using the hsiphash functions
153+
============================
144154

145155
There are two variants of the function, one that takes a list of integers, and
146156
one that takes a buffer::
@@ -183,7 +193,7 @@ You may then iterate like usual over the returned hash bucket.
183193
Performance
184194
===========
185195

186-
HalfSipHash is roughly 3 times slower than JenkinsHash. For many replacements,
187-
this will not be a problem, as the hashtable lookup isn't the bottleneck. And
188-
in general, this is probably a good sacrifice to make for the security and DoS
189-
resistance of HalfSipHash.
196+
hsiphash() is roughly 3 times slower than jhash(). For many replacements, this
197+
will not be a problem, as the hashtable lookup isn't the bottleneck. And in
198+
general, this is probably a good sacrifice to make for the security and DoS
199+
resistance of hsiphash().

0 commit comments

Comments
 (0)