From patchwork Tue Feb 20 07:48:20 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Biggers X-Patchwork-Id: 10229525 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 2DC3660392 for ; Tue, 20 Feb 2018 07:52:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 22482284F9 for ; Tue, 20 Feb 2018 07:52:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1726C2852C; Tue, 20 Feb 2018 07:52:01 +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.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, 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 ED9A02852B for ; Tue, 20 Feb 2018 07:51:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750774AbeBTHv5 (ORCPT ); Tue, 20 Feb 2018 02:51:57 -0500 Received: from mail-pl0-f67.google.com ([209.85.160.67]:45386 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751221AbeBTHvs (ORCPT ); Tue, 20 Feb 2018 02:51:48 -0500 Received: by mail-pl0-f67.google.com with SMTP id p5so7018741plo.12 for ; Mon, 19 Feb 2018 23:51:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=sVmn27zQM4Fg2ydoO4EUEVOccP8Whr7b/HVZk3Kr488=; b=DlEeAemLPXnzPcLmx6av7Jp3Hy9DL4zpqiA+IAOtixqESTS/I2b4xJqmu8ezsznO7c pVnVdLpbfHwZq2V8GhxzxxlfzAaGdNxkQwh/LQ8cmwy7h9rQCCjBJT1oQzYKVRg19yjN 4BbAmgeN6Tbjwa/nAlRwVu20a4u9inwkS+jwpEf1qxs1WLptalq+/nTBKJxiVRBmFNlf rFWhv5i7WZo78uVEWhhhSgthXqjdZVoGpVpU4e7cW8AAfNngnO4nZdSiIAwr3tmCElYP bHfqip6qJrM2OYMPavOvRslWtetC7Fdd/G+gap0Uob1nbxgpysPPSp294uVO+Ajlc7MX 0/zA== 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:in-reply-to :references; bh=sVmn27zQM4Fg2ydoO4EUEVOccP8Whr7b/HVZk3Kr488=; b=HKMzpoTBm49ZVzkcVMSzuPhvEFAtu2GGdydtSfNdibhDqiUEa2inLCYtDIrosKNg0C na4smo+epskugrKYm2hTBvBFlAWwuGqho1wmY1MmIHw3LgQDXdAImDEo3j7sKWnRMI+h D/8101+yaoCz6BZbOmm5PoRK75BHSUu0Zb04kTlYW3utJHbC3oBC216sw7WpQY5Ip2Yw yEe4EUrXwlLSwrPRnZQql88Bo2waQcfAEV/B+8LxV1nJNQu0vnJU78WzfGHKGIh2XtPY KmMScjhrGnTOLXL5RMu7bia0sT4l3eh8/C7d9ocdeDMOPcUsvBsAX5vgL2fajkuOKGHR w55A== X-Gm-Message-State: APf1xPAj8Ws5PwJQEwaRkNLqeF3IeyyB3UqhRWED9D6FLblxbHsvh1Uq qFPZSKg++NEXHknf/ZCakXzoSK3e X-Google-Smtp-Source: AH8x226/sg8oBOIHJMhI/A4kQdZ6r9HxuwhMSA8AfUZ1p2tdVGIWaPOojDXjoWka01DFLj9rFpsnkw== X-Received: by 2002:a17:902:523:: with SMTP id 32-v6mr16583982plf.145.1519113107930; Mon, 19 Feb 2018 23:51:47 -0800 (PST) Received: from zzz.localdomain (c-67-185-97-198.hsd1.wa.comcast.net. [67.185.97.198]) by smtp.gmail.com with ESMTPSA id z17sm16412772pfh.183.2018.02.19.23.51.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Feb 2018 23:51:47 -0800 (PST) From: Eric Biggers To: linux-crypto@vger.kernel.org Cc: Herbert Xu , Jussi Kivilinna , Eric Biggers Subject: [PATCH 22/30] crypto: x86/camellia - remove LRW algorithm Date: Mon, 19 Feb 2018 23:48:20 -0800 Message-Id: <20180220074828.2050-23-ebiggers3@gmail.com> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180220074828.2050-1-ebiggers3@gmail.com> References: <20180220074828.2050-1-ebiggers3@gmail.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Eric Biggers The LRW template now wraps an ECB mode algorithm rather than the block cipher directly. Therefore it is now redundant for crypto modules to wrap their ECB code with generic LRW code themselves via lrw_crypt(). Remove the lrw-camellia-asm algorithm which did this. Users who request lrw(camellia) and previously would have gotten lrw-camellia-asm will now get lrw(ecb-camellia-asm) instead, which is just as fast. Signed-off-by: Eric Biggers --- arch/x86/crypto/camellia_glue.c | 85 +--------------------------------- arch/x86/include/asm/crypto/camellia.h | 10 ---- crypto/Kconfig | 1 - 3 files changed, 1 insertion(+), 95 deletions(-) diff --git a/arch/x86/crypto/camellia_glue.c b/arch/x86/crypto/camellia_glue.c index af4840ab2a3df..9ae2af27e759b 100644 --- a/arch/x86/crypto/camellia_glue.c +++ b/arch/x86/crypto/camellia_glue.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include #include @@ -1437,65 +1436,6 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes) camellia_dec_blk(ctx, srcdst, srcdst); } -int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen) -{ - struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - int err; - - err = __camellia_setkey(&ctx->camellia_ctx, key, - keylen - CAMELLIA_BLOCK_SIZE, - &tfm->crt_flags); - if (err) - return err; - - return lrw_init_table(&ctx->lrw_table, - key + keylen - CAMELLIA_BLOCK_SIZE); -} -EXPORT_SYMBOL_GPL(lrw_camellia_setkey); - -static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct camellia_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[2 * 4]; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = &ctx->camellia_ctx, - .crypt_fn = encrypt_callback, - }; - - return lrw_crypt(desc, dst, src, nbytes, &req); -} - -static int lrw_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, - struct scatterlist *src, unsigned int nbytes) -{ - struct camellia_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm); - be128 buf[2 * 4]; - struct lrw_crypt_req req = { - .tbuf = buf, - .tbuflen = sizeof(buf), - - .table_ctx = &ctx->lrw_table, - .crypt_ctx = &ctx->camellia_ctx, - .crypt_fn = decrypt_callback, - }; - - return lrw_crypt(desc, dst, src, nbytes, &req); -} - -void lrw_camellia_exit_tfm(struct crypto_tfm *tfm) -{ - struct camellia_lrw_ctx *ctx = crypto_tfm_ctx(tfm); - - lrw_free_table(&ctx->lrw_table); -} -EXPORT_SYMBOL_GPL(lrw_camellia_exit_tfm); - int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen) { @@ -1554,7 +1494,7 @@ static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst, return xts_crypt(desc, dst, src, nbytes, &req); } -static struct crypto_alg camellia_algs[6] = { { +static struct crypto_alg camellia_algs[] = { { .cra_name = "camellia", .cra_driver_name = "camellia-asm", .cra_priority = 200, @@ -1631,29 +1571,6 @@ static struct crypto_alg camellia_algs[6] = { { .decrypt = ctr_crypt, }, }, -}, { - .cra_name = "lrw(camellia)", - .cra_driver_name = "lrw-camellia-asm", - .cra_priority = 300, - .cra_flags = CRYPTO_ALG_TYPE_BLKCIPHER, - .cra_blocksize = CAMELLIA_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct camellia_lrw_ctx), - .cra_alignmask = 0, - .cra_type = &crypto_blkcipher_type, - .cra_module = THIS_MODULE, - .cra_exit = lrw_camellia_exit_tfm, - .cra_u = { - .blkcipher = { - .min_keysize = CAMELLIA_MIN_KEY_SIZE + - CAMELLIA_BLOCK_SIZE, - .max_keysize = CAMELLIA_MAX_KEY_SIZE + - CAMELLIA_BLOCK_SIZE, - .ivsize = CAMELLIA_BLOCK_SIZE, - .setkey = lrw_camellia_setkey, - .encrypt = lrw_encrypt, - .decrypt = lrw_decrypt, - }, - }, }, { .cra_name = "xts(camellia)", .cra_driver_name = "xts-camellia-asm", diff --git a/arch/x86/include/asm/crypto/camellia.h b/arch/x86/include/asm/crypto/camellia.h index 24eff92a5356f..08d71444edc20 100644 --- a/arch/x86/include/asm/crypto/camellia.h +++ b/arch/x86/include/asm/crypto/camellia.h @@ -2,7 +2,6 @@ #ifndef ASM_X86_CAMELLIA_H #define ASM_X86_CAMELLIA_H -#include #include #include @@ -17,11 +16,6 @@ struct camellia_ctx { u32 key_length; }; -struct camellia_lrw_ctx { - struct lrw_table_ctx lrw_table; - struct camellia_ctx camellia_ctx; -}; - struct camellia_xts_ctx { struct camellia_ctx tweak_ctx; struct camellia_ctx crypt_ctx; @@ -31,10 +25,6 @@ extern int __camellia_setkey(struct camellia_ctx *cctx, const unsigned char *key, unsigned int key_len, u32 *flags); -extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, - unsigned int keylen); -extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm); - extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, unsigned int keylen); diff --git a/crypto/Kconfig b/crypto/Kconfig index 7ac34d6e820b3..694e4e9de3cb5 100644 --- a/crypto/Kconfig +++ b/crypto/Kconfig @@ -1147,7 +1147,6 @@ config CRYPTO_CAMELLIA_X86_64 depends on CRYPTO select CRYPTO_ALGAPI select CRYPTO_GLUE_HELPER_X86 - select CRYPTO_LRW select CRYPTO_XTS help Camellia cipher algorithm module (x86_64).