Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp379749imm; Thu, 13 Sep 2018 23:15:49 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZg4YulnF7w4aBTMqYgKuYAfTIZEzQfLkCZjiEU+ojSiVeErrPCR0Kkb4G+PlY5TjcYDZt2 X-Received: by 2002:a63:ed07:: with SMTP id d7-v6mr10267085pgi.429.1536905749213; Thu, 13 Sep 2018 23:15:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536905749; cv=none; d=google.com; s=arc-20160816; b=q76VTJzZQlmVGOYNfMNiObAKYM8BErJEOCpTLbsKb/Koj2G+TwvpNI+n6EKIHQqv0f otsBusqH3e7Mk5HVq1ZXB23y2Varln8cp2wYzGbBAeac4oMBFMMwcy+60aocwgceg99z sGaUqcA/A/lYfY+0mR7mcgf39p8mo0N6HEj4cQXSJVc3a2h4yfWPDlb5URyv6NNtO4Wy eHE/4TvTTLvTSwhC5kQgvH4ybNKnLeiBr4EtAzF3kDgy5Nlu8+ioEJN9Ik0vllUqC3YD kh7RLlfZZ2LWcMRMCeb3WIUsN6f9aXBDPxC65MdfLK2W/Ff+DhW6WPFXQoPvjQlAd1sC yQGw== 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=HSl75cAlxsdEKK1NOhLd3+rcWGnC7SHutCiO/fuC4B8=; b=N4Ht4TwC5xC0vATNgbySa4x1q10/O1xFXlcMKBdh9Z74rnYI1O0cNmQ3t33vFVOB1b JImtfkDRHHP0H+7KqNRHyuV1/6+9oULNShxDt0DRBaRw6QmslS2vla/LkH/UkIfnJciu 4+IGvWq6uL9WTk/TyYFDLwlpFBZ459BmZzHV8eQAj4C0R4T8hZH721QPm+aqeekg4/Nx ogTSUpyFRl8zlJV6hxCXt0SEeg5G2EgIetBcfeA0Iiu8IUtBMdF1jpV6oidM6UJ0PBaO S2KyTDBhru6znzWfiZI6WHkneH0lCKqn5Dl/DaMamP0kZGa+L1Nx+0loypgR6rP0Hs3X 22hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gs7HqqLE; 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 b61-v6si6696350plc.499.2018.09.13.23.15.33; Thu, 13 Sep 2018 23:15:49 -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=Gs7HqqLE; 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 S1727065AbeINL2W (ORCPT + 99 others); Fri, 14 Sep 2018 07:28:22 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:45758 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726955AbeINL2V (ORCPT ); Fri, 14 Sep 2018 07:28:21 -0400 Received: by mail-io1-f68.google.com with SMTP id e12-v6so5099585iok.12 for ; Thu, 13 Sep 2018 23:15:25 -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=HSl75cAlxsdEKK1NOhLd3+rcWGnC7SHutCiO/fuC4B8=; b=Gs7HqqLEzbQjhmrVodpsIHWgrL2+a/moKehA6pslD+fpWMqQ6KcIdnaIWRKXF5mnQN zhb83ezwd8Rq+suOLIpdSFfxg1ieortqYPS5R+Go9mrcoyGk1lsvl+D/iP6WZTaywxga 90rEwDrptA8s3fhS+1oESjJ8aHX/D8gsD20zA= 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=HSl75cAlxsdEKK1NOhLd3+rcWGnC7SHutCiO/fuC4B8=; b=SDEu3EUCmpBqVWJarLSfW0RDxX5co6L3a2iDmfuGYNXpBvhkYSgAApI2hCxGUeedMW 0r02ewPOWVvydHv+MEp3n8P0N7mbSRo3xK4evD3uiz04jfr+UxYJYcNTNTEPL2ws6Ulv 2iQR/WQ8OraAYDvY9XI/IEG+LflaD/oglYZmcnZqDYVgvzB4ot27PO+0umWWXw4OyraW JvvzbfPRZIFnhSqaOdbdBTnyAw1iaCi4+YUDxJZ8TkyfNLJ8DBJzxg5ndGDILL5/RBM0 yJwGqxV5BZW3++KQSgqWiz5ucmZ5D3xC8jBMq5LipdD172W8/e+qxdzLAoI4s9lCxlib AAog== X-Gm-Message-State: APzg51BLAJ5AZ5SGLUARqUqa54hZgyInCpSbX2IxCi25Ii+/LBMzc+Oj 6xMiKX0WF9dedcVr7JPUy/vqM+hz2lg5gzg8wOtaaA== X-Received: by 2002:a6b:ba86:: with SMTP id k128-v6mr8815094iof.170.1536905725278; Thu, 13 Sep 2018 23:15:25 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:2848:0:0:0:0:0 with HTTP; Thu, 13 Sep 2018 23:15:24 -0700 (PDT) In-Reply-To: References: <20180911010838.8818-1-Jason@zx2c4.com> <20180911010838.8818-3-Jason@zx2c4.com> From: Ard Biesheuvel Date: Fri, 14 Sep 2018 08:15:24 +0200 Message-ID: Subject: Re: [PATCH net-next v3 02/17] zinc: introduce minimal cryptography library To: "Jason A. Donenfeld" Cc: Andrew Lutomirski , LKML , Netdev , David Miller , Greg Kroah-Hartman , 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 13 September 2018 at 17:58, Jason A. Donenfeld wrote: > On Thu, Sep 13, 2018 at 5:43 PM Ard Biesheuvel > wrote: >> 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 > > Zinc follows the scheme of the raid6 code, as well as of most other > crypto libraries: code is grouped by cipher, making it easy for people > to work with and understand differing implementations. It also allows > us to trivially link these together at compile time rather than at > link time, which makes cipher selection much more efficient. It's > really much more maintainable this way. > >> 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. > > The same way that Zinc currently chooses between the five different > implementations for, say, x86_64 ChaCha20: > > - Generic C scalar > - SSSE3 > - AVX2 > - AVX512F > - AVX512VL > > We make a decision based on CPU capabilities, SIMD context, and input > length, and then choose the right function. > OK, so given random.c's future dependency on Zinc (for ChaCha20), and the fact that Zinc is one monolithic piece of code, all versions of all algorithms will always be statically linked into the kernel proper. I'm not sure that is acceptable. >> 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. > > Sure, sounds good. > BTW you haven't answered my question yet about what happens when the WireGuard protocol version changes: will we need a flag day and switch all deployments over at the same time?