1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef ASM_X86_CAMELLIA_H
3 #define ASM_X86_CAMELLIA_H
5 #include <crypto/b128ops.h>
6 #include <linux/crypto.h>
7 #include <linux/kernel.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
15 struct crypto_skcipher
;
18 u64 key_table
[CAMELLIA_TABLE_BYTE_LEN
/ sizeof(u64
)];
22 struct camellia_xts_ctx
{
23 struct camellia_ctx tweak_ctx
;
24 struct camellia_ctx crypt_ctx
;
27 extern int __camellia_setkey(struct camellia_ctx
*cctx
,
28 const unsigned char *key
,
29 unsigned int key_len
);
31 extern int xts_camellia_setkey(struct crypto_skcipher
*tfm
, const u8
*key
,
34 /* regular block cipher functions */
35 asmlinkage
void __camellia_enc_blk(const void *ctx
, u8
*dst
, const u8
*src
,
37 asmlinkage
void camellia_dec_blk(const void *ctx
, u8
*dst
, const u8
*src
);
39 /* 2-way parallel cipher functions */
40 asmlinkage
void __camellia_enc_blk_2way(const void *ctx
, u8
*dst
, const u8
*src
,
42 asmlinkage
void camellia_dec_blk_2way(const void *ctx
, u8
*dst
, const u8
*src
);
44 /* 16-way parallel cipher functions (avx/aes-ni) */
45 asmlinkage
void camellia_ecb_enc_16way(const void *ctx
, u8
*dst
, const u8
*src
);
46 asmlinkage
void camellia_ecb_dec_16way(const void *ctx
, u8
*dst
, const u8
*src
);
48 asmlinkage
void camellia_cbc_dec_16way(const void *ctx
, u8
*dst
, const u8
*src
);
49 asmlinkage
void camellia_ctr_16way(const void *ctx
, u8
*dst
, const u8
*src
,
52 asmlinkage
void camellia_xts_enc_16way(const void *ctx
, u8
*dst
, const u8
*src
,
54 asmlinkage
void camellia_xts_dec_16way(const void *ctx
, u8
*dst
, const u8
*src
,
57 static inline void camellia_enc_blk(const void *ctx
, u8
*dst
, const u8
*src
)
59 __camellia_enc_blk(ctx
, dst
, src
, false);
62 static inline void camellia_enc_blk_xor(const void *ctx
, u8
*dst
, const u8
*src
)
64 __camellia_enc_blk(ctx
, dst
, src
, true);
67 static inline void camellia_enc_blk_2way(const void *ctx
, u8
*dst
,
70 __camellia_enc_blk_2way(ctx
, dst
, src
, false);
73 static inline void camellia_enc_blk_xor_2way(const void *ctx
, u8
*dst
,
76 __camellia_enc_blk_2way(ctx
, dst
, src
, true);
80 extern void camellia_decrypt_cbc_2way(const void *ctx
, u8
*dst
, const u8
*src
);
81 extern void camellia_crypt_ctr(const void *ctx
, u8
*dst
, const u8
*src
,
83 extern void camellia_crypt_ctr_2way(const void *ctx
, u8
*dst
, const u8
*src
,
86 extern void camellia_xts_enc(const void *ctx
, u8
*dst
, const u8
*src
,
88 extern void camellia_xts_dec(const void *ctx
, u8
*dst
, const u8
*src
,
91 #endif /* ASM_X86_CAMELLIA_H */