]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
crypto: x86/twofish-3way - remove LRW algorithm
authorEric Biggers <ebiggers@google.com>
Tue, 20 Feb 2018 07:48:07 +0000 (23:48 -0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 2 Mar 2018 16:03:23 +0000 (00:03 +0800)
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-twofish-3way algorithm which did this.  Users who request
lrw(twofish) and previously would have gotten lrw-twofish-3way will now
get lrw(ecb-twofish-3way) instead, which is just as fast.

Signed-off-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/twofish_avx_glue.c
arch/x86/crypto/twofish_glue_3way.c
arch/x86/include/asm/crypto/twofish.h
crypto/Kconfig

index b7a3904b953c6146f543a164e6456c1893102a92..3358e23f9ffb9bb75daf91d9c8003840680017db 100644 (file)
@@ -262,6 +262,32 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
                twofish_dec_blk(ctx->ctx, srcdst, srcdst);
 }
 
+struct twofish_lrw_ctx {
+       struct lrw_table_ctx lrw_table;
+       struct twofish_ctx twofish_ctx;
+};
+
+static int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
+                             unsigned int keylen)
+{
+       struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
+       int err;
+
+       err = __twofish_setkey(&ctx->twofish_ctx, key, keylen - TF_BLOCK_SIZE,
+                              &tfm->crt_flags);
+       if (err)
+               return err;
+
+       return lrw_init_table(&ctx->lrw_table, key + keylen - TF_BLOCK_SIZE);
+}
+
+static void lrw_twofish_exit_tfm(struct crypto_tfm *tfm)
+{
+       struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
+
+       lrw_free_table(&ctx->lrw_table);
+}
+
 static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
                       struct scatterlist *src, unsigned int nbytes)
 {
index 243e90a4b5d91c52f4d9ed563ab2edf93dc27e39..2d6dc5d7f0aaf8ffc4698a1eca27997e9b5e5dc4 100644 (file)
@@ -30,7 +30,6 @@
 #include <crypto/b128ops.h>
 #include <asm/crypto/twofish.h>
 #include <asm/crypto/glue_helper.h>
-#include <crypto/lrw.h>
 #include <crypto/xts.h>
 
 EXPORT_SYMBOL_GPL(__twofish_enc_blk_3way);
@@ -213,63 +212,6 @@ static void decrypt_callback(void *priv, u8 *srcdst, unsigned int nbytes)
                twofish_dec_blk(ctx, srcdst, srcdst);
 }
 
