camellia.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef ASM_X86_CAMELLIA_H
  2. #define ASM_X86_CAMELLIA_H
  3. #include <linux/kernel.h>
  4. #include <linux/crypto.h>
  5. #define CAMELLIA_MIN_KEY_SIZE 16
  6. #define CAMELLIA_MAX_KEY_SIZE 32
  7. #define CAMELLIA_BLOCK_SIZE 16
  8. #define CAMELLIA_TABLE_BYTE_LEN 272
  9. #define CAMELLIA_PARALLEL_BLOCKS 2
  10. struct camellia_ctx {
  11. u64 key_table[CAMELLIA_TABLE_BYTE_LEN / sizeof(u64)];
  12. u32 key_length;
  13. };
  14. struct camellia_lrw_ctx {
  15. struct lrw_table_ctx lrw_table;
  16. struct camellia_ctx camellia_ctx;
  17. };
  18. struct camellia_xts_ctx {
  19. struct camellia_ctx tweak_ctx;
  20. struct camellia_ctx crypt_ctx;
  21. };
  22. extern int __camellia_setkey(struct camellia_ctx *cctx,
  23. const unsigned char *key,
  24. unsigned int key_len, u32 *flags);
  25. extern int lrw_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
  26. unsigned int keylen);
  27. extern void lrw_camellia_exit_tfm(struct crypto_tfm *tfm);
  28. extern int xts_camellia_setkey(struct crypto_tfm *tfm, const u8 *key,
  29. unsigned int keylen);
  30. /* regular block cipher functions */
  31. asmlinkage void __camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
  32. const u8 *src, bool xor);
  33. asmlinkage void camellia_dec_blk(struct camellia_ctx *ctx, u8 *dst,
  34. const u8 *src);
  35. /* 2-way parallel cipher functions */
  36. asmlinkage void __camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
  37. const u8 *src, bool xor);
  38. asmlinkage void camellia_dec_blk_2way(struct camellia_ctx *ctx, u8 *dst,
  39. const u8 *src);
  40. static inline void camellia_enc_blk(struct camellia_ctx *ctx, u8 *dst,
  41. const u8 *src)
  42. {
  43. __camellia_enc_blk(ctx, dst, src, false);
  44. }
  45. static inline void camellia_enc_blk_xor(struct camellia_ctx *ctx, u8 *dst,
  46. const u8 *src)
  47. {
  48. __camellia_enc_blk(ctx, dst, src, true);
  49. }
  50. static inline void camellia_enc_blk_2way(struct camellia_ctx *ctx, u8 *dst,
  51. const u8 *src)
  52. {
  53. __camellia_enc_blk_2way(ctx, dst, src, false);
  54. }
  55. static inline void camellia_enc_blk_xor_2way(struct camellia_ctx *ctx, u8 *dst,
  56. const u8 *src)
  57. {
  58. __camellia_enc_blk_2way(ctx, dst, src, true);
  59. }
  60. /* glue helpers */
  61. extern void camellia_decrypt_cbc_2way(void *ctx, u128 *dst, const u128 *src);
  62. extern void camellia_crypt_ctr(void *ctx, u128 *dst, const u128 *src,
  63. le128 *iv);
  64. extern void camellia_crypt_ctr_2way(void *ctx, u128 *dst, const u128 *src,
  65. le128 *iv);
  66. #endif /* ASM_X86_CAMELLIA_H */