Received: by 2002:ac0:adb2:0:0:0:0:0 with SMTP id o47-v6csp7519imb; Wed, 12 Sep 2018 16:45:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdbB1M/LQ+vfgCKlwdeyzNeC9mF0jKpr1AS8QTzF+IsYaXkZzz5Km8zV2F1f6KEnv6rzTCAk X-Received: by 2002:a17:902:6bc8:: with SMTP id m8-v6mr4645593plt.162.1536795957211; Wed, 12 Sep 2018 16:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536795957; cv=none; d=google.com; s=arc-20160816; b=MumnBicGq0tzIJeA01qjc/lNpn5Ln5Dyg8wZ7axdW0I2tUf5CFyK8qQewSXMBX4Iol uYXuGp1jIhd6OjuDxAfVH28lrUOVEsrADMOuEp/LyEoJ5WZYemBNU6LCNNMPsKyCh844 P7MswEdT/ermCpID68xYJgj6HXwyKh4BJjgx2ez3waz0V1GcEhKweu3+DhLm7fBOYnSP yMRFzUuJzbzCwZ1yNaE/6QgTnEgbBDej3MQpLDIUlejINyc1GSwY11BF89N3Ys5zwA8J eohBxrLozK4lum7RwlpFtW/lIl8u5o1CbR4bHh4YoQ3CJqgaoX5/5Tg8sgPWjnyTIToW 5t7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature; bh=JmScO6XVO286WjW/xFidOnv1605NAeMdZs+ZbF+aIzU=; b=dkWEMhwmvG/C+MjvBF2oElq8TyAaY4vBsiAjdh9qoV//GAfMi4/bDl15hNOILk2lqb cXI+nsffr5+Zz4A6xHBEKWb61Tq715X4HxsicK0NJwZO1ROJ5AbYu/TTRDQWo4AiqHl3 16z5ylwjWh4sovSXlfv1kPnduVNmmPaTiqAU6CEiEVLvZrs49srUkrHRRV+vhbITfFD6 MwptwJsapJHD0TaCfL7eMljj12fC/EGwlot3xH1eH6ikjbd3OkjVCXmqIBMI0KLOWP6+ ac9Nb6WLMUJYNQgTOWjaHeQ+jbtFwxRmLEmUA8QfzVW0Uw/9O6iUP4ST2VqEPgY54Ttd Nmcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0SHDYbWi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a20-v6si2181757pgv.85.2018.09.12.16.45.41; Wed, 12 Sep 2018 16:45:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=0SHDYbWi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726542AbeIMEwW (ORCPT + 99 others); Thu, 13 Sep 2018 00:52:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:36248 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726080AbeIMEwW (ORCPT ); Thu, 13 Sep 2018 00:52:22 -0400 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF0CA2146E for ; Wed, 12 Sep 2018 23:45:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1536795933; bh=Czl782qIU6oXU+hLju+22NmAWbzVC0QdQXchewUZA3Q=; h=In-Reply-To:References:From:Date:Subject:To:Cc:From; b=0SHDYbWi3N9o5Uqfw2rG4fSutT46EKxYdGtceA+RQeFJjm7E3K/1Q9kl+sUmOpvIQ HVTFaEgp08yDzxgBuSk/w0xcMd7YcI1JoPO+O2jfnt42evNITLeKkIimh31gyqJbTM v1hKaCVtuA/g0Oe9QTTrDtxwRXv4siAOu9fGR1aE= Received: by mail-wr1-f51.google.com with SMTP id 20-v6so3711500wrb.12 for ; Wed, 12 Sep 2018 16:45:32 -0700 (PDT) X-Gm-Message-State: APzg51DdWJ/Vn988qGuQOx5tiC4z99aunZWwRqth89uFBorpL18WsnsV b+lwcCyboRsixCJ+5P/s6tRxM/RykFJ6cINtGmvtIg== X-Received: by 2002:adf:dcc1:: with SMTP id x1-v6mr3311842wrm.21.1536795931083; Wed, 12 Sep 2018 16:45:31 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a1c:7810:0:0:0:0:0 with HTTP; Wed, 12 Sep 2018 16:45:10 -0700 (PDT) In-Reply-To: References: <20180911010838.8818-1-Jason@zx2c4.com> <20180911010838.8818-3-Jason@zx2c4.com> From: Andy Lutomirski Date: Wed, 12 Sep 2018 16:45:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library To: Ard Biesheuvel Cc: "Jason A. Donenfeld" , LKML , Netdev , David Miller , Greg Kroah-Hartman , Andrew Lutomirski , Samuel Neves , Jean-Philippe Aumasson , Linux Crypto Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 12, 2018 at 3:56 PM, Ard Biesheuvel wrote: > I realize you've put a lot of good and hard work into the existing > I am also concerned about your claim that all software algorithms will > be moved into this crypto library. You are not specific about whose > responsibility it will be that this is going to happen in a timely > fashion. But more importantly, it is not clear at all how you expect > this to work for, e.g., h/w instruction based SHAxxx or AES in various > chaining modes, which should be used only on cores that implement > those instructions (note that on arm64, we have optional instructions > for AES, PMULL, SHA1, SHA256, SHA512, SHA3, SM3 and SM4). Are all > those implementations (only few of which will be used on a certain > core) going to be part of the monolithic library? What are the APIs > going to look like for block ciphers, taking chaining modes into > account? 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.) 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. 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. 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. --Andy