linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ard Biesheuvel <ard.biesheuvel@linaro.org>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: Andrew Lutomirski <luto@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Netdev <netdev@vger.kernel.org>,
	David Miller <davem@davemloft.net>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Samuel Neves <sneves@dei.uc.pt>,
	Jean-Philippe Aumasson <jeanphilippe.aumasson@gmail.com>,
	Linux Crypto Mailing List <linux-crypto@vger.kernel.org>
Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library
Date: Thu, 13 Sep 2018 17:42:58 +0200	[thread overview]
Message-ID: <CAKv+Gu9GVbSETjp01tANMwJgA6O9aexhnH+47836KjZg+71q2A@mail.gmail.com> (raw)
In-Reply-To: <CAHmME9pcODNc2m26DH1cQY6R+grxYW5dvFpNDpz_GiugM3qufw@mail.gmail.com>

On 13 September 2018 at 16:32, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> On Thu, Sep 13, 2018 at 7:41 AM Ard Biesheuvel
> <ard.biesheuvel@linaro.org> wrote:
>> But one of the supposed selling points of this crypto library is that
>> it gives engineers who are frightened of crypto in general and the
>> crypto API in particular simple and easy to use crypto primitives
>> rather than having to jump through the crypto API's hoops.
>
> The goal is for engineers who want to specifically use algorithm X
> from within the kernel in a non-dynamic way to be able to then use
> algorithm X with a simple function call. The goal is not to open it up
> to people who have no idea what they're doing; for that a NaCL-like
> library with functions like "crypto_box_open" or something would fit
> the bill; but that's also not what we're trying to do here. Please
> don't confuse the design goals. The rest of your email is therefore a
> bit of a straw man; cut the rhetoric out.
>
>> A crypto library whose only encryption algorithm is a stream cipher
>> does *not* deliver on that promise, since it is only suitable for
>> cases where IVs are guaranteed not to be reused.
>
> False. We also offer XChaCha20Poly1305, which takes a massive nonce,
> suitable for random generation.
>
> If there became a useful case for AES-PMAC-SIV or even AES-GCM or
> something to that extent, then Zinc would add that as required. But
> we're not going to start adding random ciphers unless they're needed.
>

I'd prefer it if all the accelerated software implementations live in
the same place. But I do strongly prefer arch code to live in
arch/$arch, simply because of the maintenance scope for arch
developers and maintainers.

I think AES-GCM is a useful example here. I really like the SIMD token
abstraction a lot, but I would like to understand how this would work
in Zinc if you have
a) a generic implementation
b) perhaps an arch specific scalar implementation
c) a pure NEON implementation
d) an implementation using AES instructions but not the PMULL instructions
e) an implementation that uses AES and PMULL instructions.

On arch/arm64 we support code patching, on other arches it may be
different. We also support udev loading of modules depending on CPU
capabilities, which means only the implementation you are likely to
use will be loaded, and other modules are disregarded.

I am not asking you to implement this now. But I do want to understand
how these use cases fit into Zinc. And note that this has nothing to
do with the crypto API: this could simply be a synchronous
aes_gcm_encrypt() library function that maps to any of the above at
runtime depending on the platform's capabilities.

>> You yourself were
>> bitten by the clunkiness of the crypto API when attempting to use the
>> SHA26 code, right? So shouldn't we move that into this crypto library
>> as well?
>
> As stated in the initial commit, and in numerous other emails
> stretching back a year, yes, sha256 and other things in lib/ are going
> to be put into Zinc following the initial merge of Zinc. These changes
> will happen incrementally, like everything else that happens in the
> kernel. Sha256, in particular, is probably the first thing I'll port
> post-merge.
>

Excellent.

>> I think it is reasonable for WireGuard to standardize on
>> ChaCha20/Poly1305 only, although I have my concerns about the flag day
>> that will be required if this 'one true cipher' ever does turn out to
>> be compromised (either that, or we will have to go back in time and
>> add some kind of protocol versioning to existing deployments of
>> WireGuard)
>
> Those concerns are not valid and have already been addressed (to you,
> I believe) on this mailing list and elsewhere. WireGuard is versioned,
> hence there's no need to "add" versioning, and it is prepared to roll
> out new cryptography in a subsequent version should there be any
> issues. In other words, your concern is based on a misunderstanding of
> the protocol. If you have issues, however, with the design decisions
> of WireGuard, something that's been heavily discussed with members of
> the linux kernel community, networking community, cryptography
> community, and so forth, for the last 3 years, I invite you to bring
> them up on <wireguard@lists.zx2c4.com>.
>

