Commit 611a23c2 authored by Ard Biesheuvel's avatar Ard Biesheuvel Committed by Herbert Xu

crypto: arc4 - remove cipher implementation

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: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 4be29701
...@@ -18,26 +18,15 @@ ...@@ -18,26 +18,15 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/module.h> #include <linux/module.h>
static int arc4_set_key(struct crypto_tfm *tfm, const u8 *in_key, static int crypto_arc4_setkey(struct crypto_skcipher *tfm, const u8 *in_key,
unsigned int key_len) 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); return arc4_setkey(ctx, in_key, key_len);
} }
static int arc4_set_key_skcipher(struct crypto_skcipher *tfm, const u8 *in_key, static int crypto_arc4_crypt(struct skcipher_request *req)
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)
{ {
struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req); struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(req);
struct arc4_ctx *ctx = crypto_skcipher_ctx(tfm); struct arc4_ctx *ctx = crypto_skcipher_ctx(tfm);
...@@ -55,25 +44,11 @@ static int ecb_arc4_crypt(struct skcipher_request *req) ...@@ -55,25 +44,11 @@ static int ecb_arc4_crypt(struct skcipher_request *req)
return err; return err;
} }
static struct crypto_alg arc4_cipher = { static struct skcipher_alg arc4_alg = {
.cra_name = "arc4", /*
.cra_driver_name = "arc4-generic", * For legacy reasons, this is named "ecb(arc4)", not "arc4".
.cra_flags = CRYPTO_ALG_TYPE_CIPHER, * Nevertheless it's actually a stream cipher, not a block 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 = {
.base.cra_name = "ecb(arc4)", .base.cra_name = "ecb(arc4)",
.base.cra_driver_name = "ecb(arc4)-generic", .base.cra_driver_name = "ecb(arc4)-generic",
.base.cra_priority = 100, .base.cra_priority = 100,
...@@ -82,29 +57,19 @@ static struct skcipher_alg arc4_skcipher = { ...@@ -82,29 +57,19 @@ static struct skcipher_alg arc4_skcipher = {
.base.cra_module = THIS_MODULE, .base.cra_module = THIS_MODULE,
.min_keysize = ARC4_MIN_KEY_SIZE, .min_keysize = ARC4_MIN_KEY_SIZE,
.max_keysize = ARC4_MAX_KEY_SIZE, .max_keysize = ARC4_MAX_KEY_SIZE,
.setkey = arc4_set_key_skcipher, .setkey = crypto_arc4_setkey,
.encrypt = ecb_arc4_crypt, .encrypt = crypto_arc4_crypt,
.decrypt = ecb_arc4_crypt, .decrypt = crypto_arc4_crypt,
}; };
static int __init arc4_init(void) static int __init arc4_init(void)
{ {
int err; return crypto_register_skcipher(&arc4_alg);
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;
} }
static void __exit arc4_exit(void) static void __exit arc4_exit(void)
{ {
crypto_unregister_alg(&arc4_cipher); crypto_unregister_skcipher(&arc4_alg);
crypto_unregister_skcipher(&arc4_skcipher);
} }
subsys_initcall(arc4_init); subsys_initcall(arc4_init);
...@@ -113,4 +78,4 @@ module_exit(arc4_exit); ...@@ -113,4 +78,4 @@ module_exit(arc4_exit);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("ARC4 Cipher Algorithm"); MODULE_DESCRIPTION("ARC4 Cipher Algorithm");
MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>"); MODULE_AUTHOR("Jon Oberheide <jon@oberheide.org>");
MODULE_ALIAS_CRYPTO("arc4"); MODULE_ALIAS_CRYPTO("ecb(arc4)");
...@@ -4404,6 +4404,7 @@ static const struct alg_test_desc alg_test_descs[] = { ...@@ -4404,6 +4404,7 @@ static const struct alg_test_desc alg_test_descs[] = {
} }
}, { }, {
.alg = "ecb(arc4)", .alg = "ecb(arc4)",
.generic_driver = "ecb(arc4)-generic",
.test = alg_test_skcipher, .test = alg_test_skcipher,
.suite = { .suite = {
.cipher = __VECS(arc4_tv_template) .cipher = __VECS(arc4_tv_template)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment