crypto: x86/cast6 - drop dependency on glue helper
authorArd Biesheuvel <ardb@kernel.org>
Tue, 5 Jan 2021 16:48:06 +0000 (17:48 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Thu, 14 Jan 2021 06:10:29 +0000 (17:10 +1100)
Replace the glue helper dependency with implementations of ECB and CBC
based on the new CPP macros, which avoid the need for indirect calls.

Acked-by: Eric Biggers <ebiggers@google.com>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/x86/crypto/cast6_avx_glue.c
crypto/Kconfig

index 790efcb6df3b244055b46ad79c6ca7355c1edae2..7e2aea372349085bcb090a2117dd32019c67a81f 100644 (file)
@@ -15,7 +15,8 @@
 #include <crypto/algapi.h>
 #include <crypto/cast6.h>
 #include <crypto/internal/simd.h>
-#include <asm/crypto/glue_helper.h>
+
+#include "ecb_cbc_helpers.h"
 
 #define CAST6_PARALLEL_BLOCKS 8
 
@@ -30,63 +31,35 @@ static int cast6_setkey_skcipher(struct crypto_skcipher *tfm,
        return cast6_setkey(&tfm->base, key, keylen);
 }
 
-static const struct common_glue_ctx cast6_enc = {
-       .num_funcs = 2,
-       .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
-
-       .funcs = { {
-               .num_blocks = CAST6_PARALLEL_BLOCKS,
-               .fn_u = { .ecb = cast6_ecb_enc_8way }
-       }, {
-               .num_blocks = 1,
-               .fn_u = { .ecb = __cast6_encrypt }
-       } }
-};
-
-static const struct common_glue_ctx cast6_dec = {
-       .num_funcs = 2,
-       .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
-
-       .funcs = { {
-               .num_blocks = CAST6_PARALLEL_BLOCKS,
-               .fn_u = { .ecb = cast6_ecb_dec_8way }
-       }, {
-               .num_blocks = 1,
-               .fn_u = { .ecb = __cast6_decrypt }
-       } }
-};
-
-static const struct common_glue_ctx cast6_dec_cbc = {
-       .num_funcs = 2,
-       .fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
-
-       .funcs = { {
-               .num_blocks = CAST6_PARALLEL_BLOCKS,
-               .fn_u = { .cbc = cast6_cbc_dec_8way }
-       }, {
-               .num_blocks = 1,
-               .fn_u = { .cbc = __cast6_decrypt }
-       } }
-};
-
 static int ecb_encrypt(struct skcipher_request *req)
 {
-       return glue_ecb_req_128bit(&cast6_enc, req);
+       ECB_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
+       ECB_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_ecb_enc_8way);
+       ECB_BLOCK(1, __cast6_encrypt);
+       ECB_WALK_END();
 }
 
 static int ecb_decrypt(struct skcipher_request *req)
 {
-       return glue_ecb_req_128bit(&cast6_dec, req);
+       ECB_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
+       ECB_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_ecb_dec_8way);
+       ECB_BLOCK(1, __cast6_decrypt);
+       ECB_WALK_END();
 }
 
 static int cbc_encrypt(struct skcipher_request *req)
 {
-       return glue_cbc_encrypt_req_128bit(__cast6_encrypt, req);
+       CBC_WALK_START(req, CAST6_BLOCK_SIZE, -1);
+       CBC_ENC_BLOCK(__cast6_encrypt);
+       CBC_WALK_END();
 }
 
 static int cbc_decrypt(struct skcipher_request *req)
 {
-       return glue_cbc_decrypt_req_128bit(&cast6_dec_cbc, req);
+       CBC_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
+       CBC_DEC_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_cbc_dec_8way);
+       CBC_DEC_BLOCK(1, __cast6_decrypt);
+       CBC_WALK_END();
 }
 
 static struct skcipher_alg cast6_algs[] = {
index 29dce7efc443b463918b0c4f4b98f37263d6d2e4..25101558acb5ceeeb5260f91c16f5ec9ad86a6d2 100644 (file)
@@ -1393,7 +1393,6 @@ config CRYPTO_CAST6_AVX_X86_64
        select CRYPTO_SKCIPHER
        select CRYPTO_CAST6
        select CRYPTO_CAST_COMMON
-       select CRYPTO_GLUE_HELPER_X86
        select CRYPTO_SIMD
        imply CRYPTO_XTS
        imply CRYPTO_CTR