I'd prefer to have the discussion here, if you don't mind.

IIUC clients and servers need to run the same version of the protocol.
So does it require a flag day to switch the world over to the new
version when the old one is deprecated?

>> And frankly, if the code were as good as the prose, we wouldn't be
>> having this discussion.
>
> Please cut out this rhetoric. That's an obviously unprovable
> statement, but it probably isn't true anyway. I wish you'd stick to
> technical concerns only, rather than what appears to be a desire to
> derail this by any means necessary.
>

I apologize if I hit a nerve there, that was not my intention.

I am not an 'entrenched crypto API guy that is out to get you'. I am a
core ARM developer that takes an interest in crypto, shares your
concern about the usability of the crypto API, and tries to ensure
that what we end up is maintainable and usable for everybody.

>> Zinc adds its own clunky ways to mix arch and
>> generic code, involving GCC -include command line arguments and
>> #ifdefs everywhere. My review comments on this were completely ignored
>> by Jason.
>
> No, they were not ignored. v2 cleaned up the #ifdefs. v4 has already
> cleaned up the makefile stuff and will be even cleaner. Good things
> await, don't worry.
>

You know what? If you're up for it, let's not wait until Plumbers, but
instead, let's collaborate off list to get this into shape.

  reply	other threads:[~2018-09-13 17:35 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-11  1:08 [PATCH net-next v3 00/17] WireGuard: Secure Network Tunnel Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 01/17] asm: simd context helper API Jason A. Donenfeld
