xref: /linux/arch/x86/crypto/camellia.h (revision a04ea6f7)
1*a04ea6f7SArd Biesheuvel /* SPDX-License-Identifier: GPL-2.0 */
2*a04ea6f7SArd Biesheuvel #ifndef ASM_X86_CAMELLIA_H
3*a04ea6f7SArd Biesheuvel #define ASM_X86_CAMELLIA_H
4*a04ea6f7SArd Biesheuvel 
5*a04ea6f7SArd Biesheuvel #include <crypto/b128ops.h>
6*a04ea6f7SArd Biesheuvel #include <linux/crypto.h>
7*a04ea6f7SArd Biesheuvel #include <linux/kernel.h>
8*a04ea6f7SArd Biesheuvel 
9*a04ea6f7SArd Biesheuvel #define CAMELLIA_MIN_KEY_SIZE	16
10*a04ea6f7SArd Biesheuvel #define CAMELLIA_MAX_KEY_SIZE	32
11*a04ea6f7SArd Biesheuvel #define CAMELLIA_BLOCK_SIZE	16
12*a04ea6f7SArd Biesheuvel #define CAMELLIA_TABLE_BYTE_LEN	272
13*a04ea6f7SArd Biesheuvel #define CAMELLIA_PARALLEL_BLOCKS 2
14*a04ea6f7SArd Biesheuvel 
15*a04ea6f7SArd Biesheuvel struct crypto_skcipher;
16*a04ea6f7SArd Biesheuvel 
17*a04ea6f7SArd Biesheuvel struct camellia_ctx {
18*a04ea6f7SArd Biesheuvel 	u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
19*a04ea6f7SArd Biesheuvel 	u32 key_length;
20*a04ea6f7SArd Biesheuvel };
21*a04ea6f7SArd Biesheuvel 
22*a04ea6f7SArd Biesheuvel extern int __camellia_setkey(struct camellia_ctx *cctx,
23*a04ea6f7SArd Biesheuvel 			     const unsigned char *key,
24*a04ea6f7SArd Biesheuvel 			     unsigned int key_len);
25*a04ea6f7SArd Biesheuvel 
26*a04ea6f7SArd Biesheuvel /* regular block cipher functions */
27*a04ea6f7SArd Biesheuvel asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src,
28*a04ea6f7SArd Biesheuvel 				   bool xor);
29*a04ea6f7SArd Biesheuvel asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src);
30*a04ea6f7SArd Biesheuvel 
31*a04ea6f7SArd Biesheuvel /* 2-way parallel cipher functions */
32*a04ea6f7SArd Biesheuvel asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src,
33*a04ea6f7SArd Biesheuvel 					bool xor);
34*a04ea6f7SArd Biesheuvel asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src);
35*a04ea6f7SArd Biesheuvel 
36*a04ea6f7SArd Biesheuvel /* 16-way parallel cipher functions (avx/aes-ni) */
37*a04ea6f7SArd Biesheuvel asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src);
38*a04ea6f7SArd Biesheuvel asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src);
39*a04ea6f7SArd Biesheuvel 
40*a04ea6f7SArd Biesheuvel asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src);
41*a04ea6f7SArd Biesheuvel 
camellia_enc_blk(const void * ctx,u8 * dst,const u8 * src)42*a04ea6f7SArd Biesheuvel static inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src)
43*a04ea6f7SArd Biesheuvel {
44*a04ea6f7SArd Biesheuvel 	__camellia_enc_blk(ctx, dst, src, false);
45*a04ea6f7SArd Biesheuvel }
46*a04ea6f7SArd Biesheuvel 
camellia_enc_blk_xor(const void * ctx,u8 * dst,const u8 * src)47*a04ea6f7SArd Biesheuvel static inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src)
48*a04ea6f7SArd Biesheuvel {
49*a04ea6f7SArd Biesheuvel 	__camellia_enc_blk(ctx, dst, src, true);
50*a04ea6f7SArd Biesheuvel }
51*a04ea6f7SArd Biesheuvel 
camellia_enc_blk_2way(const void * ctx,u8 * dst,const u8 * src)52*a04ea6f7SArd Biesheuvel static inline void camellia_enc_blk_2way(const void *ctx, u8 *dst,
53*a04ea6f7SArd Biesheuvel 					 const u8 *src)
54*a04ea6f7SArd Biesheuvel {
55*a04ea6f7SArd Biesheuvel 	__camellia_enc_blk_2way(ctx, dst, src, false);
56*a04ea6f7SArd Biesheuvel }
57*a04ea6f7SArd Biesheuvel 
camellia_enc_blk_xor_2way(const void * ctx,u8 * dst,const u8 * src)58*a04ea6f7SArd Biesheuvel static inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst,
59*a04ea6f7SArd Biesheuvel 					     const u8 *src)
60*a04ea6f7SArd Biesheuvel {
61*a04ea6f7SArd Biesheuvel 	__camellia_enc_blk_2way(ctx, dst, src, true);
62*a04ea6f7SArd Biesheuvel }
63*a04ea6f7SArd Biesheuvel 
64*a04ea6f7SArd Biesheuvel /* glue helpers */
65*a04ea6f7SArd Biesheuvel extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src);
66*a04ea6f7SArd Biesheuvel 
67*a04ea6f7SArd Biesheuvel #endif /* ASM_X86_CAMELLIA_H */
68