crypto: x86/camellia - remove LRW algorithm

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 <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Eric Biggers 2018-02-19 23:48:20 -08:00 committed by Herbert Xu
parent 44c9b75409
commit 6043d341f0
3 changed files with 1 additions and 95 deletions

View File

@ -30,7 +30,6 @@
#include <linux/module.h> #include <linux/module.h>
#include <linux/types.h> #include <linux/types.h>
#include <crypto/algapi.h> #include <crypto/algapi.h>
#include <crypto/lrw.h>
#include <crypto/xts.h> #include <crypto/xts.h>
#include <asm/crypto/camellia.h> #include <asm/crypto/camellia.h>
#include <asm/crypto/glue_helper.h> #include <asm/crypto/glue_helper.h>
@ -1437,65 +1436,6 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
camellia_dec_blk(ctx, srcdst, srcdst); 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, int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
unsigned int keylen) 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); 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_name = "camellia",
.cra_driver_name = "camellia-asm", .cra_driver_name = "camellia-asm",
.cra_priority = 200, .cra_priority = 200,
@ -1631,29 +1571,6 @@ static struct crypto_alg camellia_algs[6] = { {
.decrypt = ctr_crypt, .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_name = "xts(camellia)",
.cra_driver_name = "xts-camellia-asm", .cra_driver_name = "xts-camellia-asm",

View File

@ -2,7 +2,6 @@
#ifndef ASM_X86_CAMELLIA_H #ifndef ASM_X86_CAMELLIA_H
#define ASM_X86_CAMELLIA_H #define ASM_X86_CAMELLIA_H
#include <crypto/lrw.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/crypto.h> #include <linux/crypto.h>
@ -17,11 +16,6 @@ struct camellia_ctx {
u32 key_length; u32 key_length;
}; };
struct camellia_lrw_ctx {
struct lrw_table_ctx lrw_table;
struct camellia_ctx camellia_ctx;
};
struct camellia_xts_ctx { struct camellia_xts_ctx {
struct camellia_ctx tweak_ctx; struct camellia_ctx tweak_ctx;
struct camellia_ctx crypt_ctx; struct camellia_ctx crypt_ctx;
@ -31,10 +25,6 @@ extern int __camellia_setkey(struct camellia_ctx *cctx,
const unsigned char *key, const unsigned char *key,
unsigned int key_len, u32 *flags); 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, extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
unsigned int keylen); unsigned int keylen);

View File

@ -1147,7 +1147,6 @@ config CRYPTO_CAMELLIA_X86_64
depends on CRYPTO depends on CRYPTO
select CRYPTO_ALGAPI select CRYPTO_ALGAPI
select CRYPTO_GLUE_HELPER_X86 select CRYPTO_GLUE_HELPER_X86
select CRYPTO_LRW
select CRYPTO_XTS select CRYPTO_XTS
help help
Camellia cipher algorithm module (x86_64). Camellia cipher algorithm module (x86_64).