crypto: remove CRYPTO_TFM_RES_BAD_KEY_LEN
[linux-block.git] / arch / x86 / include / asm / crypto / camellia.h
CommitLineData
b2441318 1/* SPDX-License-Identifier: GPL-2.0 */
cf582cce
JK
2#ifndef ASM_X86_CAMELLIA_H
3#define ASM_X86_CAMELLIA_H
4
451cc493 5#include <crypto/b128ops.h>
cf582cce 6#include <linux/crypto.h>
451cc493 7#include <linux/kernel.h>
cf582cce
JK
8
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
14
44893bc2
EB
15struct crypto_skcipher;
16
cf582cce
JK
17struct camellia_ctx {
18 u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
19 u32 key_length;
20};
21
cf582cce
JK
22struct camellia_xts_ctx {
23 struct camellia_ctx tweak_ctx;
24 struct camellia_ctx crypt_ctx;
25};
26
27extern int __camellia_setkey(struct camellia_ctx *cctx,
28 const unsigned char *key,
674f368a 29 unsigned int key_len);
cf582cce 30
44893bc2 31extern int xts_camellia_setkey(struct crypto_skcipher *tfm, const u8 *key,
cf582cce
JK
32 unsigned int keylen);
33
34/* regular block cipher functions */
9c1e8836
KC
35asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src,
36 bool xor);
37asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src);
cf582cce
JK
38
39/* 2-way parallel cipher functions */
9c1e8836
KC
40asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src,
41 bool xor);
42asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src);
cf582cce 43
f3f935a7 44/* 16-way parallel cipher functions (avx/aes-ni) */
9c1e8836
KC
45asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src);
46asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src);
47
48asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src);
49asmlinkage void camellia_ctr_16way(const void *ctx, u8 *dst, const u8 *src,
50 le128 *iv);
51
52asmlinkage void camellia_xts_enc_16way(const void *ctx, u8 *dst, const u8 *src,
53 le128 *iv);
54asmlinkage void camellia_xts_dec_16way(const void *ctx, u8 *dst, const u8 *src,
55 le128 *iv);
56
57static inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src)
cf582cce
JK
58{
59 __camellia_enc_blk(ctx, dst, src, false);
60}
61
9c1e8836 62static inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src)
cf582cce
JK
63{
64 __camellia_enc_blk(ctx, dst, src, true);
65}
66
9c1e8836 67static inline void camellia_enc_blk_2way(const void *ctx, u8 *dst,
cf582cce
JK
68 const u8 *src)
69{
70 __camellia_enc_blk_2way(ctx, dst, src, false);
71}
72
9c1e8836 73static inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst,
cf582cce
JK
74 const u8 *src)
75{
76 __camellia_enc_blk_2way(ctx, dst, src, true);
77}
78
79/* glue helpers */
9c1e8836
KC
80extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src);
81extern void camellia_crypt_ctr(const void *ctx, u8 *dst, const u8 *src,
cf582cce 82 le128 *iv);
9c1e8836 83extern void camellia_crypt_ctr_2way(const void *ctx, u8 *dst, const u8 *src,
cf582cce
JK
84 le128 *iv);
85
9c1e8836
KC
86extern void camellia_xts_enc(const void *ctx, u8 *dst, const u8 *src,
87 le128 *iv);
88extern void camellia_xts_dec(const void *ctx, u8 *dst, const u8 *src,
89 le128 *iv);
f3f935a7 90
cf582cce 91#endif /* ASM_X86_CAMELLIA_H */