diff options
author | Jussi Kivilinna <jussi.kivilinna@mbnet.fi> | 2012-10-26 07:48:56 -0400 |
---|---|---|
committer | Herbert Xu <herbert@gondor.apana.org.au> | 2012-11-09 04:32:31 -0500 |
commit | cf582ccedad02eb9bfdcdb25adfc800dd117b428 (patch) | |
tree | 61337d49d10f40440da57a3ce49355b2b015124b /arch/x86/include/asm/crypto | |
parent | bf9c5181865f1cc12f934eac182bbd06438ffecc (diff) |
crypto: camellia-x86_64 - share common functions and move structures and function definitions to header file
Prepare camellia-x86_64 functions to be reused from AVX/AESNI implementation
module.
Signed-off-by: Jussi Kivilinna <jussi.kivilinna@mbnet.fi>
Acked-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'arch/x86/include/asm/crypto')
-rw-r--r-- | arch/x86/include/asm/crypto/camellia.h | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/arch/x86/include/asm/crypto/camellia.h b/arch/x86/include/asm/crypto/camellia.h new file mode 100644 index 000000000000..98038add801e --- /dev/null +++ b/arch/x86/include/asm/crypto/camellia.h | |||
@@ -0,0 +1,82 @@ | |||
1 | #ifndef ASM_X86_CAMELLIA_H | ||
2 | #define ASM_X86_CAMELLIA_H | ||
3 | |||
4 | #include <linux/kernel.h> | ||
5 | #include <linux/crypto.h> | ||
6 | |||
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 | ||
12 | |||
13 | struct camellia_ctx { | ||
14 | u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)]; | ||
15 | u32 key_length; | ||
16 | }; | ||
17 | |||
18 | struct camellia_lrw_ctx { | ||
19 | struct lrw_table_ctx lrw_table; | ||
20 | struct camellia_ctx camellia_ctx; | ||
21 | }; | ||
22 | |||
23 | struct camellia_xts_ctx { | ||
24 | struct camellia_ctx tweak_ctx; | ||
25 | struct camellia_ctx crypt_ctx; | ||
26 | }; | ||
27 | |||
28 | extern int __camellia_setkey(struct camellia_ctx *cctx, | ||
29 | const unsigned char *key, | ||
30 | unsigned int key_len, u32 *flags); | ||
31 | |||
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); | ||
35 | |||
36 | extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key, | ||
37 | unsigned int keylen); | ||
38 | |||
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); | ||
44 | |||
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); | ||
50 | |||
51 | static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst, | ||
52 | const u8 *src) | ||
53 | { | ||
54 | __camellia_enc_blk(ctx, dst, src, false); | ||
55 | } | ||
56 | |||
57 | static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst, | ||
58 | const u8 *src) | ||
59 | { | ||
60 | __camellia_enc_blk(ctx, dst, src, true); | ||
61 | } | ||
62 | |||
63 | static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst, | ||
64 | const u8 *src) | ||
65 | { | ||
66 | __camellia_enc_blk_2way(ctx, dst, src, false); | ||
67 | } | ||
68 | |||
69 | static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst, | ||
70 | const u8 *src) | ||
71 | { | ||
72 | __camellia_enc_blk_2way(ctx, dst, src, true); | ||
73 | } | ||
74 | |||
75 | /* glue helpers */ | ||
76 | extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src); | ||
77 | extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src, | ||
78 | le128 *iv); | ||
79 | extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src, | ||
80 | le128 *iv); | ||
81 | |||
82 | #endif /* ASM_X86_CAMELLIA_H */ | ||