From patchwork Wed Jun 19 16:29:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 11004685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id CBBF21395 for ; Wed, 19 Jun 2019 16:32:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B98C32856B for ; Wed, 19 Jun 2019 16:32:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AC2C128571; Wed, 19 Jun 2019 16:32:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C80052855A for ; Wed, 19 Jun 2019 16:32:10 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0B5D63003AFF; Wed, 19 Jun 2019 16:32:00 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BF69A1001DCB; Wed, 19 Jun 2019 16:31:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8FDCA206D3; Wed, 19 Jun 2019 16:31:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x5JGU0b3016585 for ; Wed, 19 Jun 2019 12:30:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5B8285C21E; Wed, 19 Jun 2019 16:30:00 +0000 (UTC) Delivered-To: dm-devel@redhat.com Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 55E1B5C207 for ; Wed, 19 Jun 2019 16:30:00 +0000 (UTC) Received: from mail-wm1-f68.google.com (mail-wm1-f68.google.com [209.85.128.68]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F376811DE for ; Wed, 19 Jun 2019 16:29:38 +0000 (UTC) Received: by mail-wm1-f68.google.com with SMTP id x15so144864wmj.3 for ; Wed, 19 Jun 2019 09:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s7YMvUeKHGCVPJ6h56oRKX/tJWXbZ14BKIbZN9gJZ54=; b=eMMMWYZGeoSYwM2Rb3U8pUTkVicJDmfOxgck1fjWi1SKUOs/Y8GqoTMbY4/XG0FKBf rSu7Q6/zA+WT/2CCI4L/vaPLP29Xi5DyYJW9cCs8ppKuiQiJXjg9K4RWSXwu8MZ7Ihgi ibDToRK5FS5Ohz43wVNxhK5ZmQeVzxT6rPSsKk+DTFxpFFQBySjY6DL0SMNW2J8CNlWy BOEsGvZkm1i1vUvJx5Fm4wge8wESv/ABJy4UOfqKgT3eXmnkkZSYQmHB8WGdJSte3XVX M/QBVQQ7eqjBna5Zob0eIfVT1Gbg3yzFz2zWYIgQNpSm6C0VH6ushjJMC1aHgrEqbq3N MBZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=s7YMvUeKHGCVPJ6h56oRKX/tJWXbZ14BKIbZN9gJZ54=; b=bPcE6S/W2qpwsDErmS0GBCMkH3hXb+6PdiqwMzazquPNm4uiUhlfl0Quir6g9fn/SH LF7VJduFwBg0srvcU0Y4C4OgZMJHdvay9LG3R/n/xRsL5mVDCQgSEpGMQH2ocxOTuw2D Rl7/Y9Hf+DkF3zpqzkwc9OH4l1z+7qFsy86d6cQTUXwLhb5L5szscqqFpVkPdO21eCMR smW/0yqDGnEJY4ysN8ioUTmAh/PNBsnf4XH5SFGx7XYXo+Ot+IfAj0J8v1HP/X9/RJML B60UeCPUzjEmrFzdKjQFzdWDLlCyGs12nQM/WiCXjw1cXrcxEQpWUq+NIYDRvFILlFS+ 2KLQ== X-Gm-Message-State: APjAAAU7AJuYh5WvO1nZkn7kBfqiNxhdFsojSTCLVmu7Dzouah/+UNea cP3K3skZwzWGEqg7Qr8dZGWrhA== X-Google-Smtp-Source: APXvYqyrwmONlQJLim0WamimribrTMlM1X8z6r0UVVTQFfT7okHbJzxy0T2AuaWZcCpYQcjG8u6OMQ== X-Received: by 2002:a1c:a019:: with SMTP id j25mr6648778wme.95.1560961776946; Wed, 19 Jun 2019 09:29:36 -0700 (PDT) Received: from localhost.localdomain (laubervilliers-657-1-83-120.w92-154.abo.wanadoo.fr. [92.154.90.120]) by smtp.gmail.com with ESMTPSA id 32sm37815960wra.35.2019.06.19.09.29.35 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 19 Jun 2019 09:29:36 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Date: Wed, 19 Jun 2019 18:29:15 +0200 Message-Id: <20190619162921.12509-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 19 Jun 2019 16:29:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 19 Jun 2019 16:29:45 +0000 (UTC) for IP:'209.85.128.68' DOMAIN:'mail-wm1-f68.google.com' HELO:'mail-wm1-f68.google.com' FROM:'ard.biesheuvel@linaro.org' RCPT:'' X-RedHat-Spam-Score: -0.109 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_NONE, SPF_NONE) 209.85.128.68 mail-wm1-f68.google.com 209.85.128.68 mail-wm1-f68.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: dm-devel@redhat.com Cc: Herbert Xu , Eric Biggers , Ard Biesheuvel , linux-fscrypt@vger.kernel.org, Gilad Ben-Yossef , dm-devel@redhat.com, Milan Broz Subject: [dm-devel] [PATCH v3 0/6] crypto: switch to crypto API for ESSIV generation X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Wed, 19 Jun 2019 16:32:10 +0000 (UTC) X-Virus-Scanned: ClamAV using ClamSMTP This series creates an ESSIV template that produces a skcipher or AEAD transform based on a tuple of the form ',,' (or ',,' for the AEAD case). It exposes the encapsulated sync or async skcipher/aead by passing through all operations, while using the cipher/shash pair to transform the input IV into an ESSIV output IV. 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 #4. This code has been tested using the fscrypt test suggested by Eric (generic/549), as well as the mode-test script suggested by Milan for the dm-crypt case. I also tested the aead case in a virtual machine, but it definitely needs some wider testing from the dm-crypt experts. Changes since v2: - fixed a couple of bugs that snuck in after I'd done the bulk of my testing - some cosmetic tweaks to the ESSIV template skcipher setkey function to align it with the aead one - add a test case for essiv(cbc(aes),aes,sha256) - add an accelerated implementation for arm64 that combines the IV derivation and the actual en/decryption in a single asm routine Scroll down for tcrypt speed test result comparing the essiv template with the asm implementation. Bare cbc(aes) tests included for reference as well. Taken on a 2GHz Cortex-A57 (AMD Seattle) Code can be found here https://git.kernel.org/pub/scm/linux/kernel/git/ardb/linux.git/log/?h=essiv-v3 Cc: Herbert Xu Cc: Eric Biggers Cc: dm-devel@redhat.com Cc: linux-fscrypt@vger.kernel.org Cc: Gilad Ben-Yossef Cc: Milan Broz Ard Biesheuvel (6): crypto: essiv - create wrapper template for ESSIV generation fs: crypto: invoke crypto API for ESSIV handling md: dm-crypt: infer ESSIV block cipher from cipher string directly md: dm-crypt: switch to ESSIV crypto API template crypto: essiv - add test vector for essiv(cbc(aes),aes,sha256) crypto: arm64/aes - implement accelerated ESSIV/CBC mode arch/arm64/crypto/aes-glue.c | 129 ++++ arch/arm64/crypto/aes-modes.S | 99 +++ crypto/Kconfig | 4 + crypto/Makefile | 1 + crypto/essiv.c | 630 ++++++++++++++++++++ crypto/tcrypt.c | 9 + crypto/testmgr.c | 6 + crypto/testmgr.h | 208 +++++++ drivers/md/Kconfig | 1 + drivers/md/dm-crypt.c | 237 ++------ fs/crypto/Kconfig | 1 + fs/crypto/crypto.c | 5 - fs/crypto/fscrypt_private.h | 9 - fs/crypto/keyinfo.c | 88 +-- 14 files changed, 1132 insertions(+), 295 deletions(-) create mode 100644 crypto/essiv.c