All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v5 0/4] The SipHash Patchset
@ 2016-12-15 20:29 ` Jason A. Donenfeld
  0 siblings, 0 replies; 181+ messages in thread
From: Jason A. Donenfeld @ 2016-12-15 20:29 UTC (permalink / raw)
  To: Netdev, kernel-hardening, LKML, linux-crypto, David Laight,
	Ted Tso, Hannes Frederic Sowa, Linus Torvalds, Eric Biggers,
	Tom Herbert, George Spelvin, Vegard Nossum, ak, davem, luto
  Cc: Jason A. Donenfeld

Hey folks,

I think we're approaching the end of the review for this patchset and we're
getting somewhat close to being ready for it being queued up. At this point,
I've incorporated all of the extremely helpful and instructive suggestions
from the list.

For this v5, we now accept u64[2] as the key, so that alignment is taken
care of naturally. For other alignment issues, we have both the fast aligned
version and the unaligned version, depending on what's necessary. We've
worked out the issues for struct padding. The functions now take a void
pointer to avoid ugly casting, which also helps us shed the inline helper
functions which were not very pretty. The replacements of MD5 have been
benchmarked and show a big increase in speed. We've even come up with a
better naming scheme for dword/qword. All and all it's shaping up nicely.

So, if this series looks good to you, please send along your Reviewed-by,
so we can begin to get this completed. If there are still lingering issues,
let me know and I'll incorporated them into a v6 if necessary.

Thanks,
Jason

Jason A. Donenfeld (4):
  siphash: add cryptographically secure PRF
  siphash: add Nu{32,64} helpers
  secure_seq: use SipHash in place of MD5
  random: use SipHash in place of MD5

 drivers/char/random.c   |  32 +++----
 include/linux/siphash.h |  65 ++++++++++++++
 lib/Kconfig.debug       |   6 +-
 lib/Makefile            |   5 +-
 lib/siphash.c           | 223 ++++++++++++++++++++++++++++++++++++++++++++++++
 lib/test_siphash.c      | 101 ++++++++++++++++++++++
 net/core/secure_seq.c   | 133 +++++++++++------------------
 7 files changed, 460 insertions(+), 105 deletions(-)
 create mode 100644 include/linux/siphash.h
 create mode 100644 lib/siphash.c
 create mode 100644 lib/test_siphash.c

-- 
2.11.0

^ permalink raw reply	[flat|nested] 181+ messages in thread
* Re: Re: [PATCH v5 1/4] siphash: add cryptographically secure PRF
@ 2016-12-16 21:01 Jason A. Donenfeld
  2016-12-16 21:15 ` Hannes Frederic Sowa
  0 siblings, 1 reply; 181+ messages in thread
From: Jason A. Donenfeld @ 2016-12-16 21:01 UTC (permalink / raw)
  To: kernel-hardening, Theodore Ts'o, George Spelvin, Jason,
	Andi Kleen, David Miller, David Laight, Daniel J . Bernstein,
	Eric Biggers, Hannes Frederic Sowa, Jean-Philippe Aumasson,
	Linux Crypto Mailing List, LKML, Andy Lutomirski, Netdev,
	Tom Herbert, Linus Torvalds, Vegard Nossum

Hi Ted,

On Fri, Dec 16, 2016 at 9:43 PM, Theodore Ts'o <tytso@mit.edu> wrote:
> What should we do with get_random_int() and get_random_long()?  In
> some cases it's being used in performance sensitive areas, and where
> anti-DoS protection might be enough.  In others, maybe not so much.
>
> If we rekeyed the secret used by get_random_int() and
> get_random_long() frequently (say, every minute or every 5 minutes),
> would that be sufficient for current and future users of these
> interfaces?

get_random_int() and get_random_long() should quite clearly use
SipHash with its secure 128-bit key and not HalfSipHash with its
64-bit key. HalfSipHash is absolutely insufficient for this use case.
Remember, we're already an order of magnitude or more faster than
md5...

With regard to periodic rekeying... since the secret is 128-bits, I
believe this is likely sufficient for _not_ rekeying. There's also the
chaining variable, to tie together invocations of the function. If
you'd prefer, instead of the chaining variable, we could use some
siphash output to mutate the original key, but I don't think this
approach is actually better and might introduce vulnerabilities. In my
opinion chaining+128bitkey is sufficient. On the other hand, rekeying
every X minutes is 3 or 4 lines of code. If you want (just say so),
I'll add this to my next revision.

