]>
Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
cf582cce JK |
2 | #ifndef ASM_X86_CAMELLIA_H |
3 | #define ASM_X86_CAMELLIA_H | |
4 | ||
5 | #include <linux/kernel.h> | |
6 | #include <linux/crypto.h> | |
7 | ||
8 | #define CAMELLIA_MIN_KEY_SIZE 16 | |
9 | #define CAMELLIA_MAX_KEY_SIZE 32 | |
10 | #define CAMELLIA_BLOCK_SIZE 16 | |
11 | #define CAMELLIA_TABLE_BYTE_LEN 272 | |
12 | #define CAMELLIA_PARALLEL_BLOCKS 2 | |
13 | ||
14 | struct camellia_ctx { | |
15 | u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)]; | |
16 | u32 key_length; | |
17 | }; | |
18 | ||
19 | struct camellia_lrw_ctx { | |
20 | struct lrw_table_ctx lrw_table; | |
21 | struct camellia_ctx camellia_ctx; | |
22 | }; | |
23 | ||
24 | struct camellia_xts_ctx { | |
25 | struct camellia_ctx tweak_ctx; | |
26 | struct camellia_ctx crypt_ctx; | |
27 | }; | |
28 | ||
29 | extern int __camellia_setkey(struct camellia_ctx *cctx, | |
30 | const unsigned char *key, | |
31 | unsigned int key_len, u32 *flags); | |
32 | ||
33 | extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, | |
34 | unsigned int keylen); | |
35 | extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm); | |
36 | ||
37 | extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, | |
38 | unsigned int keylen); | |
39 | ||
40 | /* regular block cipher functions */ | |
41 | asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, | |
42 | const u8 *src, bool xor); | |
43 | asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst, | |
44 | const u8 *src); | |
45 | ||
46 | /* 2-way parallel cipher functions */ | |
47 | asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, | |
48 | const u8 *src, bool xor); | |
49 | asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst, | |
50 | const u8 *src); | |
51 | ||
f3f935a7 JK |
52 | /* 16-way parallel cipher functions (avx/aes-ni) */ |
53 | asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst, | |
54 | const u8 *src); | |
55 | asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst, | |
56 | const u8 *src); | |
57 | ||
58 | asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst, | |
59 | const u8 *src); | |
60 | asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst, | |
61 | const u8 *src, le128 *iv); | |
62 | ||
63 | asmlinkage void camellia_xts_enc_16way(struct camellia_ctx *ctx, u8 *dst, | |
64 | const u8 *src, le128 *iv); | |
65 | asmlinkage void camellia_xts_dec_16way(struct camellia_ctx *ctx, u8 *dst, | |
66 | const u8 *src, le128 *iv); | |
67 | ||
cf582cce JK |
68 | static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, |
69 | const u8 *src) | |
70 | { | |
71 | __camellia_enc_blk(ctx, dst, src, false); | |
72 | } | |
73 | ||
74 | static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst, | |
75 | const u8 *src) | |
76 | { | |
77 | __camellia_enc_blk(ctx, dst, src, true); | |
78 | } | |
79 | ||
80 | static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, | |
81 | const u8 *src) | |
82 | { | |
83 | __camellia_enc_blk_2way(ctx, dst, src, false); | |
84 | } | |
85 | ||
86 | static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst, | |
87 | const u8 *src) | |
88 | { | |
89 | __camellia_enc_blk_2way(ctx, dst, src, true); | |
90 | } | |
91 | ||
92 | /* glue helpers */ | |
93 | extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src); | |
94 | extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, | |
95 | le128 *iv); | |
96 | extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, | |
97 | le128 *iv); | |
98 | ||
f3f935a7 JK |
99 | extern void camellia_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv); |
100 | extern void camellia_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv); | |
101 | ||
cf582cce | 102 | #endif /* ASM_X86_CAMELLIA_H */ |