Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6062077imm; Wed, 12 Sep 2018 15:58:40 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYDL7O3JIDKKhakMeqEBAUJu+ADv85ASjBtMlqwj/Zx2MJEvGstFWB8jLGRr5gvcUXu4PMv X-Received: by 2002:a17:902:4081:: with SMTP id c1-v6mr4453192pld.169.1536793120005; Wed, 12 Sep 2018 15:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536793119; cv=none; d=google.com; s=arc-20160816; b=Sp4OCSXRtWHykf9bNpgorsp9xdU2PhgBPHzzCODKWGDC2EPvLh4eulKK4DYvf0yzdY y0NfBk1taRRTVsdOmREBxW/QFr2w4YJqOIgfP94OMh7T4G65hWtglkFVLE9Y5FljRGb+ lIZ0+zapz+aKyN7fE8OXQU9CRaHtbTM0rL9HG8+l564qs+utMQ9JqMr+1SQE1JJpYTZ1 vGu0vek1i0w74a05+fd23X6KhxOIjnJ6cO2B6Qg0dopf+vruEqxu1SHkQBdbNmW2AnAN 3AzoKJG/x9sNg4GOxWoVFunHp6NUpayMZztqjVtGqczlkWCAZ0/PeqPEWUUtyEXBoPh3 lgig== 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=EgZcEbg59QVjWNxoyROPDrTgEyRAiE/Lf/mQjux6twI=; b=JtevGLmLI7YAO2pFfhgXzx/XsF4j4zSdK67EYhrNxFGZdUl5DFUCsCOTtgf8sFiIH6 lzdx3/RjRKtx+Lj0JvPLQDM3BweJOMCCLlPH7bZr9+Qo4LAha5xIvNQl0ljsAW5rO6xZ o6oV7ljvVn84icBOVHsKDKMgo7kU96wOYi5fMBIj4x2hRE/843qAiUpXVw4C83y06ePn vbPT1MyPbVqxFSA6Ep+dIcdPkpcFiCtIrvhvKPmOTCmEvzzo1su9Y9rEtD6U20GAQ9wb uvvQS3KF+/Gn09/kmZS3U6oSi1P5EL4cXDEklYqLDX2cz3ZM9OGe+SbCstjl/WWz/eKV aneQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jDk7jQWH; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v1-v6si2276127pfc.23.2018.09.12.15.58.25; Wed, 12 Sep 2018 15:58:39 -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=@linaro.org header.s=google header.b=jDk7jQWH; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728308AbeIMEDk (ORCPT + 99 others); Thu, 13 Sep 2018 00:03:40 -0400 Received: from mail-io1-f50.google.com ([209.85.166.50]:45484 "EHLO mail-io1-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725751AbeIMEDe (ORCPT ); Thu, 13 Sep 2018 00:03:34 -0400 Received: by mail-io1-f50.google.com with SMTP id e12-v6so1594409iok.12 for ; Wed, 12 Sep 2018 15:56:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=EgZcEbg59QVjWNxoyROPDrTgEyRAiE/Lf/mQjux6twI=; b=jDk7jQWHq645EknXsspyOA3LfqfE0N1Ka7FnvwHlZw8KbCsACuJ0O8cg7tvhg068d3 bRY+Slu5HqbVmXLrcHyc8eepohDPT8pr1mBrR7ZEQan+lfE7FEflq5TyCfD0m5+0KBRH ejSwS0dDgFJYvTeaOnavDN/CUZSYXMCFSv3HE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=EgZcEbg59QVjWNxoyROPDrTgEyRAiE/Lf/mQjux6twI=; b=dzZ0ppBSjpzyEET3Er9klIApk1flFTWZDla8CDaXKvTaNoEAtoZUo/OB6jt7XaX6xO amkdFKhbpn9DURt37NhnmHxWwbt9MLbVoP8k6AXVw4YWLoDzzwnao5sNhGkEtOfrkDyC TAD6u2+bktGOBnS/3uH/D92TczH+ax3p8oywO4Draz0W2G6agmwlg7u+1t+VyXZkDZQr a39BVynMAYctR1nvdITVhNQ4Bnqly6mvMl/nLtXyAu6bQxuMsoVhkgMfEjPBfiZo5uNY w1NeMV0U0T3P4k5g1hKTFVYjrVlMXkJ6ppvoIU5CKZgilVfWA1/xLe+Eup2RsE7Sxhqx k2xQ== X-Gm-Message-State: APzg51DnTyp8EMtCUdTaKDvKStMkK6lxCef2mmxLm8Ic8us5nB4/Sjze OTQvQw3o5hVnF3MRfD38hFT2l7mkeahe8AHJXQoBEQ== X-Received: by 2002:a6b:4516:: with SMTP id s22-v6mr4122058ioa.60.1536793014199; Wed, 12 Sep 2018 15:56:54 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:2848:0:0:0:0:0 with HTTP; Wed, 12 Sep 2018 15:56:53 -0700 (PDT) In-Reply-To: References: <20180911010838.8818-1-Jason@zx2c4.com> <20180911010838.8818-3-Jason@zx2c4.com> From: Ard Biesheuvel Date: Thu, 13 Sep 2018 00:56:53 +0200 Message-ID: Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library To: "Jason A. Donenfeld" Cc: 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 11 September 2018 at 23:22, Jason A. Donenfeld wrote: > Hello Ard, > > I realize you've put a lot of good and hard work into the existing > crypto API, and that my writing in these commit messages might be a > bit too bristly and dismissive of that hard work. So I think in a > sense it's understandable that you've responded as such here. But > hopefully I can address your concerns. One thing to keep in mind is > that Zinc endeavors to provide the basis for simple and direct > functions to software algorithms. This is fairly modest goal. Just > some functions that do some stuff in software. Around these you'll > still be able to have complicated and impressive dynamic dispatch and > asynchronous mechanisms such as the present crypto API. Zinc is merely > getting the software implementation side done in a very simple and > direct way. So I don't think there's a good reason for so much > antagonism, despite a perhaps overbearing tone of my commit messages. > Rather, I expect that we'll wind up working together on this quite a > bit down the line. > No worries, it takes more than this to piss me off. I do take pride in my work, but I am perfectly aware that I am not a rare talent like Andy Polyakov, which is actually why I have worked extensively with him in the past to get kernel specific changes to the ARM/arm64 NEON code into upstream OpenSSL, so that we could use the upstream code unmodified and benefit from upstream review. [1] [2] In this series, you are dumping a huge volume of unannotated, generated asm into the kernel which has been modified [by you] to [among other things?] adhere to the kernel API (without documenting what the changes are exactly). How does that live up to the promise of better, peer reviewed code? Then there is the performance claim. We know for instance that the OpenSSL ARM NEON code for ChaCha20 is faster on cores that happen to possess a micro-architectural property that ALU instructions are essentially free when they are interleaved with SIMD instructions. But we also know that a) Cortex-A7, which is a relevant target, is not one of those cores, and b) that chip designers are not likely to optimize for that particular usage pattern so relying on it in generic code is unwise in general. 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 sure it is rather simple to port the crypto API implementation of ChaCha20 to use your library. I am more concerned about how your library is going to expand to cover all other software algorithms that we currently use in the kernel. >> In spite of the wall of text, you fail to point out exactly why the >> existing AEAD API in unsuitable, and why fixing it is not an option. > > I thought I had addressed this. Firstly, there's a need for more than > just AEAD, but ignoring that, the AEAD API is a big full API that does > lots of things, makes allocations, parses descriptors, and so forth. > I'm sure this kind of highly-engineered approach will continue to > improve over time in that highly engineered direction. Zinc is doing > something a bit different: it's providing a series of simple functions > for various cryptographic routines. This is a considerably different > goal -- perhaps even a complementary one -- to the AEAD API. > I understand how your crypto library is different from the crypto API. But the question was why WireGuard cannot make use of the crypto APIs AEAD interface. And note that this is an honest question: I know that the crypto API is cumbersome to use in general, but it would be very helpful to understand where exactly the impedance mismatch is between what your code needs and what the crypto API provides. >> I don't think you have >> convinced anyone else yet either. > > Please only speak for yourself and refrain from rhetoric like this, > which is patently false. > Fair enough. You have clearly convinced Greg :-) >> Please refrain from sending a v4 with just a couple of more tweaks on >> top > > Sorry, no, I'm not going to stop working hard on this because you're > wary of a new approach. I will continue to improve the submission > until it is mergable, and I do not intend to stop. > Of course. But please respond to all the concerns, not just the low hanging fruit. I have already mentioned a couple of times that I object to dumping large volumes of generated assembly into the kernel tree without any annotation whatsoever, or any documentation about how the generated code was hand tweaked before submission. You have not responded to that concern yet. > Anyway, it sounds like this whole thing may have ruffled your feathers > a bit. Will you be at Linux Plumbers Conference in November? I'm > planning on attending, and perhaps we could find some time there to > sit down and talk one on one a bit. > That would be good, yes. I will be there. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=e4e7f10bfc4069925e99cc4b428c3434e30b6c3f [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7918ecef073fe80eeb399a37d8d48561864eedf1