Linux 3.11-rc3
[cris-mirror.git] / arch / x86 / include / asm / crypto / camellia.h
blobbb93333d920027ebafca6832d44063a673764691
1 #ifndef ASM_X86_CAMELLIA_H
2 #define ASM_X86_CAMELLIA_H
4 #include <linux/kernel.h>
5 #include <linux/crypto.h>
7 #define CAMELLIA_MIN_KEY_SIZE 16
8 #define CAMELLIA_MAX_KEY_SIZE 32
9 #define CAMELLIA_BLOCK_SIZE 16
10 #define CAMELLIA_TABLE_BYTE_LEN 272
11 #define CAMELLIA_PARALLEL_BLOCKS 2
13 struct camellia_ctx {
14 u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
15 u32 key_length;
18 struct camellia_lrw_ctx {
19 struct lrw_table_ctx lrw_table;
20 struct camellia_ctx camellia_ctx;
23 struct camellia_xts_ctx {
24 struct camellia_ctx tweak_ctx;
25 struct camellia_ctx crypt_ctx;
28 extern int __camellia_setkey(struct camellia_ctx *cctx,
29 const unsigned char *key,
30 unsigned int key_len, u32 *flags);
32 extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
33 unsigned int keylen);
34 extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm);
36 extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
37 unsigned int keylen);
39 /* regular block cipher functions */
40 asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
41 const u8 *src, bool xor);
42 asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst,
43 const u8 *src);
45 /* 2-way parallel cipher functions */
46 asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
47 const u8 *src, bool xor);
48 asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst,
49 const u8 *src);
51 /* 16-way parallel cipher functions (avx/aes-ni) */
52 asmlinkage void camellia_ecb_enc_16way(struct camellia_ctx *ctx, u8 *dst,
53 const u8 *src);
54 asmlinkage void camellia_ecb_dec_16way(struct camellia_ctx *ctx, u8 *dst,
55 const u8 *src);
57 asmlinkage void camellia_cbc_dec_16way(struct camellia_ctx *ctx, u8 *dst,
58 const u8 *src);
59 asmlinkage void camellia_ctr_16way(struct camellia_ctx *ctx, u8 *dst,
60 const u8 *src, le128 *iv);
62 asmlinkage void camellia_xts_enc_16way(struct camellia_ctx *ctx, u8 *dst,
63 const u8 *src, le128 *iv);
64 asmlinkage void camellia_xts_dec_16way(struct camellia_ctx *ctx, u8 *dst,
65 const u8 *src, le128 *iv);
67 static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
68 const u8 *src)
70 __camellia_enc_blk(ctx, dst, src, false);
73 static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst,
74 const u8 *src)
76 __camellia_enc_blk(ctx, dst, src, true);
79 static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
80 const u8 *src)
82 __camellia_enc_blk_2way(ctx, dst, src, false);
85 static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst,
86 const u8 *src)
88 __camellia_enc_blk_2way(ctx, dst, src, true);
91 /* glue helpers */
92 extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src);
93 extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src,
94 le128 *iv);
95 extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
96 le128 *iv);
98 extern void camellia_xts_enc(void *ctx, u128 *dst, const u128 *src, le128 *iv);
99 extern void camellia_xts_dec(void *ctx, u128 *dst, const u128 *src, le128 *iv);
101 #endif /* ASM_X86_CAMELLIA_H */