cc_crypto_ctx.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* Copyright (C) 2012-2019 ARM Limited (or its affiliates). */
  3. #ifndef _CC_CRYPTO_CTX_H_
  4. #define _CC_CRYPTO_CTX_H_
  5. #include <linux/types.h>
  6. #define CC_DRV_DES_IV_SIZE 8
  7. #define CC_DRV_DES_BLOCK_SIZE 8
  8. #define CC_DRV_DES_ONE_KEY_SIZE 8
  9. #define CC_DRV_DES_DOUBLE_KEY_SIZE 16
  10. #define CC_DRV_DES_TRIPLE_KEY_SIZE 24
  11. #define CC_DRV_DES_KEY_SIZE_MAX CC_DRV_DES_TRIPLE_KEY_SIZE
  12. #define CC_AES_IV_SIZE 16
  13. #define CC_AES_IV_SIZE_WORDS (CC_AES_IV_SIZE >> 2)
  14. #define CC_AES_BLOCK_SIZE 16
  15. #define CC_AES_BLOCK_SIZE_WORDS 4
  16. #define CC_AES_128_BIT_KEY_SIZE 16
  17. #define CC_AES_128_BIT_KEY_SIZE_WORDS (CC_AES_128_BIT_KEY_SIZE >> 2)
  18. #define CC_AES_192_BIT_KEY_SIZE 24
  19. #define CC_AES_192_BIT_KEY_SIZE_WORDS (CC_AES_192_BIT_KEY_SIZE >> 2)
  20. #define CC_AES_256_BIT_KEY_SIZE 32
  21. #define CC_AES_256_BIT_KEY_SIZE_WORDS (CC_AES_256_BIT_KEY_SIZE >> 2)
  22. #define CC_AES_KEY_SIZE_MAX CC_AES_256_BIT_KEY_SIZE
  23. #define CC_AES_KEY_SIZE_WORDS_MAX (CC_AES_KEY_SIZE_MAX >> 2)
  24. #define CC_MD5_DIGEST_SIZE 16
  25. #define CC_SHA1_DIGEST_SIZE 20
  26. #define CC_SHA224_DIGEST_SIZE 28
  27. #define CC_SHA256_DIGEST_SIZE 32
  28. #define CC_SHA256_DIGEST_SIZE_IN_WORDS 8
  29. #define CC_SHA384_DIGEST_SIZE 48
  30. #define CC_SHA512_DIGEST_SIZE 64
  31. #define CC_SHA1_BLOCK_SIZE 64
  32. #define CC_SHA1_BLOCK_SIZE_IN_WORDS 16
  33. #define CC_MD5_BLOCK_SIZE 64
  34. #define CC_MD5_BLOCK_SIZE_IN_WORDS 16
  35. #define CC_SHA224_BLOCK_SIZE 64
  36. #define CC_SHA256_BLOCK_SIZE 64
  37. #define CC_SHA256_BLOCK_SIZE_IN_WORDS 16
  38. #define CC_SHA1_224_256_BLOCK_SIZE 64
  39. #define CC_SHA384_BLOCK_SIZE 128
  40. #define CC_SHA512_BLOCK_SIZE 128
  41. #define CC_DIGEST_SIZE_MAX CC_SHA512_DIGEST_SIZE
  42. #define CC_HASH_BLOCK_SIZE_MAX CC_SHA512_BLOCK_SIZE /*1024b*/
  43. #define CC_HMAC_BLOCK_SIZE_MAX CC_HASH_BLOCK_SIZE_MAX
  44. #define CC_DRV_ALG_MAX_BLOCK_SIZE CC_HASH_BLOCK_SIZE_MAX
  45. #define CC_CPP_NUM_SLOTS 8
  46. #define CC_CPP_NUM_ALGS 2
  47. enum cc_cpp_alg {
  48. CC_CPP_SM4 = 1,
  49. CC_CPP_AES = 0
  50. };
  51. enum drv_engine_type {
  52. DRV_ENGINE_NULL = 0,
  53. DRV_ENGINE_AES = 1,
  54. DRV_ENGINE_DES = 2,
  55. DRV_ENGINE_HASH = 3,
  56. DRV_ENGINE_RC4 = 4,
  57. DRV_ENGINE_DOUT = 5,
  58. DRV_ENGINE_RESERVE32B = S32_MAX,
  59. };
  60. enum drv_crypto_alg {
  61. DRV_CRYPTO_ALG_NULL = -1,
  62. DRV_CRYPTO_ALG_AES = 0,
  63. DRV_CRYPTO_ALG_DES = 1,
  64. DRV_CRYPTO_ALG_HASH = 2,
  65. DRV_CRYPTO_ALG_C2 = 3,
  66. DRV_CRYPTO_ALG_HMAC = 4,
  67. DRV_CRYPTO_ALG_AEAD = 5,
  68. DRV_CRYPTO_ALG_BYPASS = 6,
  69. DRV_CRYPTO_ALG_NUM = 7,
  70. DRV_CRYPTO_ALG_RESERVE32B = S32_MAX
  71. };
  72. enum drv_crypto_direction {
  73. DRV_CRYPTO_DIRECTION_NULL = -1,
  74. DRV_CRYPTO_DIRECTION_ENCRYPT = 0,
  75. DRV_CRYPTO_DIRECTION_DECRYPT = 1,
  76. DRV_CRYPTO_DIRECTION_DECRYPT_ENCRYPT = 3,
  77. DRV_CRYPTO_DIRECTION_RESERVE32B = S32_MAX
  78. };
  79. enum drv_cipher_mode {
  80. DRV_CIPHER_NULL_MODE = -1,
  81. DRV_CIPHER_ECB = 0,
  82. DRV_CIPHER_CBC = 1,
  83. DRV_CIPHER_CTR = 2,
  84. DRV_CIPHER_CBC_MAC = 3,
  85. DRV_CIPHER_XTS = 4,
  86. DRV_CIPHER_XCBC_MAC = 5,
  87. DRV_CIPHER_OFB = 6,
  88. DRV_CIPHER_CMAC = 7,
  89. DRV_CIPHER_CCM = 8,
  90. DRV_CIPHER_CBC_CTS = 11,
  91. DRV_CIPHER_GCTR = 12,
  92. DRV_CIPHER_ESSIV = 13,
  93. DRV_CIPHER_BITLOCKER = 14,
  94. DRV_CIPHER_RESERVE32B = S32_MAX
  95. };
  96. enum drv_hash_mode {
  97. DRV_HASH_NULL = -1,
  98. DRV_HASH_SHA1 = 0,
  99. DRV_HASH_SHA256 = 1,
  100. DRV_HASH_SHA224 = 2,
  101. DRV_HASH_SHA512 = 3,
  102. DRV_HASH_SHA384 = 4,
  103. DRV_HASH_MD5 = 5,
  104. DRV_HASH_CBC_MAC = 6,
  105. DRV_HASH_XCBC_MAC = 7,
  106. DRV_HASH_CMAC = 8,
  107. DRV_HASH_SM3 = 9,
  108. DRV_HASH_MODE_NUM = 10,
  109. DRV_HASH_RESERVE32B = S32_MAX
  110. };
  111. enum drv_hash_hw_mode {
  112. DRV_HASH_HW_MD5 = 0,
  113. DRV_HASH_HW_SHA1 = 1,
  114. DRV_HASH_HW_SHA256 = 2,
  115. DRV_HASH_HW_SHA224 = 10,
  116. DRV_HASH_HW_SHA512 = 4,
  117. DRV_HASH_HW_SHA384 = 12,
  118. DRV_HASH_HW_GHASH = 6,
  119. DRV_HASH_HW_SM3 = 14,
  120. DRV_HASH_HW_RESERVE32B = S32_MAX
  121. };
  122. #endif /* _CC_CRYPTO_CTX_H_ */