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: 11004643 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 D742D1580 for ; Wed, 19 Jun 2019 16:29:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C74DB284F9 for ; Wed, 19 Jun 2019 16:29:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B193728505; Wed, 19 Jun 2019 16:29:41 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7EAC5284C3 for ; Wed, 19 Jun 2019 16:29:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726251AbfFSQ3k (ORCPT ); Wed, 19 Jun 2019 12:29:40 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:35158 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725899AbfFSQ3j (ORCPT ); Wed, 19 Jun 2019 12:29:39 -0400 Received: by mail-wm1-f67.google.com with SMTP id c6so166463wml.0 for ; Wed, 19 Jun 2019 09:29:37 -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=Ki7/m0C6Wb68dxUMEWNPG8qNHeSp+uEVbF9WGWoKo9r2y4pMNZwDjLP5mNaV41tI+b MvxPhmiYWS0tVbeWKeHgzvHmF+5JRPxJyg2BtNeXeV75+PYsT0B2yO9GstB+8K8DqLdj PZsUytKNS2HY3aZUuuYEql6YsO/8LS5w9CRHeyVswaPxvIveVS6LZYOnQoYLUflfBDdD uEBt8aeVB4qS18nLqwn9ES5OJkFt8myvmFen+KDY7/wKAsaMkmUzv0NfYBYjDCdzL6Cm +O3UKz3Wyjni2pMEvRHRqnWWqlGaMNkCyJ3tV2eb4Fr8KS2EhkpNRekCZqctrRnNe+3F 8K8w== X-Gm-Message-State: APjAAAV97Yusy4MFYLVKSBGQ2rnBq+7x8mE+A7cPOqP6lHaz4+xeKoQu TBIJnSQC1HACzUabll66J1tqyA== 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 Cc: Ard Biesheuvel , Herbert Xu , Eric Biggers , dm-devel@redhat.com, linux-fscrypt@vger.kernel.org, Gilad Ben-Yossef , Milan Broz Subject: [PATCH v3 0/6] crypto: switch to crypto API for ESSIV generation Date: Wed, 19 Jun 2019 18:29:15 +0200 Message-Id: <20190619162921.12509-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Sender: linux-fscrypt-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fscrypt@vger.kernel.org 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