camellia.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. #ifndef ASM_X86_CAMELLIA_H
  3. #define ASM_X86_CAMELLIA_H
  4. #include <crypto/b128ops.h>
  5. #include <linux/crypto.h>
  6. #include <linux/kernel.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
  12. struct crypto_skcipher;
  13. struct camellia_ctx {
  14. u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
  15. u32 key_length;
  16. };
  17. extern int __camellia_setkey(struct camellia_ctx *cctx,
  18. const unsigned char *key,
  19. unsigned int key_len);
  20. /* regular block cipher functions */
  21. asmlinkage void __camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src,
  22. bool xor);
  23. asmlinkage void camellia_dec_blk(const void *ctx, u8 *dst, const u8 *src);
  24. /* 2-way parallel cipher functions */
  25. asmlinkage void __camellia_enc_blk_2way(const void *ctx, u8 *dst, const u8 *src,
  26. bool xor);
  27. asmlinkage void camellia_dec_blk_2way(const void *ctx, u8 *dst, const u8 *src);
  28. /* 16-way parallel cipher functions (avx/aes-ni) */
  29. asmlinkage void camellia_ecb_enc_16way(const void *ctx, u8 *dst, const u8 *src);
  30. asmlinkage void camellia_ecb_dec_16way(const void *ctx, u8 *dst, const u8 *src);
  31. asmlinkage void camellia_cbc_dec_16way(const void *ctx, u8 *dst, const u8 *src);
  32. static inline void camellia_enc_blk(const void *ctx, u8 *dst, const u8 *src)
  33. {
  34. __camellia_enc_blk(ctx, dst, src, false);
  35. }
  36. static inline void camellia_enc_blk_xor(const void *ctx, u8 *dst, const u8 *src)
  37. {
  38. __camellia_enc_blk(ctx, dst, src, true);
  39. }
  40. static inline void camellia_enc_blk_2way(const void *ctx, u8 *dst,
  41. const u8 *src)
  42. {
  43. __camellia_enc_blk_2way(ctx, dst, src, false);
  44. }
  45. static inline void camellia_enc_blk_xor_2way(const void *ctx, u8 *dst,
  46. const u8 *src)
  47. {
  48. __camellia_enc_blk_2way(ctx, dst, src, true);
  49. }
  50. /* glue helpers */
  51. extern void camellia_decrypt_cbc_2way(const void *ctx, u8 *dst, const u8 *src);
  52. #endif /* ASM_X86_CAMELLIA_H */