Skip to content

Commit ea55cfc

Browse files
ardbiesheuvelherbertx
authored andcommitted
crypto: x86/cast6 - drop dependency on glue helper
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>
1 parent 674d40a commit ea55cfc

File tree

2 files changed

+17
-45
lines changed

2 files changed

+17
-45
lines changed

arch/x86/crypto/cast6_avx_glue.c

Lines changed: 17 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
#include <crypto/algapi.h>
1616
#include <crypto/cast6.h>
1717
#include <crypto/internal/simd.h>
18-
#include <asm/crypto/glue_helper.h>
18+
19+
#include "ecb_cbc_helpers.h"
1920

2021
#define CAST6_PARALLEL_BLOCKS 8
2122

@@ -30,63 +31,35 @@ static int cast6_setkey_skcipher(struct crypto_skcipher *tfm,
3031
return cast6_setkey(&tfm->base, key, keylen);
3132
}
3233

33-
static const struct common_glue_ctx cast6_enc = {
34-
.num_funcs = 2,
35-
.fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
36-
37-
.funcs = { {
38-
.num_blocks = CAST6_PARALLEL_BLOCKS,
39-
.fn_u = { .ecb = cast6_ecb_enc_8way }
40-
}, {
41-
.num_blocks = 1,
42-
.fn_u = { .ecb = __cast6_encrypt }
43-
} }
44-
};
45-
46-
static const struct common_glue_ctx cast6_dec = {
47-
.num_funcs = 2,
48-
.fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
49-
50-
.funcs = { {
51-
.num_blocks = CAST6_PARALLEL_BLOCKS,
52-
.fn_u = { .ecb = cast6_ecb_dec_8way }
53-
}, {
54-
.num_blocks = 1,
55-
.fn_u = { .ecb = __cast6_decrypt }
56-
} }
57-
};
58-
59-
static const struct common_glue_ctx cast6_dec_cbc = {
60-
.num_funcs = 2,
61-
.fpu_blocks_limit = CAST6_PARALLEL_BLOCKS,
62-
63-
.funcs = { {
64-
.num_blocks = CAST6_PARALLEL_BLOCKS,
65-
.fn_u = { .cbc = cast6_cbc_dec_8way }
66-
}, {
67-
.num_blocks = 1,
68-
.fn_u = { .cbc = __cast6_decrypt }
69-
} }
70-
};
71-
7234
static int ecb_encrypt(struct skcipher_request *req)
7335
{
74-
return glue_ecb_req_128bit(&cast6_enc, req);
36+
ECB_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
37+
ECB_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_ecb_enc_8way);
38+
ECB_BLOCK(1, __cast6_encrypt);
39+
ECB_WALK_END();
7540
}
7641

7742
static int ecb_decrypt(struct skcipher_request *req)
7843
{
79-
return glue_ecb_req_128bit(&cast6_dec, req);
44+
ECB_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
45+
ECB_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_ecb_dec_8way);
46+
ECB_BLOCK(1, __cast6_decrypt);
47+
ECB_WALK_END();
8048
}
8149

8250
static int cbc_encrypt(struct skcipher_request *req)
8351
{
84-
return glue_cbc_encrypt_req_128bit(__cast6_encrypt, req);
52+
CBC_WALK_START(req, CAST6_BLOCK_SIZE, -1);
53+
CBC_ENC_BLOCK(__cast6_encrypt);
54+
CBC_WALK_END();
8555
}
8656

8757
static int cbc_decrypt(struct skcipher_request *req)
8858
{
89-
return glue_cbc_decrypt_req_128bit(&cast6_dec_cbc, req);
59+
CBC_WALK_START(req, CAST6_BLOCK_SIZE, CAST6_PARALLEL_BLOCKS);
60+
CBC_DEC_BLOCK(CAST6_PARALLEL_BLOCKS, cast6_cbc_dec_8way);
61+
CBC_DEC_BLOCK(1, __cast6_decrypt);
62+
CBC_WALK_END();
9063
}
9164

9265
static struct skcipher_alg cast6_algs[] = {

crypto/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1393,7 +1393,6 @@ config CRYPTO_CAST6_AVX_X86_64
13931393
select CRYPTO_SKCIPHER
13941394
select CRYPTO_CAST6
13951395
select CRYPTO_CAST_COMMON
1396-
select CRYPTO_GLUE_HELPER_X86
13971396
select CRYPTO_SIMD
13981397
imply CRYPTO_XTS
13991398
imply CRYPTO_CTR

0 commit comments

Comments
 (0)