From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ard Biesheuvel Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library Date: Thu, 13 Sep 2018 17:07:08 +0200 Message-ID: References: <20180911010838.8818-1-Jason@zx2c4.com> <20180911010838.8818-3-Jason@zx2c4.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Andrew Lutomirski , LKML , Netdev , David Miller , Greg Kroah-Hartman , Samuel Neves , Jean-Philippe Aumasson , Linux Crypto Mailing List To: "Jason A. Donenfeld" Return-path: Received: from mail-it0-f67.google.com ([209.85.214.67]:37956 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728054AbeIMURF (ORCPT ); Thu, 13 Sep 2018 16:17:05 -0400 Received: by mail-it0-f67.google.com with SMTP id p129-v6so8164849ite.3 for ; Thu, 13 Sep 2018 08:07:10 -0700 (PDT) In-Reply-To: Sender: netdev-owner@vger.kernel.org List-ID: On 13 September 2018 at 16:18, Jason A. Donenfeld wrote: > On Thu, Sep 13, 2018 at 1:45 AM Andy Lutomirski wrote: >> I'm not convinced that there's any real need for *all* crypto >> algorithms to move into lib/zinc or to move at all. As I see it, >> there are two classes of crypto algorithms in the kernel: >> >> a) Crypto that is used by code that chooses its algorithm statically >> and wants synchronous operations. These include everything in >> drivers/char/random.c, but also a bunch of various networking things >> that are hardcoded and basically everything that uses stack buffers. >> (This means it includes all the code that I broke when I did >> VMAP_STACK. Sign.) > > Right, exactly. This is what will wind up using Zinc. I'm working on > an example usage of this for v4 of the patch submission, which you can > ogle in a preview here if you're curious: > > https://git.zx2c4.com/linux-dev/commit/?h=big_key_rewrite > > 28 insertions, 206 deletions :-D > I must say, that actually looks pretty good. >> b) Crypto that is used dynamically. This includes dm-crypt >> (aes-xts-plain64, aes-cbc-essiv, etc), all the ALG_IF interfaces, a >> lot of IPSEC stuff, possibly KCM, and probably many more. These will >> get comparatively little benefit from being converted to a zinc-like >> interface. For some of these cases, it wouldn't make any sense at all >> to convert them. Certainly the ones that do async hardware crypto >> using DMA engines will never look at all like zinc, even under the >> hood. > > Right, this is what the crypto API will continue to be used for. > > >> I think that, as a short-term goal, it makes a lot of sense to have >> implementations of the crypto that *new* kernel code (like Wireguard) >> wants to use in style (a) that live in /lib, and it obviously makes >> sense to consolidate their implementations with the crypto/ >> implementations in a timely manner. As a medium-term goal, adding >> more algorithms as needed for things that could use the simpler APIs >> (Bluetooth, perhaps) would make sense. > > Agreed 100%. With regards to "consolidate their implementations" -- > I've actually already done this after your urging yesterday, and so > that will be a part of v4. > >> But I see no reason at all that /lib should ever contain a grab-bag of >> crypto implementations just for the heck of it. They should have real >> in-kernel users IMO. And this means that there will probably always >> be some crypto implementations in crypto/ for things like aes-xts. > > Right, precisely. > > Jason