Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1752249ybi; Sun, 16 Jun 2019 12:23:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqyq/KY9dyoyoiR/TY3AtK1neLo3waPQV7vdKh8oSKv6RzC9xYP0MP6Upl8LDGfYs1p7lwbl X-Received: by 2002:a65:44cb:: with SMTP id g11mr45222678pgs.193.1560712989809; Sun, 16 Jun 2019 12:23:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560712989; cv=none; d=google.com; s=arc-20160816; b=KQBurSaRU5Dy1HdI+Az2JM0JCAz1UI1GdQIOyAz11jMC9M13c0grFOURWJpi/xE86V 1c73/TbjZ1ElKYLEROGwDLrkKZ2KFRKojo9/SzjnHILIcIUNwiwH2zCYI4Yb8nXBLePr P5uK6wpoTx9nPd3O4HqMwzmElNyqoj5B/QbGLTgrAB2guBdfyrIAmMWv5QXLlxgCegtL GXMXoTVRqETF+beA4DUx2ovMKtBwRM6gK1LmSEBJ7IO+whiS8orK7SjG96hQ+qsNPa2a eDyyiMyxYf3Uyw/FmA2lUFIoWtfPqNh7FGKWWozHyx7icdeY7XEzsbF/7mZae4Xuj12c vUBQ== 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=saUshM2iv2FhtdSgUUkXIgTrskoGJu0Ya5EbuRmU4C8=; b=r5AQpdrhcIf/5CO2K5Zul2xTNhKyQMi3gO/guJMeyqHpzpYGkjzpC8KxNNtbPoxkFn JgU5ySh0RQyHJvP/tEXmjCLzjFUvjqdqqoDpHqnfijDI8j44RVFV3LAJaJiSbqfJPOJ8 t9NMqCekEWG6SdJ7FQpHDNvXWzSTcZbYfYHOCSty19Wy4qlZNd8MuvBArwjfxYtRuThv 5WjPwELzzvQcLGfKD0yyKcmNg3LN6viwqM7A/AIs2LRGrlrVI/j7SNgcH4gMIK8vsEEJ njlq+dO7J8lPg6PLQPBJzyfcG21OwbPmQqvMj56a3BNuFXQFqjzYKKyUNewgVgvnQVf3 XR8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AVFyW+HO; 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 k11si7891930pjs.73.2019.06.16.12.22.48; Sun, 16 Jun 2019 12:23:09 -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=AVFyW+HO; 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 S1726683AbfFPTNN (ORCPT + 99 others); Sun, 16 Jun 2019 15:13:13 -0400 Received: from mail-io1-f67.google.com ([209.85.166.67]:36512 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbfFPTNN (ORCPT ); Sun, 16 Jun 2019 15:13:13 -0400 Received: by mail-io1-f67.google.com with SMTP id h6so16699415ioh.3 for ; Sun, 16 Jun 2019 12:13:13 -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=saUshM2iv2FhtdSgUUkXIgTrskoGJu0Ya5EbuRmU4C8=; b=AVFyW+HOIC/dDzrlp6oyi565VgYUCIlE1FrmGeeEWn/+HOG49dqLCMEGLSNsBA7tRr jaRXDJaL+cFwGxkDv3+sb4bPFcnLic922GupQ5/bglCOFB0kH7x7ZibqhqjV2gKUkiJf HjxVM95nwDns58YfY7DlKQMfwihX2fmB8J8iug8VHeK/XOP0i3pn46BhipxHQ9rSSTDU 5R+D5sN1CnYMiIHkoqkM47R9qJc63gKC9rUvP+Ql5JnYVr0dcsHCoteTcvdBRk8uaRa4 rhYJYEFLjb3vTrChcI5CzYUM/jpP4NGgef2G+RZoHZOsVGoDNCekvUWRENwsEz1vOnI+ gxTQ== 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=saUshM2iv2FhtdSgUUkXIgTrskoGJu0Ya5EbuRmU4C8=; b=uUy4brzvQ8kAofT0mEVyzveeeowVfdReGdxZpTu9Pn+lLfnKZQ+HmDjgK0Fft0Cg3+ kpc/3Hgv4hBFequsX3Mqw5RuWCmZjnDKkqku4A3CzEzQ07WJai5tfse552zC8jsb9u3S f7o1EgRkLjdlO4pojYPnwvLo45mtTctcXllWaJzTJYtUAubUQrUhONuIb5f4IeVGwaqe UZApKQDbVYp8browfs8/b5T865w5jO5syhBbNQu9hPZMWxJoUyLLSW8GQS5OT4P0tl5/ 4d2EnQ+lCr0RM/EfvGovigzU3r6VHUJs+GSfEIQQLkPVz/sPkHY+xtyguiAByJNWDZUX q44A== X-Gm-Message-State: APjAAAVxZdvTxhKqRd+zWVrn+Kricaxsp12kQp2xFbDORy+4hthy7NyE lgZAaXW3+PWBC2RgnGyLTxZgaecSQrurdaRFMq/g2w== X-Received: by 2002:a5e:820a:: with SMTP id l10mr12989202iom.283.1560712392550; Sun, 16 Jun 2019 12:13:12 -0700 (PDT) MIME-Version: 1.0 References: <20190614083404.20514-1-ard.biesheuvel@linaro.org> <9cd635ec-970b-bd1b-59f4-1a07395e69a0@gmail.com> In-Reply-To: <9cd635ec-970b-bd1b-59f4-1a07395e69a0@gmail.com> From: Ard Biesheuvel Date: Sun, 16 Jun 2019 21:13:01 +0200 Message-ID: Subject: Re: [RFC PATCH 0/3] crypto: switch to shash for ESSIV generation To: Milan Broz Cc: "open list:HARDWARE RANDOM NUMBER GENERATOR CORE" , Herbert Xu , Eric Biggers , device-mapper development , Mike Snitzer 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 Sat, 15 Jun 2019 at 20:19, Milan Broz wrote: > > On 14/06/2019 10:34, Ard Biesheuvel wrote: > > This series is presented as an RFC for a couple of reasons: > > - it is only build tested > > - it is unclear whether this is the right way to move away from the use of > > bare ciphers in non-crypto code > > - we haven't really discussed whether moving away from the use of bare ciphers > > in non-crypto code is a goal we agree on > > > > This series creates an ESSIV shash template that takes a (cipher,hash) tuple, > > where the digest size of the hash must be a valid key length for the cipher. > > The setkey() operation takes the hash of the input key, and sets into the > > cipher as the encryption key. Digest operations accept input up to the > > block size of the cipher, and perform a single block encryption operation to > > produce the ESSIV output. > > > > This matches what both users of ESSIV in the kernel do, and so it is proposed > > as a replacement for those, in patches #2 and #3. > > > > As for the discussion: the code is untested, so it is presented for discussion > > only. I'd like to understand whether we agree that phasing out the bare cipher > > interface from non-crypto code is a good idea, and whether this approach is > > suitable for fscrypt and dm-crypt. > > If you want some discussion, it would be very helpful if you cc device-mapper list > to reach dm-crypt developers. Please add at least dm-devel list. > > Just a few comments: > > - ESSIV is useful only for CBC mode. I wish we move to some better mode > in the future instead of cementing CBC use... But if it helps people > to actually use unpredictable IV for CBC, it is the right approach. > (yes, I know XTS has own problems as well... but IMO that should be the default > for sector/fs-block encryption these days :) > I agree that XTS should be preferred. But for some reason, the kernel's XTS implementation does not support ciphertext stealing (as opposed to, e.g., OpenSSL), and so CBC ended up being used for encrypting the filenames in fscrypt. I am trying to serve both customers with the same solution here, regardless of whether it is the recommended approach or not. > - I do not think there is a problem if ESSIV moves to crypto API, > but there it is presented as a hash... It is really just an IV generator. > True. But we don't have the proper abstractions to make this distinction, and so a shash is currently the best match. > > - wiring up some essiv(x,y) combinations into the testing framework. I wonder > > if anything other than essiv(aes,sha256) makes sense. > > In cryptsetup testsuite, we test serpent and twofish ciphers at least, but in > reality, essiv(aes,sha256) is the most used combination. > If it makes sense, I can run some tests with dm-crypt and this patchset. > OK, that is helpful, thanks. Mind if I ping you once we reach a state where we need to test for correctness? At the moment, this is still mostly a discussion piece.