You asked about the security requirements of these functions. The
comment says they're not cryptographically secure. And right now with
MD5 they're not. So the expectations are pretty low. Moving to siphash
adds some cryptographic security, certainly. Moving to siphash plus
rekeying adds a bit more. Of course, on recent x86, RDRAND is used
instead, so the cryptographic strength then depends on the thickness
of your tinfoil hat. So probably we shouldn't change what we advertise
these functions provide, even though we're certainly improving them
performance-wise and security-wise.

> P.S.  I'll note that my performance figures when testing changes to
> get_random_int() were done on a 32-bit x86; Jason, I'm guessing your
> figures were using a 64-bit x86 system?.  I haven't tried 32-bit ARM
> or smaller CPU's (e.g., mips, et. al.) that might be more likely to be
> used on IoT devices, but I'm worried about those too, of course.

Yes, on x86-64. But on i386 chacha20 incurs nearly the same kind of
slowdown as siphash, so I expect the comparison to be more or less
equal. There's another thing I really didn't like about your chacha20
approach which is that it uses the /dev/urandom pool, which means
various things need to kick in in the background to refill this.
Additionally, having to refill the buffered chacha output every 32 or
so longs isn't nice. These things together make for inconsistent and
hard to understand general operating system performance, because
get_random_long is called at every process startup for ASLR. So, in
the end, I believe there's another reason for going with the siphash
approach: deterministic performance.

Jason

^ permalink raw reply	[flat|nested] 181+ messages in thread

end of thread, other threads:[~2016-12-22 19:50 UTC | newest]