2018-09-12  6:14   ` Kevin Easton
2018-09-12 18:10     ` Jason A. Donenfeld
2018-09-13  5:03       ` Kevin Easton
2018-09-13 13:52         ` Jason A. Donenfeld
2018-09-13 13:53           ` Jason A. Donenfeld
2018-09-15 19:58           ` Andy Lutomirski
2018-09-15 20:01             ` Jason A. Donenfeld
2018-09-17 13:14         ` Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library Jason A. Donenfeld
2018-09-11 10:08   ` Ard Biesheuvel
2018-09-11 14:56     ` Greg Kroah-Hartman
2018-09-11 21:47       ` Eric Biggers
2018-09-11 22:02         ` Jason A. Donenfeld
2018-09-11 23:30           ` Andrew Lunn
2018-09-11 23:57             ` David Miller
2018-09-12  0:02               ` Jason A. Donenfeld
2018-09-17  4:09               ` Andy Lutomirski
2018-09-17  4:45                 ` David Miller
2018-09-17 14:55                   ` Andy Lutomirski
2018-09-17 14:59                     ` Jason A. Donenfeld
2018-09-17  5:07                 ` Jason A. Donenfeld
2018-09-17 14:53                   ` Andy Lutomirski
2018-09-17 14:59                     ` Jason A. Donenfeld
2018-09-17 16:24                     ` Jason A. Donenfeld
2018-09-18 16:06                     ` Ard Biesheuvel
2018-09-18 16:45                       ` Jason A. Donenfeld
2018-09-17  5:26                 ` Ard Biesheuvel
2018-09-17 14:51                   ` Andy Lutomirski
2018-09-17 15:28                     ` Jason A. Donenfeld
2018-09-17 16:06                       ` Andy Lutomirski
2018-09-17 16:17                         ` Jason A. Donenfeld
2018-09-17 15:31                     ` Jason A. Donenfeld
2018-09-17 16:07                       ` Andy Lutomirski
2018-09-17 16:16                         ` Jason A. Donenfeld
2018-09-17 16:18                           ` Andy Lutomirski
2018-09-18  0:56                             ` Jason A. Donenfeld
2018-09-17 15:52                   ` Jason A. Donenfeld
2018-09-18  4:21                     ` Herbert Xu
2018-09-18  4:26                       ` Jason A. Donenfeld
2018-09-18 18:53                     ` Ard Biesheuvel
2018-09-18 20:36                       ` Jason A. Donenfeld
2018-09-19 16:55                         ` Ard Biesheuvel
2018-09-11 22:16         ` Andy Lutomirski
2018-09-11 22:18           ` Jason A. Donenfeld
2018-09-11 23:01             ` Andy Lutomirski
2018-09-12  0:01               ` Jason A. Donenfeld
2018-09-12  4:29                 ` Jason A. Donenfeld
2018-09-11 21:22     ` Jason A. Donenfeld
2018-09-12 22:56       ` Ard Biesheuvel
2018-09-12 23:45         ` Andy Lutomirski
2018-09-13  5:41           ` Ard Biesheuvel
2018-09-13 14:32             ` Jason A. Donenfeld
2018-09-13 15:42               ` Ard Biesheuvel [this message]
2018-09-13 15:58                 ` Jason A. Donenfeld
2018-09-14  6:15                   ` Ard Biesheuvel
2018-09-14  9:53                     ` Jason A. Donenfeld
2018-09-13  6:39           ` Milan Broz
2018-09-13 14:34             ` Jason A. Donenfeld
2018-09-13 15:26             ` Andy Lutomirski
2018-09-13 14:18           ` Jason A. Donenfeld
2018-09-13 15:07             ` Ard Biesheuvel
2018-09-13 14:15         ` Jason A. Donenfeld
2018-09-13 15:04           ` Ard Biesheuvel
2018-09-13 15:45             ` Jason A. Donenfeld
2018-09-11 22:08     ` Eric Biggers
2018-09-12 18:16       ` Jason A. Donenfeld
2018-09-12 18:19         ` Ard Biesheuvel
2018-09-12 18:34           ` Eric Biggers
2018-09-14  6:21             ` Ard Biesheuvel
2018-09-11  1:08 ` [PATCH net-next v3 03/17] zinc: ChaCha20 generic C implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 04/17] zinc: ChaCha20 ARM and ARM64 implementations Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 05/17] zinc: ChaCha20 x86_64 implementation Jason A. Donenfeld
2018-09-11  8:22   ` Thomas Gleixner
2018-09-11  9:00     ` Samuel Neves
2018-09-11  9:09       ` Thomas Gleixner
2018-09-11 21:12         ` Jason A. Donenfeld
2018-09-11 21:27           ` Thomas Gleixner
2018-09-11 21:28             ` Jason A. Donenfeld
2018-09-11 21:48           ` Eric Biggers
2018-09-11 22:04             ` Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 06/17] zinc: ChaCha20 MIPS32r2 implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 07/17] zinc: Poly1305 generic C implementation and selftest Jason A. Donenfeld
2018-09-11  1:17   ` Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 07/17] zinc: Poly1305 generic C implementations " Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 08/17] zinc: Poly1305 ARM and ARM64 implementations Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 09/17] zinc: Poly1305 x86_64 implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 10/17] zinc: Poly1305 MIPS32r2 and MIPS64 implementations Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 11/17] zinc: ChaCha20Poly1305 construction and selftest Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 12/17] zinc: BLAKE2s generic C implementation " Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 13/17] zinc: BLAKE2s x86_64 implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 14/17] zinc: Curve25519 generic C implementations and selftest Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 15/17] zinc: Curve25519 ARM implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 16/17] zinc: Curve25519 x86_64 implementation Jason A. Donenfeld
2018-09-11  1:08 ` [PATCH net-next v3 17/17] net: WireGuard secure network tunnel Jason A. Donenfeld
2018-09-11 12:59   ` kbuild test robot
2018-09-11 20:53     ` Jason A. Donenfeld
2018-09-11 13:17   ` kbuild test robot
2018-09-11 21:05     ` Jason A. Donenfeld
2018-09-11 13:30   ` Andrew Lunn
2018-09-11 21:08     ` Jason A. Donenfeld
2018-09-11 21:55       ` Andrew Lunn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKv+Gu9GVbSETjp01tANMwJgA6O9aexhnH+47836KjZg+71q2A@mail.gmail.com \
    --to=ard.biesheuvel@linaro.org \
    --cc=Jason@zx2c4.com \
    --cc=davem@davemloft.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jeanphilippe.aumasson@gmail.com \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luto@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=sneves@dei.uc.pt \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).