Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3179875ybi; Thu, 18 Jul 2019 22:35:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi74SQ1588+yvtkHWTcZhzizO35pldHYDEURXhSTZ1iLUl4A8F0myY0Sl1dHiR+Fsd1GK2 X-Received: by 2002:a17:90a:d814:: with SMTP id a20mr55772128pjv.48.1563514515285; Thu, 18 Jul 2019 22:35:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563514515; cv=none; d=google.com; s=arc-20160816; b=zUgeIx79BQmx1eHvYKyYHR3OkGEdrZo3aavjoWNpt/3BOl1Rr7DC3ccEbSkMzMNodM fZkgWdbhQLISuxMREk+3Sgwnumq4DIufU01vObnLenXjuJPQTYD1yZLm6T92tdg1x6YB PW/63LiooGvjceu6YF8GlJgvic1KEagGTpjevVTPLpDMWIC4zEKw1+cmgyycHbJpOZe3 ercFqS/UnjUJZG82f9rBFnSaNb3wq27KvzdT0p0d6dw8Y8B6syJxBQZNig0yJMd0t3lo QB/NWMkhfLT0AbQows6x9gUpvPCLxaTBR864pAvE53uGbbVmUcTmmQTsGZk79OQUzlKO onbA== 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=Iow/hRxvVSUjo+9McFqy4a9hVvzKVnwTDlHSRUZV1h8=; b=zPAOXX3dcQhF1k8tZFsA2KqgyzgF/t9ISsxmSJNuzxbi22CXdz2taaCouAGRWCWpKZ +HJhEsJ0XuHCJSP8W7Uf5tZRH7I3WXoWKW7NAV3vZMOT+cqATdK/fGi5+Xf2SN94+txM bIoq/aEIyabN1pmvEbOA1ZUUnwybFHINPUH+rP4n8V5GitvlK4xAMGsnKVCu0gGcnAPa i5PsF7ANV4dnaxsvamCv0otVcIknzVkbRmpbfV7MW2KFPFLjv2LQyFdXKQv8/OJ45QTI EUoGrFwSd3/PvwWUh/qjE4E8gO8iQBnFtph3jGsHSwt2acVAC3D+ZVM5MyuzUF2o5FoM XQPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=x7yc+G26; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 a15si1406676pgw.246.2019.07.18.22.34.54; Thu, 18 Jul 2019 22:35:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=x7yc+G26; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 S1726402AbfGSFer (ORCPT + 99 others); Fri, 19 Jul 2019 01:34:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:41813 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726147AbfGSFeq (ORCPT ); Fri, 19 Jul 2019 01:34:46 -0400 Received: by mail-wr1-f65.google.com with SMTP id c2so27724710wrm.8 for ; Thu, 18 Jul 2019 22:34:44 -0700 (PDT) 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=Iow/hRxvVSUjo+9McFqy4a9hVvzKVnwTDlHSRUZV1h8=; b=x7yc+G267SAGG4+G1mYrx99EtRd9meF6RmN/qzLyX6h7BW1cMrMG2uA5mCfLoPhRvK tyjNZBh3NRZ30JNiQVjC1dfbmHZs50BYyNcpaBR5Jl/egodlcFOx4lckK0TQKqrewwcI gj5SIZEybkRYNEC1kyAbgq9kQlZ3/ve4ZHq4STBdJuExOlqEXRj7M3XbDv3hUkhrAVKd 9bbZNGP56jOz56RXjlYUPWQId5uYymwK6anBlKHMPZACUu1+fDL/R7S3LboWCql1x8Pg U1XPNQzm2/Kj/nekZmrLPdJ95DSoZGhEAO4/My9cNMdn8BQ+qZEmtHCPI+Bjswi2FQ6a 3G8Q== 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=Iow/hRxvVSUjo+9McFqy4a9hVvzKVnwTDlHSRUZV1h8=; b=nUsZ+vwVlzvInuWJwev04XS1i42CY8OtejZr9d0Yk1tar7Wu46Kch15yjV1BO/ZMI2 mhN8M0D2QW/rLD6mJu91fEZ/EWp4QfRZIQ7r1b7TxRqYTuLJdsyDUDvC+FTqUpraZH+A WjNXtfu6IYIOzTvj23333mKo06OtPPj6tAiHnlrOEQ3eUg5LQwSjbMLK+ARW3VyDTiaK Rdlz9AiZqWvgjhsncQ+tLKAtqJX4WWsp85ItkyptAH7jaI2It0AqS3FOgPZ11Cwspc6n PwbHuflO7Mnp0QlLsISaHnbJ7WmOgOC22hdPaHhBmIONwdgGPlzsbUS7qznmr2sQhWVj mg9g== X-Gm-Message-State: APjAAAXibiBl06a4Xx0mOEMEPjnKTmpQBKuqTNNshG40GHomZFNNhyQz u9mdJFENs49GrRXX+tagoT9uKhT6gC4N98wchx+ByQ== X-Received: by 2002:a5d:428b:: with SMTP id k11mr23152900wrq.174.1563514484209; Thu, 18 Jul 2019 22:34:44 -0700 (PDT) MIME-Version: 1.0 References: <20190717172823.GA205944@gmail.com> <20190718065223.4xaefcwjoxvujntw@gondor.apana.org.au> <20190718072154.m2umem24x4grbf6w@gondor.apana.org.au> <36e78459-1594-6d19-0ab4-95b03a6de036@gmail.com> <20190718152908.xiuze3kb3fdc7ov6@gondor.apana.org.au> <20190718155140.b6ig3zq22askmfpy@gondor.apana.org.au> In-Reply-To: From: Ard Biesheuvel Date: Fri, 19 Jul 2019 07:34:33 +0200 Message-ID: Subject: Re: xts fuzz testing and lack of ciphertext stealing support To: Pascal Van Leeuwen Cc: Herbert Xu , Milan Broz , Horia Geanta , "linux-crypto@vger.kernel.org" , "dm-devel@redhat.com" Content-Type: text/plain; charset="UTF-8" Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On Thu, 18 Jul 2019 at 19:03, Pascal Van Leeuwen wrote: > > > > > For XTS, you have this additional curve ball being thrown in called the "tweak". > > > > For encryption, the underlying "xts" would need to be able to chain the tweak, > > > > from what I've seen of the source the implementation cannot do that. > > > > > > You simply use the underlying xts for the first n - 2 blocks and > > > do the last two by hand. > > > > > > > OK, so it appears the XTS ciphertext stealing algorithm does not > > include the peculiar reordering of the 2 final blocks, which means > > that the kernel's implementation of XTS already conforms to the spec > > for inputs that are a multiple of the block size. > > > Yes, for XTS you effectively don't do CTS if it's a 16 byte multiple ... > > > The reason I am not a fan of making any changes here is that there are > > no in-kernel users that require ciphertext stealing for XTS, nor is > > anyone aware of any reason why we should be adding it to the userland > > interface. So we are basically adding dead code so that we are > > theoretically compliant in a way that we will never exercise in > > practice. > > > You know, having worked on all kinds of workarounds for silly irrelevant > (IMHO) corner cases in the inside-secure hardware driver over the past > months just to keep testmgr happy, this is kind of ironic ... > > Cipher text stealing happens to be a *major* part of the XTS specification > (it's not actually XTS without the CTS part!), yet you are suggesting not > to implement it because *you* don't have or know a use case for it. > That seems like a pretty bad argument to me. It's not some minor corner > case that's not supported.The implementation is just *incomplete* > without it. > I would argue that these cases are diametrically opposite: you proposed to remove support for zero length input vectors from the entire crypto API to prevent your driver from having to deal with inputs that the hardware cannot handle. I am proposing not to add support for cases that we have no need for. XTS without CTS is indistinguishable from XTS with CTS if the inputs are always a multiple of the block size, and in 12 years, nobody has ever raised the issue that our support is limited to that. So what problem are we fixing by changing this? dm-crypt does not care, fscrypt does not care, userland does not care (given that it does not work today and we are only finding out now due to some fuzz test failing on CAAM) > > Note that for software algorithms such as the bit sliced NEON > > implementation of AES, which can only operate on 8 AES blocks at a > > time, doing the final 2 blocks sequentially is going to seriously > > impact performance. This means whatever wrapper we invent around xex() > > (or whatever we call it) should go out of its way to ensure that the > > common, non-CTS case does not regress in performance, and the special > > handling is only invoked when necessary (which will be never). > > > I pretty much made the same argument about all these driver workarounds > slowing down my driver fast path but that was considered a non-issue. > > In this particular case, it should not need to be more than: > > if (unlikely(size & 15)) { > xts_with_partial_last_block(); > } else { > xts_with_only_full_blocks(); > } > Of course. But why add this at all if it is known to be dead code?