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-
7234static 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
7742static 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
8250static 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
8757static 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
9265static struct skcipher_alg cast6_algs [] = {
0 commit comments