162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci#ifndef ASM_X86_CAMELLIA_H 362306a36Sopenharmony_ci#define ASM_X86_CAMELLIA_H 462306a36Sopenharmony_ci 562306a36Sopenharmony_ci#include <crypto/b128ops.h> 662306a36Sopenharmony_ci#include <linux/crypto.h> 762306a36Sopenharmony_ci#include <linux/kernel.h> 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#define CAMELLIA_MIN_KEY_SIZE 16 1062306a36Sopenharmony_ci#define CAMELLIA_MAX_KEY_SIZE 32 1162306a36Sopenharmony_ci#define CAMELLIA_BLOCK_SIZE 16 1262306a36Sopenharmony_ci#define CAMELLIA_TABLE_BYTE_LEN 272 1362306a36Sopenharmony_ci#define CAMELLIA_PARALLEL_BLOCKS 2 1462306a36Sopenharmony_ci 1562306a36Sopenharmony_cistruct crypto_skcipher; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_cistruct camellia_ctx { 1862306a36Sopenharmony_ci u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)]; 1962306a36Sopenharmony_ci u32 key_length; 2062306a36Sopenharmony_ci}; 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ciextern int __camellia_setkey(struct camellia_ctx *cctx, 2362306a36Sopenharmony_ci const unsigned char *key, 2462306a36Sopenharmony_ci unsigned int key_len); 2562306a36Sopenharmony_ci 2662306a36Sopenharmony_ci/* regular block cipher functions */ 2762306a36Sopenharmony_ciasmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src, 2862306a36Sopenharmony_ci bool xor); 2962306a36Sopenharmony_ciasmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src); 3062306a36Sopenharmony_ci 3162306a36Sopenharmony_ci/* 2-way parallel cipher functions */ 3262306a36Sopenharmony_ciasmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src, 3362306a36Sopenharmony_ci bool xor); 3462306a36Sopenharmony_ciasmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src); 3562306a36Sopenharmony_ci 3662306a36Sopenharmony_ci/* 16-way parallel cipher functions (avx/aes-ni) */ 3762306a36Sopenharmony_ciasmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src); 3862306a36Sopenharmony_ciasmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src); 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ciasmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src); 4162306a36Sopenharmony_ci 4262306a36Sopenharmony_cistatic inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src) 4362306a36Sopenharmony_ci{ 4462306a36Sopenharmony_ci __camellia_enc_blk(ctx, dst, src, false); 4562306a36Sopenharmony_ci} 4662306a36Sopenharmony_ci 4762306a36Sopenharmony_cistatic inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src) 4862306a36Sopenharmony_ci{ 4962306a36Sopenharmony_ci __camellia_enc_blk(ctx, dst, src, true); 5062306a36Sopenharmony_ci} 5162306a36Sopenharmony_ci 5262306a36Sopenharmony_cistatic inline void camellia_enc_blk_2way(const void *ctx, u8 *dst, 5362306a36Sopenharmony_ci const u8 *src) 5462306a36Sopenharmony_ci{ 5562306a36Sopenharmony_ci __camellia_enc_blk_2way(ctx, dst, src, false); 5662306a36Sopenharmony_ci} 5762306a36Sopenharmony_ci 5862306a36Sopenharmony_cistatic inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst, 5962306a36Sopenharmony_ci const u8 *src) 6062306a36Sopenharmony_ci{ 6162306a36Sopenharmony_ci __camellia_enc_blk_2way(ctx, dst, src, true); 6262306a36Sopenharmony_ci} 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci/* glue helpers */ 6562306a36Sopenharmony_ciextern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src); 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ci#endif /* ASM_X86_CAMELLIA_H */ 68