Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 #ifndef ASM_X86_CAMELLIA_H
0003 #define ASM_X86_CAMELLIA_H
0004 
0005 #include <crypto/b128ops.h>
0006 #include <linux/crypto.h>
0007 #include <linux/kernel.h>
0008 
0009 #define CAMELLIA_MIN_KEY_SIZE   16
0010 #define CAMELLIA_MAX_KEY_SIZE   32
0011 #define CAMELLIA_BLOCK_SIZE 16
0012 #define CAMELLIA_TABLE_BYTE_LEN 272
0013 #define CAMELLIA_PARALLEL_BLOCKS 2
0014 
0015 struct crypto_skcipher;
0016 
0017 struct camellia_ctx {
0018     u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
0019     u32 key_length;
0020 };
0021 
0022 extern int __camellia_setkey(struct camellia_ctx *cctx,
0023                  const unsigned char *key,
0024                  unsigned int key_len);
0025 
0026 /* regular block cipher functions */
0027 asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src,
0028                    bool xor);
0029 asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src);
0030 
0031 /* 2-way parallel cipher functions */
0032 asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src,
0033                     bool xor);
0034 asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src);
0035 
0036 /* 16-way parallel cipher functions (avx/aes-ni) */
0037 asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src);
0038 asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src);
0039 
0040 asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src);
0041 
0042 static inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src)
0043 {
0044     __camellia_enc_blk(ctx, dst, src, false);
0045 }
0046 
0047 static inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src)
0048 {
0049     __camellia_enc_blk(ctx, dst, src, true);
0050 }
0051 
0052 static inline void camellia_enc_blk_2way(const void *ctx, u8 *dst,
0053                      const u8 *src)
0054 {
0055     __camellia_enc_blk_2way(ctx, dst, src, false);
0056 }
0057 
0058 static inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst,
0059                          const u8 *src)
0060 {
0061     __camellia_enc_blk_2way(ctx, dst, src, true);
0062 }
0063 
0064 /* glue helpers */
0065 extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src);
0066 
0067 #endif /* ASM_X86_CAMELLIA_H */