From patchwork Wed Jun 12 16:19:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 166588 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp3877563ilk; Wed, 12 Jun 2019 09:20:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqwz4TYkV20CndAtEXB3bKrnOISxcmvLK/gM8OuZgQVF5pov5GB0S0tt1LscTj7GYKhtV6OA X-Received: by 2002:a62:65c7:: with SMTP id z190mr87792296pfb.73.1560356414925; Wed, 12 Jun 2019 09:20:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560356414; cv=none; d=google.com; s=arc-20160816; b=J9qmmtKaJPFH6bSDS0OK3+Hi+ya1zP/zgFdadt1THkNbpsu1g1nbn2IBexO3z3qQK3 Z3tlsN3lNrjo6ZZQiMRStT0Kvzb9QVkC5uIgQ7V9tRJx8ceonEdgB8KpXJNgINbJu4L5 fLHGztYGGMBgnXeZ2HofVpmHrTql3EEMnsv8r2QzVQhTxCdwsN+kL8RVRWvbn2Dc2jN9 9duUCm5sOM748TusExTKywIa9LyEDqvhJRX6/bl7l6hqICp0H9qALWuXaTWx0IEqaeei ffjhVUDhFZwlq7VpF/LO5oH7pFvoS7u7daG5KB7o+USgab5IRROXfVHfAj1UJxsyv38C mNMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=71XtsErnWwza7NpJOunpzUrf9mDsoTV+W1Ysg9p4k2o=; b=gomaxujxbbr3yNTC8+QcOFD7+ZGpxpPSgH8MtVzBrao93OGftLOZXeJ0/hDnPhLJkq NVEffF1wZJwKO7QFRiLPKuI/jXLgmAkSdqjhC8T1eFKKSf12PEBqlT1SRoAbcMNJBFGg pEQ9clQs5GmCGORagyVIA2srd2w/MyWEZDbNH3jYJV8Z9b57leUr4gjbz50GPXjhl8Bi pPfSGyfeWru8jVTz2+5pz3JuAFogM/rWP6camWSOybGCc7LV6q8bffo8YygaL1NIFOXT jkZvXcSKoM/efD3Yrbjwh6OBSc5SaWtoUpbyKPO/tTHF1eGC5Cc+Rd/7k+2VcthSES7Z GOew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=yxACm3A5; 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 m62si210687pgm.392.2019.06.12.09.20.14; Wed, 12 Jun 2019 09:20:14 -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=yxACm3A5; 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 S2405317AbfFLQUN (ORCPT + 3 others); Wed, 12 Jun 2019 12:20:13 -0400 Received: from mail-wm1-f66.google.com ([209.85.128.66]:35035 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730745AbfFLQUN (ORCPT ); Wed, 12 Jun 2019 12:20:13 -0400 Received: by mail-wm1-f66.google.com with SMTP id c6so7202177wml.0 for ; Wed, 12 Jun 2019 09:20:11 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=71XtsErnWwza7NpJOunpzUrf9mDsoTV+W1Ysg9p4k2o=; b=yxACm3A5BvBtD/oTZ10SCftJv/HJQwBaaE9YyNlHEmeMfgBGTXyDWEvOOlGi+qmqNF bdtxIUyQpBaQpf29p1VZZXpWpDg9z2sE4Gs96qAWDmifWDIffYuRa7+mU8dk3OoV+djJ t9sKC3MSbq/h5cLjPaEVdS5C+D9Q4os8PtAYBJ+NkcXAPrZWMzsddcS8reb5AFXLtV3j UJMgrC68lQa+Qhq5jPgvl9xS9XPlm0QOMCV71IAPevba1Hi3kw4+O75YW4BrUK12Bom4 GdT3j8xrq7bEA5lg4PVGhVoA+yX6wGBdPirlrpLaZ2EwpNVlAG78ryDyLr3iIMYnE/VM foag== 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:mime-version:content-transfer-encoding; bh=71XtsErnWwza7NpJOunpzUrf9mDsoTV+W1Ysg9p4k2o=; b=oF2T7FxQtB0ps1yOs++xQXQ+UkWUf4BZOS1oiO8Ie4Z5TI17nKXM8hpZZgMeoDEWZG taeukyb4JqDfA4FrYe1XomHzu5ly6wCR4Cpm790U9LUZwR9roka+VM+XYFyiISxQEVNX qVE8yYGTJ66zk9wE2mgXvVtbuu67Xt38bJkaEpfLznzBfzzxz6PsSKI9pAtzKalwtAp8 51yUU4rw0zab7jfhLDxO4ElGVbKEdqr0z6Bc0pbeeacDBOaWWpIjXAmy4C1a0TpiUXQn xvkrK4Cup0dwa4Epw5aZkXUiKocXA4mObOmBbW55LC4agnySVxro9zftGPHyHh4oIGk9 ONEg== X-Gm-Message-State: APjAAAUDMxe0/QMj/yjaeq9RTJRIPpOKw/5X6xRTRXeblzKMY4HhAecz SMHCHsTdYSWG26Htg0byJz33AeLUf4Bm5g== X-Received: by 2002:a1c:a7c6:: with SMTP id q189mr22019wme.146.1560356411078; Wed, 12 Jun 2019 09:20:11 -0700 (PDT) Received: from sudo.home ([2a01:cb1d:112:6f00:353a:f33a:a393:3ada]) by smtp.gmail.com with ESMTPSA id c16sm70172wrr.53.2019.06.12.09.20.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2019 09:20:10 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: Ard Biesheuvel , Herbert Xu , "David S. Miller" , Eric Biggers , Johannes Berg Subject: [PATCH v5 5/7] crypto: arc4 - remove cipher implementation Date: Wed, 12 Jun 2019 18:19:57 +0200 Message-Id: <20190612161959.30478-6-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190612161959.30478-1-ard.biesheuvel@linaro.org> References: <20190612161959.30478-1-ard.biesheuvel@linaro.org> MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org There are no remaining users of the cipher implementation, and there are no meaningful ways in which the arc4 cipher can be combined with templates other than ECB (and the way we do provide that combination is highly dubious to begin with). So let's drop the arc4 cipher altogether, and only keep the ecb(arc4) skcipher, which is used in various places in the kernel. Signed-off-by: Ard Biesheuvel --- crypto/arc4.c | 64 +++++--------------- crypto/testmgr.c | 1 + 2 files changed, 16 insertions(+), 49 deletions(-) -- 2.20.1 diff --git a/crypto/arc4.c b/crypto/arc4.c index 6974dba1b7b9..dd82fb7ebc75 100644 --- a/crypto/arc4.c +++ b/crypto/arc4.c @@ -13,26 +13,15 @@ #include #include -static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key, - unsigned int key_len) +static int crypto_arc4_setkey(struct crypto_skcipher *tfm, const u8 *in_key, + unsigned int key_len) { - struct arc4_ctx *ctx = crypto_tfm_ctx(tfm); + struct arc4_ctx *ctx = crypto_skcipher_ctx(tfm); return arc4_setkey(ctx, in_key, key_len); } -static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key, - unsigned int key_len) -{ - return arc4_set_key(&tfm->base, in_key, key_len); -} - -static void arc4_crypt_one(struct crypto_tfm *tfm, u8 *out, const u8 *in) -{ - arc4_crypt(crypto_tfm_ctx(tfm), out, in, 1); -} - -static int ecb_arc4_crypt(struct skcipher_request *req) +static int crypto_arc4_crypt(struct skcipher_request *req) { struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); struct arc4_ctx *ctx = crypto_skcipher_ctx(tfm); @@ -50,24 +39,11 @@ static int ecb_arc4_crypt(struct skcipher_request *req) return err; } -static struct crypto_alg arc4_cipher = { - .cra_name = "arc4", - .cra_flags = CRYPTO_ALG_TYPE_CIPHER, - .cra_blocksize = ARC4_BLOCK_SIZE, - .cra_ctxsize = sizeof(struct arc4_ctx), - .cra_module = THIS_MODULE, - .cra_u = { - .cipher = { - .cia_min_keysize = ARC4_MIN_KEY_SIZE, - .cia_max_keysize = ARC4_MAX_KEY_SIZE, - .cia_setkey = arc4_set_key, - .cia_encrypt = arc4_crypt_one, - .cia_decrypt = arc4_crypt_one, - }, - }, -}; - -static struct skcipher_alg arc4_skcipher = { +static struct skcipher_alg arc4_alg = { + /* + * For legacy reasons, this is named "ecb(arc4)", not "arc4". + * Nevertheless it's actually a stream cipher, not a block cipher. + */ .base.cra_name = "ecb(arc4)", .base.cra_priority = 100, .base.cra_blocksize = ARC4_BLOCK_SIZE, @@ -75,29 +51,19 @@ static struct skcipher_alg arc4_skcipher = { .base.cra_module = THIS_MODULE, .min_keysize = ARC4_MIN_KEY_SIZE, .max_keysize = ARC4_MAX_KEY_SIZE, - .setkey = arc4_set_key_skcipher, - .encrypt = ecb_arc4_crypt, - .decrypt = ecb_arc4_crypt, + .setkey = crypto_arc4_setkey, + .encrypt = crypto_arc4_crypt, + .decrypt = crypto_arc4_crypt, }; static int __init arc4_init(void) { - int err; - - err = crypto_register_alg(&arc4_cipher); - if (err) - return err; - - err = crypto_register_skcipher(&arc4_skcipher); - if (err) - crypto_unregister_alg(&arc4_cipher); - return err; + return crypto_register_skcipher(&arc4_alg); } static void __exit arc4_exit(void) { - crypto_unregister_alg(&arc4_cipher); - crypto_unregister_skcipher(&arc4_skcipher); + crypto_unregister_skcipher(&arc4_alg); } subsys_initcall(arc4_init); @@ -106,4 +72,4 @@ module_exit(arc4_exit); MODULE_LICENSE("GPL"); MODULE_DESCRIPTION("ARC4 Cipher Algorithm"); MODULE_AUTHOR("Jon Oberheide "); -MODULE_ALIAS_CRYPTO("arc4"); +MODULE_ALIAS_CRYPTO("ecb(arc4)"); diff --git a/crypto/testmgr.c b/crypto/testmgr.c index 658a7eeebab2..c7be4e3c22cc 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c @@ -4125,6 +4125,7 @@ static const struct alg_test_desc alg_test_descs[] = { } }, { .alg = "ecb(arc4)", + .generic_driver = "ecb(arc4)-generic", .test = alg_test_skcipher, .suite = { .cipher = __VECS(arc4_tv_template)