Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp853809imm; Thu, 13 Sep 2018 08:43:25 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZdwwDLPV1/v5NYwUouHlW0G5YundY5R0OO53qEjhcdfWqQnUIuylZF4JLc3lElYgsJBmot X-Received: by 2002:a62:1c0a:: with SMTP id c10-v6mr8143282pfc.41.1536853405358; Thu, 13 Sep 2018 08:43:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536853405; cv=none; d=google.com; s=arc-20160816; b=xliSLbec1uEGIIzKow/cpMD8rC8Es7VmUHrKDUQt7pxT0WEWAMO+nRxBgilBZFDCil oxAufJ2CP0yCjiRiL3wqLr+K/QjYZc83Vxd7nwIgt+BWpLEPEkcwSwafc7lbChnbfhR+ s2Q8rvcnfwo745D47UisDJF/AYBgYtF4FtrcksxbcHAnPtephFLgeiIQ1k+FMAHwI1eZ Aw8/RcuU017paKGV5/2tCcKjuZ39CCVriSOxrIjE6zt6vcIrVDSwV6FNgQI85kU5vYKH Aysv8xXP5kdf71LrCHgV3F09KBh4AEIDUMonl/JSrwSwgLSFtY1T7sqsmh4ac+yJuHiT KDow== 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=tEf4SmJ/m3MuEYMCYriasC6mhFVOVmCk2r36nlDLxaU=; b=A13aoKc8+1AxZdGAQFMqK47wUejWQSJesxqZdA3PguzKrgSp+TUSQuUC/Eyg3abAp8 4mvRWIjdr6Oy3U53VpHIzgEakUrro3j1RrPxo3505iCcKGedR/XlYCZebwi35yj9ZuRy KzNM+eZaMeCer5bqI/ksFCyCkHSbpbqhUK8jLD53yJAWpnd+TM9L6vJSwaStDUCYKn5m zO0xr1yU7HNhDrnr0pFSzu12M3uviirov08mRxd9dvlu2SS6Lkr3qe8WaewgxBq/yaQa oZeLlMcRHGofs7zVUlWOHg8AouvNJOKe1zXZ8lM3/4HFBpjQt3uAdsTLf5VyhBpBElZ7 awWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NIyecWJO; 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 x10-v6si4218872pgt.655.2018.09.13.08.43.07; Thu, 13 Sep 2018 08:43:25 -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=NIyecWJO; 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 S1727803AbeIMUxD (ORCPT + 99 others); Thu, 13 Sep 2018 16:53:03 -0400 Received: from mail-io1-f49.google.com ([209.85.166.49]:32818 "EHLO mail-io1-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726763AbeIMUxD (ORCPT ); Thu, 13 Sep 2018 16:53:03 -0400 Received: by mail-io1-f49.google.com with SMTP id r196-v6so3546180iod.0 for ; Thu, 13 Sep 2018 08:42:59 -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=tEf4SmJ/m3MuEYMCYriasC6mhFVOVmCk2r36nlDLxaU=; b=NIyecWJOUT+d7Mju6fhw4dQQBiTP0MmgsLvn0tarMhGnGVcVYojctUyZpvmiE5vl6y o4E6PgOXcmiYg+IRA5jcxUiTLrgo3fysufnH7ACQXpED+tnnE7tMSPUOp1gTskGh9+v9 bXx2R6Sum1pYQlNjtwy1pczPtvHbUT+sleahE= 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=tEf4SmJ/m3MuEYMCYriasC6mhFVOVmCk2r36nlDLxaU=; b=AxnC9HCztUM93oQtg5jlDq7XiGTCGCKrjyfwhORlHACB4Zcu0gf0qyu5C+K1tHxW7o R+5uZqCxmwUSPvYwS0h8KW4syXtPqBP+za/hBvTUQlP5RRWvwu9b9jrP+2y0LY43NRGx 7P33UVzmnDmT8iamx9M6wlfq75XjX3EzGQg47pQEi4E8vAODaNXZowrOZ7xDHnOozDib oJ9plsdt9QpfSqwBmI00guT2ziXqrmjHgU7IiRc5l28+cTZIkAEQaqs2LhhyjwURPTV8 dy2Wi82yl7mVRuCueXW7dgSmoYDiolFf6Xh1jbdQxxi6Ubhdn3AmcOAD4MvnsynpIXBe InSA== X-Gm-Message-State: APzg51CYenKmvXPcYX+AGSgfMx0g91HO25xqF8s1gxvGOMDqoW/hQyeb dtXi3s/wn9Vb2bfqVmzp8ZzixzofvTD7WkgSPUHpEQ== X-Received: by 2002:a6b:4516:: with SMTP id s22-v6mr6952867ioa.60.1536853379126; Thu, 13 Sep 2018 08:42:59 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a6b:2848:0:0:0:0:0 with HTTP; Thu, 13 Sep 2018 08:42:58 -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 17:42:58 +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 16:32, Jason A. Donenfeld wrote: > On Thu, Sep 13, 2018 at 7:41 AM Ard Biesheuvel > wrote: >> But one of the supposed selling points of this crypto library is that >> it gives engineers who are frightened of crypto in general and the >> crypto API in particular simple and easy to use crypto primitives >> rather than having to jump through the crypto API's hoops. > > The goal is for engineers who want to specifically use algorithm X > from within the kernel in a non-dynamic way to be able to then use > algorithm X with a simple function call. The goal is not to open it up > to people who have no idea what they're doing; for that a NaCL-like > library with functions like "crypto_box_open" or something would fit > the bill; but that's also not what we're trying to do here. Please > don't confuse the design goals. The rest of your email is therefore a > bit of a straw man; cut the rhetoric out. > >> A crypto library whose only encryption algorithm is a stream cipher >> does *not* deliver on that promise, since it is only suitable for >> cases where IVs are guaranteed not to be reused. > > False. We also offer XChaCha20Poly1305, which takes a massive nonce, > suitable for random generation. > > If there became a useful case for AES-PMAC-SIV or even AES-GCM or > something to that extent, then Zinc would add that as required. But > we're not going to start adding random ciphers unless they're needed. > 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, simply because of the maintenance scope for arch developers and maintainers. 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. On arch/arm64 we support code patching, on other arches it may be different. We also support udev loading of modules depending on CPU capabilities, which means only the implementation you are likely to use will be loaded, and other modules are disregarded. I am not asking you to implement this now. But I do want to understand how these use cases fit into Zinc. And note that this has nothing to do with the crypto API: this could simply be a synchronous aes_gcm_encrypt() library function that maps to any of the above at runtime depending on the platform's capabilities. >> You yourself were >> bitten by the clunkiness of the crypto API when attempting to use the >> SHA26 code, right? So shouldn't we move that into this crypto library >> as well? > > As stated in the initial commit, and in numerous other emails > stretching back a year, yes, sha256 and other things in lib/ are going > to be put into Zinc following the initial merge of Zinc. These changes > will happen incrementally, like everything else that happens in the > kernel. Sha256, in particular, is probably the first thing I'll port > post-merge. > Excellent. >> I think it is reasonable for WireGuard to standardize on >> ChaCha20/Poly1305 only, although I have my concerns about the flag day >> that will be required if this 'one true cipher' ever does turn out to >> be compromised (either that, or we will have to go back in time and >> add some kind of protocol versioning to existing deployments of >> WireGuard) > > Those concerns are not valid and have already been addressed (to you, > I believe) on this mailing list and elsewhere. WireGuard is versioned, > hence there's no need to "add" versioning, and it is prepared to roll > out new cryptography in a subsequent version should there be any > issues. In other words, your concern is based on a misunderstanding of > the protocol. If you have issues, however, with the design decisions > of WireGuard, something that's been heavily discussed with members of > the linux kernel community, networking community, cryptography > community, and so forth, for the last 3 years, I invite you to bring > them up on . > I'd prefer to have the discussion here, if you don't mind. IIUC clients and servers need to run the same version of the protocol. So does it require a flag day to switch the world over to the new version when the old one is deprecated? >> And frankly, if the code were as good as the prose, we wouldn't be >> having this discussion. > > Please cut out this rhetoric. That's an obviously unprovable > statement, but it probably isn't true anyway. I wish you'd stick to > technical concerns only, rather than what appears to be a desire to > derail this by any means necessary. > I apologize if I hit a nerve there, that was not my intention. I am not an 'entrenched crypto API guy that is out to get you'. I am a core ARM developer that takes an interest in crypto, shares your concern about the usability of the crypto API, and tries to ensure that what we end up is maintainable and usable for everybody. >> Zinc adds its own clunky ways to mix arch and >> generic code, involving GCC -include command line arguments and >> #ifdefs everywhere. My review comments on this were completely ignored >> by Jason. > > No, they were not ignored. v2 cleaned up the #ifdefs. v4 has already > cleaned up the makefile stuff and will be even cleaner. Good things > await, don't worry. > 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.