-int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
-                      unsigned int keylen)
-{
-       struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
-       int err;
-
-       err = __twofish_setkey(&ctx->twofish_ctx, key, keylen - TF_BLOCK_SIZE,
-                              &tfm->crt_flags);
-       if (err)
-               return err;
-
-       return lrw_init_table(&ctx->lrw_table, key + keylen - TF_BLOCK_SIZE);
-}
-EXPORT_SYMBOL_GPL(lrw_twofish_setkey);
-
-static int lrw_encrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
-                      struct scatterlist *src, unsigned int nbytes)
-{
-       struct twofish_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
-       be128 buf[3];
-       struct lrw_crypt_req req = {
-               .tbuf = buf,
-               .tbuflen = sizeof(buf),
-
-               .table_ctx = &ctx->lrw_table,
-               .crypt_ctx = &ctx->twofish_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 twofish_lrw_ctx *ctx = crypto_blkcipher_ctx(desc->tfm);
-       be128 buf[3];
-       struct lrw_crypt_req req = {
-               .tbuf = buf,
-               .tbuflen = sizeof(buf),
-
-               .table_ctx = &ctx->lrw_table,
-               .crypt_ctx = &ctx->twofish_ctx,
-               .crypt_fn = decrypt_callback,
-       };
-
-       return lrw_crypt(desc, dst, src, nbytes, &req);
-}
-
-void lrw_twofish_exit_tfm(struct crypto_tfm *tfm)
-{
-       struct twofish_lrw_ctx *ctx = crypto_tfm_ctx(tfm);
-
-       lrw_free_table(&ctx->lrw_table);
-}
-EXPORT_SYMBOL_GPL(lrw_twofish_exit_tfm);
-
 int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
                       unsigned int keylen)
 {
@@ -328,7 +270,7 @@ static int xts_decrypt(struct blkcipher_desc *desc, struct scatterlist *dst,
        return xts_crypt(desc, dst, src, nbytes, &req);
 }
 
-static struct crypto_alg tf_algs[5] = { {
+static struct crypto_alg tf_algs[] = { {
        .cra_name               = "ecb(twofish)",
        .cra_driver_name        = "ecb-twofish-3way",
        .cra_priority           = 300,
@@ -387,27 +329,6 @@ static struct crypto_alg tf_algs[5] = { {
                        .decrypt        = ctr_crypt,
                },
        },
-}, {
-       .cra_name               = "lrw(twofish)",
-       .cra_driver_name        = "lrw-twofish-3way",
-       .cra_priority           = 300,
-       .cra_flags              = CRYPTO_ALG_TYPE_BLKCIPHER,
-       .cra_blocksize          = TF_BLOCK_SIZE,
-       .cra_ctxsize            = sizeof(struct twofish_lrw_ctx),
-       .cra_alignmask          = 0,
-       .cra_type               = &crypto_blkcipher_type,
-       .cra_module             = THIS_MODULE,
-       .cra_exit               = lrw_twofish_exit_tfm,
-       .cra_u = {
-               .blkcipher = {
-                       .min_keysize    = TF_MIN_KEY_SIZE + TF_BLOCK_SIZE,
-                       .max_keysize    = TF_MAX_KEY_SIZE + TF_BLOCK_SIZE,
-                       .ivsize         = TF_BLOCK_SIZE,
-                       .setkey         = lrw_twofish_setkey,
-                       .encrypt        = lrw_encrypt,
-                       .decrypt        = lrw_decrypt,
-               },
-       },
 }, {
        .cra_name               = "xts(twofish)",
        .cra_driver_name        = "xts-twofish-3way",
index 65bb80adba3ef096849595f1df2612fd7aa81431..3c904116ee002114068f42406e7f016a3f45e009 100644 (file)
@@ -4,14 +4,8 @@
 
 #include <linux/crypto.h>
 #include <crypto/twofish.h>
-#include <crypto/lrw.h>
 #include <crypto/b128ops.h>
 
-struct twofish_lrw_ctx {
-       struct lrw_table_ctx lrw_table;
-       struct twofish_ctx twofish_ctx;
-};
-
 struct twofish_xts_ctx {
        struct twofish_ctx tweak_ctx;
        struct twofish_ctx crypt_ctx;
@@ -36,11 +30,6 @@ extern void twofish_enc_blk_ctr(void *ctx, u128 *dst, const u128 *src,
 extern void twofish_enc_blk_ctr_3way(void *ctx, u128 *dst, const u128 *src,
                                     le128 *iv);
 
-extern int lrw_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
-                             unsigned int keylen);
-
-extern void lrw_twofish_exit_tfm(struct crypto_tfm *tfm);
-
 extern int xts_twofish_setkey(struct crypto_tfm *tfm, const u8 *key,
                              unsigned int keylen);
 
index cca8271d8894ddc3ef9285ea63026e1080a89734..eba78fa8514705b41755558ed7c63ed2ab3cd87d 100644 (file)
@@ -1584,7 +1584,6 @@ config CRYPTO_TWOFISH_X86_64_3WAY
        select CRYPTO_TWOFISH_COMMON
        select CRYPTO_TWOFISH_X86_64
        select CRYPTO_GLUE_HELPER_X86
-       select CRYPTO_LRW
        select CRYPTO_XTS
        help
          Twofish cipher algorithm (x86_64, 3-way parallel).