crypto_qti_virt.h 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2020, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _CRYPTO_QTI_VIRT_H
  7. #define _CRYPTO_QTI_VIRT_H
  8. #include <linux/errno.h>
  9. #include <linux/types.h>
  10. #include <linux/blk-crypto.h>
  11. //#include <linux/blk-crypto-profile.h>
  12. //#define RAW_SECRET_SIZE 32
  13. #if IS_ENABLED(CONFIG_QTI_CRYPTO_VIRTUALIZATION)
  14. /**
  15. * crypto_qti_virt_program_key() - will send key and virtual slot
  16. * info to Back end (BE) and BE will program the key into specified
  17. * keyslot in the inline encryption hardware.
  18. *
  19. * @blk_crypto_key: Actual key or wrapped key
  20. * @slot: virtual slot
  21. *
  22. * Return: zero on success, else a -errno value
  23. */
  24. int crypto_qti_virt_program_key(const struct blk_crypto_key *key,
  25. unsigned int slot);
  26. /**
  27. * crypto_qti_virt_invalidate_key() - will virtual slot
  28. * info to Back end (BE) and BE will Evict key from the
  29. * specified keyslot in the hardware
  30. *
  31. * @slot: virtual slot
  32. *
  33. * Return: zero on success, else a -errno value
  34. */
  35. int crypto_qti_virt_invalidate_key(unsigned int slot);
  36. /**
  37. * crypto_qti_virt_derive_raw_secret_platform() - Derive
  38. * software secret from wrapped key
  39. *
  40. * @wrapped_key: The wrapped key
  41. * @wrapped_key_size: Size of the wrapped key in bytes
  42. * @secret: (output) the software secret
  43. * @secret_size: (output) the number of secret bytes to derive
  44. *
  45. * Return: zero on success, else a -errno value
  46. */
  47. int crypto_qti_virt_derive_raw_secret_platform(const u8 *wrapped_key,
  48. unsigned int wrapped_key_size, u8 *secret,
  49. unsigned int secret_size);
  50. /**
  51. * crypto_qti_virt_ice_get_info() - Determines the
  52. * total number of available slot for virtual machine
  53. *
  54. * @total_num_slots: its an out param and this will update
  55. * with max number of slots.
  56. *
  57. * Return: zero on success, else a -errno value
  58. */
  59. int crypto_qti_virt_ice_get_info(uint32_t *total_num_slots);
  60. int crypto_qti_virt_get_crypto_capabilities(unsigned int *crypto_modes_supported,
  61. uint32_t crypto_array_size);
  62. #else
  63. static inline int crypto_qti_virt_program_key(const struct blk_crypto_key *key,
  64. unsigned int slot)
  65. {
  66. return -EOPNOTSUPP;
  67. }
  68. static inline int crypto_qti_virt_invalidate_key(unsigned int slot)
  69. {
  70. return -EOPNOTSUPP;
  71. }
  72. static inline int crypto_qti_virt_derive_raw_secret_platform(
  73. const u8 *wrapped_key,
  74. unsigned int wrapped_key_size, u8 *secret,
  75. unsigned int secret_size)
  76. {
  77. return -EOPNOTSUPP;
  78. }
  79. static inline int crypto_qti_virt_ice_get_info(uint32_t *total_num_slots)
  80. {
  81. return -EOPNOTSUPP;
  82. }
  83. static inline int crypto_qti_virt_get_crypto_capabilities(unsigned int *crypto_modes_supported,
  84. uint32_t crypto_array_size)
  85. {
  86. return -EOPNOTSUPP;
  87. }
  88. #endif /* CONFIG_QTI_CRYPTO_VIRTUALIZATION */
  89. #endif /*_CRYPTO_QTI_VIRT_H */