Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp762837imu; Tue, 20 Nov 2018 06:37:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/X5mN1pGcz4hF6oQj2f//yguX39dtf4W+H6bSj2DB15fl+LfwRFRiA4tO4rm3nKxXC5q1BA X-Received: by 2002:a65:5387:: with SMTP id x7mr2154144pgq.412.1542724672184; Tue, 20 Nov 2018 06:37:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542724672; cv=none; d=google.com; s=arc-20160816; b=htF9C1XFkBWhI+qwTgn/VqtK1AIIO4+t0wyUgImrxw2hAvVZWrcxTNF/RTKk0olkNt l8WAHQm5hfWIrLGr6c+bq47laev1ajnYGCAfm2xPGs2NIhoD2Sm8v8os8oAbpAIr9/nR NXT859vX5xw+V7rzhzxsZ6nFGrFopHNEfjUB5kCLwR9L3mp65fsabb+roq3znvy04FcP 9+yCiZPQHC/ekgSbCkA2r26M0SDVqNz8b3gu+CPUmpbUptiEsPq2aE7W/6DBwfm3ubT0 vprgGgxk89Xyuoqy0cMHA1lfZ/nZSRu4sbg8ujonHtCH938SYiRwXr1x/OT2GMg/o5Ih FKZA== 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 :in-reply-to:references:mime-version:dkim-signature; bh=w+21HGHswGnYjENYIqGn/kvXK0Nsz+J5eHz7rf19uQA=; b=v6R5PGFqmZjy+Fo/0H5bK8oV8ACSx66Tc+GGrA5Pkcr5RYH5D1/f6+gBccS9kabvXU 1+UwJezKE3aRI56BwzfF9JhTH/CZer3i4TGNiQ6V+ragKDD20zXXsyyVuq6BrPer5Ql9 /505h84TwUOWK/yYtLIsLZNy/GO9lxSHzl8msUa1dDQe8bv2zV3E25NW0ym6EnOofYv1 vcoZMSlRCx4JWOuhlcSXPrRNFmSnAh/oOoV85GnZgTKKVYJfK1b+SJDkeakdr/Np2LXx lzDvgYlxYq4u0QP6t2nY8UQN1BIzndmSe8dfCWnvZg/+EowAs3Ijm7Lsn4Q4qGyqgVSn xOvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=N2M2qQBE; 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 d25si31952627pgd.88.2018.11.20.06.37.37; Tue, 20 Nov 2018 06:37:52 -0800 (PST) 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=N2M2qQBE; 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 S1728345AbeKTVAn (ORCPT + 99 others); Tue, 20 Nov 2018 16:00:43 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:44581 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728107AbeKTVAn (ORCPT ); Tue, 20 Nov 2018 16:00:43 -0500 Received: by mail-io1-f65.google.com with SMTP id r200so980138iod.11 for ; Tue, 20 Nov 2018 02:32:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=w+21HGHswGnYjENYIqGn/kvXK0Nsz+J5eHz7rf19uQA=; b=N2M2qQBExH0uZGz9+vw+ZVIivlhVE2O9nTd0SntvyDDXYyQkQkwQR+FppqpL6mAkeK lUzJ2OLAx1tHjHC+B/pdAkopYqBI3M5C0cBw9937Mur3nvOipWn+8Yr9RYhlKKqGqI/x RZyTlF/wtRP02s3wbbFXPCObptqYox7tX6vqs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=w+21HGHswGnYjENYIqGn/kvXK0Nsz+J5eHz7rf19uQA=; b=dKkFbA6NU/vC0k+lJYiwdlozMZT3H0VVMWIpdmbVrryCUH0kQjCAgXcCOpnqqo8fMX hrJmmdm2REDoqAIhN44EmRIwZpbYrSMzQa8Fiiogpag3u6gibf7+xn64s0tgjWuhbiJk WfCyd3iRdfXuIIV8R0axZEtOJU/IlPvR126B7TbGBX/CvAU/s9rAJHN9nFn4FOz2mKDY vp1VrCpsPLyTvbtl6WDDE3jI/oXdnuxScFAvsfTmOf3Zu76WTNOzD/MQqy6reWUHBEyH EK4Vpj1EaPey82DC7j81jbM+G8NGB3obMzGvIrArdUbGeT8wRDhXxSYaGF34qPaG332d k7dw== X-Gm-Message-State: AA+aEWY7Gsak7EBLOfRiobd9nye7h0smAOn7iSFawe6FY5yB8XiUx7fL jFnrLKVaKKl3OBjZy423wEBHh/wShh3nq01TsmaYUA== X-Received: by 2002:a6b:7a46:: with SMTP id k6mr1175871iop.60.1542709936366; Tue, 20 Nov 2018 02:32:16 -0800 (PST) MIME-Version: 1.0 References: <20181105232526.173947-1-ebiggers@kernel.org> <20181105232526.173947-11-ebiggers@kernel.org> <20181112185816.GA8663@gmail.com> <20181116060227.hwu4igi6bp26ddpi@gondor.apana.org.au> <20181117001718.GA175522@gmail.com> <20181119052451.qttzfgcm4hvbdc4u@gondor.apana.org.au> <20181120060217.t4nccaqpwnxkl4tx@gondor.apana.org.au> In-Reply-To: <20181120060217.t4nccaqpwnxkl4tx@gondor.apana.org.au> From: Ard Biesheuvel Date: Tue, 20 Nov 2018 11:32:05 +0100 Message-ID: Subject: Re: [RFC PATCH v2 0/4] Exporting existing crypto API code through zinc To: Herbert Xu Cc: "Jason A. Donenfeld" , Eric Biggers , "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , linux-fscrypt@vger.kernel.org, linux-arm-kernel , Linux Kernel Mailing List , Paul Crowley , Greg Kaiser , Samuel Neves , Tomer Ashur , Martin Willi 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 Tue, 20 Nov 2018 at 07:02, Herbert Xu wrote: > > On Mon, Nov 19, 2018 at 01:24:51PM +0800, Herbert Xu wrote: > > > > In response to Martin's patch-set which I merged last week, I think > > here is quick way out for the zinc interface. > > > > Going through the past zinc discussions it would appear that > > everybody is quite happy with the zinc interface per se. The > > most contentious areas are in fact the algorithm implementations > > under zinc, as well as the conversion of the crypto API algorithms > > over to using the zinc interface (e.g., you can no longer access > > specific implementations). > > > > My proposal is to merge the zinc interface as is, but to invert > > how we place the algorithm implementations. IOW the implementations > > should stay where they are now, with in the crypto API. However, > > we will provide direct access to them for zinc without going through > > the crypto API. IOW we'll just export the functions directly. > > > > Here is a proof of concept patch to do it for chacha20-generic. > > It basically replaces patch 3 in the October zinc patch series. > > Actually this patch also exports the arm/x86 chacha20 functions > > too so they are ready for use by zinc. > > > > If everyone is happy with this then we can immediately add the > > zinc interface and expose the existing crypto API algorithms > > through it. This would allow wireguard to be merged right away. > > > > In parallel, the discussions over replacing the implementations > > underneath can carry on without stalling the whole project. > > > > PS This patch is totally untested :) > > Here is an updated version demonstrating how we could access the > accelerated versions of chacha20. It also includes a final patch > to deposit the new zinc version of x86-64 chacha20 into > arch/x86/crypto where it can be used by both the crypto API as well > as zinc. > > The key differences between this and the last zinc patch series: > > 1. The crypto API algorithms remain individually accessible, this > is crucial as these algorithm names are exported to user-space so > changing the names to foo-zinc is not going to work. > Are you saying user space may use names like "ctr-aes-neon" directly rather than "ctr(aes)" for any implementation of the mode? If so, that is highly unfortunate, since it means we'd be breaking user space by wrapping a crypto library function with its own arch specific specializations into a generic crypto API wrapper. Note that I think that using AF_ALG to access software crypto routines (as opposed to accelerators) is rather pointless to begin with, but if it permits that today than we're stuck with it. > 2. The arch-specific algorithm code lives in their own module rather > than in a monolithic module. > This is one of the remaining issues I have with Zinc. However, modulo the above concerns, I think it does make sense to have a separate function API for synchronous software routines below the current crypto API. What I don't want is a separate Zinc kingdom with a different name, different maintainers and going through a different tree, and with its own approach to test vectors, arch specific code, etc etc