cptvf_algs.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2016 Cavium, Inc.
  4. */
  5. #ifndef _CPTVF_ALGS_H_
  6. #define _CPTVF_ALGS_H_
  7. #include "request_manager.h"
  8. #define MAX_DEVICES 16
  9. #define MAJOR_OP_FC 0x33
  10. #define MAX_ENC_KEY_SIZE 32
  11. #define MAX_HASH_KEY_SIZE 64
  12. #define MAX_KEY_SIZE (MAX_ENC_KEY_SIZE + MAX_HASH_KEY_SIZE)
  13. #define CONTROL_WORD_LEN 8
  14. #define KEY2_OFFSET 48
  15. #define DMA_MODE_FLAG(dma_mode) \
  16. (((dma_mode) == DMA_GATHER_SCATTER) ? (1 << 7) : 0)
  17. enum req_type {
  18. AE_CORE_REQ,
  19. SE_CORE_REQ,
  20. };
  21. enum cipher_type {
  22. DES3_CBC = 0x1,
  23. DES3_ECB = 0x2,
  24. AES_CBC = 0x3,
  25. AES_ECB = 0x4,
  26. AES_CFB = 0x5,
  27. AES_CTR = 0x6,
  28. AES_GCM = 0x7,
  29. AES_XTS = 0x8
  30. };
  31. enum aes_type {
  32. AES_128_BIT = 0x1,
  33. AES_192_BIT = 0x2,
  34. AES_256_BIT = 0x3
  35. };
  36. union encr_ctrl {
  37. u64 flags;
  38. struct {
  39. #if defined(__BIG_ENDIAN_BITFIELD)
  40. u64 enc_cipher:4;
  41. u64 reserved1:1;
  42. u64 aes_key:2;
  43. u64 iv_source:1;
  44. u64 hash_type:4;
  45. u64 reserved2:3;
  46. u64 auth_input_type:1;
  47. u64 mac_len:8;
  48. u64 reserved3:8;
  49. u64 encr_offset:16;
  50. u64 iv_offset:8;
  51. u64 auth_offset:8;
  52. #else
  53. u64 auth_offset:8;
  54. u64 iv_offset:8;
  55. u64 encr_offset:16;
  56. u64 reserved3:8;
  57. u64 mac_len:8;
  58. u64 auth_input_type:1;
  59. u64 reserved2:3;
  60. u64 hash_type:4;
  61. u64 iv_source:1;
  62. u64 aes_key:2;
  63. u64 reserved1:1;
  64. u64 enc_cipher:4;
  65. #endif
  66. } e;
  67. };
  68. struct cvm_cipher {
  69. const char *name;
  70. u8 value;
  71. };
  72. struct enc_context {
  73. union encr_ctrl enc_ctrl;
  74. u8 encr_key[32];
  75. u8 encr_iv[16];
  76. };
  77. struct fchmac_context {
  78. u8 ipad[64];
  79. u8 opad[64]; /* or OPAD */
  80. };
  81. struct fc_context {
  82. struct enc_context enc;
  83. struct fchmac_context hmac;
  84. };
  85. struct cvm_enc_ctx {
  86. u32 key_len;
  87. u8 enc_key[MAX_KEY_SIZE];
  88. u8 cipher_type:4;
  89. u8 key_type:2;
  90. };
  91. struct cvm_des3_ctx {
  92. u32 key_len;
  93. u8 des3_key[MAX_KEY_SIZE];
  94. };
  95. struct cvm_req_ctx {
  96. struct cpt_request_info cpt_req;
  97. u64 control_word;
  98. struct fc_context fctx;
  99. };
  100. int cptvf_do_request(void *cptvf, struct cpt_request_info *req);
  101. #endif /*_CPTVF_ALGS_H_*/