Thread overview: 181+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-15 20:29 [PATCH v5 0/4] The SipHash Patchset Jason A. Donenfeld
2016-12-15 20:29 ` [kernel-hardening] " Jason A. Donenfeld
2016-12-15 20:30 ` [PATCH v5 1/4] siphash: add cryptographically secure PRF Jason A. Donenfeld
2016-12-15 20:30   ` [kernel-hardening] " Jason A. Donenfeld
2016-12-15 22:42   ` George Spelvin
2016-12-15 22:42     ` [kernel-hardening] " George Spelvin
2016-12-15 23:00     ` Jean-Philippe Aumasson
2016-12-15 23:00       ` [kernel-hardening] " Jean-Philippe Aumasson
2016-12-15 23:28       ` George Spelvin
2016-12-15 23:28         ` [kernel-hardening] " George Spelvin
2016-12-16 17:06         ` David Laight
2016-12-16 17:06           ` [kernel-hardening] " David Laight
2016-12-16 17:06           ` David Laight
2016-12-16 17:09           ` Jason A. Donenfeld
2016-12-16 17:09             ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 17:09             ` Jason A. Donenfeld
2016-12-16  3:46       ` George Spelvin
2016-12-16  3:46         ` [kernel-hardening] " George Spelvin
2016-12-16  8:08         ` Jean-Philippe Aumasson
2016-12-16  8:08           ` [kernel-hardening] " Jean-Philippe Aumasson
2016-12-16 12:39           ` Jason A. Donenfeld
2016-12-16 12:39             ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 13:22             ` Jean-Philippe Aumasson
2016-12-16 13:22               ` [kernel-hardening] " Jean-Philippe Aumasson
2016-12-16 15:51               ` Jason A. Donenfeld
2016-12-16 15:51                 ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 17:36                 ` George Spelvin
2016-12-16 17:36                   ` [kernel-hardening] " George Spelvin
2016-12-16 18:00                   ` Jason A. Donenfeld
2016-12-16 18:00                     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 20:17                     ` George Spelvin
2016-12-16 20:17                       ` [kernel-hardening] " George Spelvin
2016-12-16 20:43                       ` Theodore Ts'o
2016-12-16 20:43                         ` [kernel-hardening] " Theodore Ts'o
2016-12-16 22:13                         ` George Spelvin
2016-12-16 22:13                           ` [kernel-hardening] " George Spelvin
2016-12-16 22:15                           ` Andy Lutomirski
2016-12-16 22:15                             ` [kernel-hardening] " Andy Lutomirski
2016-12-16 22:15                             ` Andy Lutomirski
2016-12-16 22:18                           ` Jason A. Donenfeld
2016-12-16 22:18                             ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 23:44                             ` George Spelvin
2016-12-16 23:44                               ` [kernel-hardening] " George Spelvin
2016-12-17  1:39                               ` Jason A. Donenfeld
2016-12-17  1:39                                 ` [kernel-hardening] " Jason A. Donenfeld
2016-12-17  2:15                                 ` George Spelvin
2016-12-17  2:15                                   ` [kernel-hardening] " George Spelvin
2016-12-17 15:41                                   ` Theodore Ts'o
2016-12-17 15:41                                     ` [kernel-hardening] " Theodore Ts'o
2016-12-17 16:14                                     ` Jeffrey Walton
2016-12-17 16:14                                       ` [kernel-hardening] " Jeffrey Walton
2016-12-19 17:21                                     ` Jason A. Donenfeld
2016-12-17 12:42                 ` George Spelvin
2016-12-17 12:42                   ` [kernel-hardening] " George Spelvin
2016-12-16 20:39               ` Jason A. Donenfeld
2016-12-16 20:39                 ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 19:47             ` Tom Herbert
2016-12-16 19:47               ` [kernel-hardening] " Tom Herbert
2016-12-16 20:41               ` George Spelvin
2016-12-16 20:41                 ` [kernel-hardening] " George Spelvin
2016-12-16 20:57                 ` Tom Herbert
2016-12-16 20:57                   ` [kernel-hardening] " Tom Herbert
2016-12-16 20:44               ` Daniel Micay
2016-12-16 20:44                 ` [kernel-hardening] " Daniel Micay
2016-12-16 21:09                 ` Jason A. Donenfeld
2016-12-17 15:21               ` George Spelvin
2016-12-17 15:21                 ` [kernel-hardening] " George Spelvin
2016-12-19 14:14                 ` David Laight
2016-12-19 14:14                   ` [kernel-hardening] " David Laight
2016-12-19 14:14                   ` David Laight
2016-12-19 18:10                   ` George Spelvin
2016-12-19 18:10                     ` [kernel-hardening] " George Spelvin
2016-12-19 20:18                     ` Jean-Philippe Aumasson
2016-12-19 20:18                       ` [kernel-hardening] " Jean-Philippe Aumasson
2016-12-16  2:14   ` kbuild test robot
2016-12-16  2:14     ` [kernel-hardening] " kbuild test robot
2016-12-17 14:55   ` Jeffrey Walton
2016-12-17 14:55     ` [kernel-hardening] " Jeffrey Walton
2016-12-19 17:08     ` Jason A. Donenfeld
2016-12-19 17:08       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-19 17:19       ` Jean-Philippe Aumasson
2016-12-19 17:19         ` [kernel-hardening] " Jean-Philippe Aumasson
2016-12-15 20:30 ` [PATCH v5 2/4] siphash: add Nu{32,64} helpers Jason A. Donenfeld
2016-12-15 20:30   ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 10:39   ` David Laight
2016-12-16 10:39     ` [kernel-hardening] " David Laight
2016-12-16 10:39     ` David Laight
2016-12-16 15:44     ` George Spelvin
2016-12-16 15:44       ` [kernel-hardening] " George Spelvin
2016-12-15 20:30 ` [PATCH v5 3/4] secure_seq: use SipHash in place of MD5 Jason A. Donenfeld
2016-12-15 20:30   ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  9:59   ` David Laight
2016-12-16  9:59     ` [kernel-hardening] " David Laight
2016-12-16  9:59     ` David Laight
2016-12-16 15:57     ` Jason A. Donenfeld
2016-12-16 15:57       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 15:57       ` Jason A. Donenfeld
2016-12-15 20:30 ` [PATCH v5 4/4] random: " Jason A. Donenfeld
2016-12-15 20:30   ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  3:03 ` [PATCH v6 0/5] The SipHash Patchset Jason A. Donenfeld
2016-12-16  3:03   ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  3:03   ` [PATCH v6 1/5] siphash: add cryptographically secure PRF Jason A. Donenfeld
2016-12-16  3:03     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  3:03   ` [PATCH v6 2/5] secure_seq: use SipHash in place of MD5 Jason A. Donenfeld
2016-12-16  3:03     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  3:03   ` [PATCH v6 3/5] random: " Jason A. Donenfeld
2016-12-16  3:03     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16 21:31     ` Andy Lutomirski
2016-12-16 21:31       ` [kernel-hardening] " Andy Lutomirski
2016-12-16 21:31       ` Andy Lutomirski
2016-12-16  3:03   ` [PATCH v6 4/5] md5: remove from lib and only live in crypto Jason A. Donenfeld
2016-12-16  3:03     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-16  3:03   ` [PATCH v6 5/5] syncookies: use SipHash in place of SHA1 Jason A. Donenfeld
2016-12-16  3:03     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:02   ` [PATCH v7 0/6] The SipHash Patchset Jason A. Donenfeld
2016-12-21 23:02     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:02     ` [PATCH v7 1/6] siphash: add cryptographically secure PRF Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22  1:40       ` Stephen Hemminger
2016-12-22  1:40         ` [kernel-hardening] " Stephen Hemminger
2016-12-21 23:02     ` [PATCH v7 2/6] secure_seq: use SipHash in place of MD5 Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:02     ` [PATCH v7 3/6] random: " Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:13       ` Jason A. Donenfeld
2016-12-21 23:13         ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:42       ` Andy Lutomirski
2016-12-21 23:42         ` [kernel-hardening] " Andy Lutomirski
2016-12-21 23:42         ` Andy Lutomirski
2016-12-22  2:07         ` Hannes Frederic Sowa
2016-12-22  2:07           ` [kernel-hardening] " Hannes Frederic Sowa
2016-12-22  2:07           ` Hannes Frederic Sowa
2016-12-22  2:09           ` Andy Lutomirski
2016-12-22  2:09             ` [kernel-hardening] " Andy Lutomirski
2016-12-22  2:09             ` Andy Lutomirski
2016-12-22  2:49           ` Jason A. Donenfeld
2016-12-22  2:49             ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22  2:49             ` Jason A. Donenfeld
2016-12-22  3:12             ` Jason A. Donenfeld
2016-12-22  3:12               ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22  3:12               ` Jason A. Donenfeld
2016-12-22  5:41             ` Theodore Ts'o
2016-12-22  5:41               ` [kernel-hardening] " Theodore Ts'o
2016-12-22  6:03               ` Jason A. Donenfeld
2016-12-22 15:58                 ` Theodore Ts'o
2016-12-22 15:58                   ` [kernel-hardening] " Theodore Ts'o
2016-12-22 16:16                   ` Jason A. Donenfeld
2016-12-22 16:16                     ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22 16:30                     ` Theodore Ts'o
2016-12-22 16:36                       ` Jason A. Donenfeld
2016-12-22 12:47               ` Hannes Frederic Sowa
2016-12-22 12:47                 ` [kernel-hardening] " Hannes Frederic Sowa
2016-12-22 13:10                 ` Jason A. Donenfeld
2016-12-22 15:05                   ` Hannes Frederic Sowa
2016-12-22 15:12                     ` Jason A. Donenfeld
2016-12-22 15:29                       ` Jason A. Donenfeld
2016-12-22 15:33                         ` Hannes Frederic Sowa
2016-12-22 15:33                           ` [kernel-hardening] " Hannes Frederic Sowa
2016-12-22 15:41                           ` Jason A. Donenfeld
2016-12-22 15:51                             ` Hannes Frederic Sowa
2016-12-22 15:51                               ` [kernel-hardening] " Hannes Frederic Sowa
2016-12-22 15:53                               ` Jason A. Donenfeld
2016-12-22 15:54                   ` Theodore Ts'o
2016-12-22 15:54                     ` [kernel-hardening] " Theodore Ts'o
2016-12-22 18:08                     ` Hannes Frederic Sowa
2016-12-22 18:13                       ` Jason A. Donenfeld
2016-12-22 18:13                         ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22 19:50                       ` Theodore Ts'o
2016-12-22  2:31         ` Jason A. Donenfeld
2016-12-22  2:31           ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22  2:31           ` Jason A. Donenfeld
2016-12-21 23:02     ` [PATCH v7 4/6] md5: remove from lib and only live in crypto Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:02     ` [PATCH v7 5/6] syncookies: use SipHash in place of SHA1 Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-21 23:02     ` [PATCH v7 6/6] siphash: implement HalfSipHash1-3 for hash tables Jason A. Donenfeld
2016-12-21 23:02       ` [kernel-hardening] " Jason A. Donenfeld
2016-12-22  0:46       ` Andi Kleen
2016-12-22  0:46         ` [kernel-hardening] " Andi Kleen
2016-12-16 21:01 Re: [PATCH v5 1/4] siphash: add cryptographically secure PRF Jason A. Donenfeld
2016-12-16 21:15 ` Hannes Frederic Sowa

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.