1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ASM_X86_CAMELLIA_H
3 #define ASM_X86_CAMELLIA_H
5 #include <crypto/lrw.h>
6 #include <linux/kernel.h>
7 #include <linux/crypto.h>
9 #define CAMELLIA_MIN_KEY_SIZE 16
10 #define CAMELLIA_MAX_KEY_SIZE 32
11 #define CAMELLIA_BLOCK_SIZE 16
12 #define CAMELLIA_TABLE_BYTE_LEN 272
13 #define CAMELLIA_PARALLEL_BLOCKS 2
16 u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
20 struct camellia_lrw_ctx {
21 struct lrw_table_ctx lrw_table;
22 struct camellia_ctx camellia_ctx;
25 struct camellia_xts_ctx {
26 struct camellia_ctx tweak_ctx;
27 struct camellia_ctx crypt_ctx;
30 extern int __camellia_setkey(struct camellia_ctx *cctx,
31 const unsigned char *key,
32 unsigned int key_len, u32 *flags);
34 extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
36 extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm);
38 extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
41 /* regular block cipher functions */
42 asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
43 const u8 *src, bool xor);
44 asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst,
47 /* 2-way parallel cipher functions */
48 asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
49 const u8 *src, bool xor);
50 asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst,
53 /* 16-way parallel cipher functions (avx/aes-ni) */
54 asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst,
56 asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst,
59 asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst,
61 asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst,
62 const u8 *src, le128 *iv);
64 asmlinkage void camellia_xts_enc_16way(struct camellia_ctx *ctx, u8 *dst,
65 const u8 *src, le128 *iv);
66 asmlinkage void camellia_xts_dec_16way(struct camellia_ctx *ctx, u8 *dst,
67 const u8 *src, le128 *iv);
69 static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
72 __camellia_enc_blk(ctx, dst, src, false);
75 static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst,
78 __camellia_enc_blk(ctx, dst, src, true);
81 static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
84 __camellia_enc_blk_2way(ctx, dst, src, false);
87 static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst,
90 __camellia_enc_blk_2way(ctx, dst, src, true);
94 extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src);
95 extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src,
97 extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
100 extern void camellia_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv);
101 extern void camellia_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv);
103 #endif /* ASM_X86_CAMELLIA_H */