tme_hwkm_master.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  4. */
  5. #ifndef _TME_HWKM_MASTER_H_
  6. #define _TME_HWKM_MASTER_H_
  7. #include <linux/tme_hwkm_master_defs.h>
  8. /**
  9. * API functions
  10. */
  11. /**
  12. * Clear a Key Table entry.
  13. *
  14. * @param [in] key_id The ID of the key to clear.
  15. * @param [out] err_info Extended error info
  16. *
  17. * @return 0 if successful, error code otherwise.
  18. */
  19. uint32_t tme_hwkm_master_clearkey(uint32_t key_id,
  20. struct tme_ext_err_info *err_info);
  21. /**
  22. * Generate a random key with an associated policy.
  23. *
  24. * @param [in] key_id The ID of the key to be generated.
  25. * @param [in] policy The policy specifying the key to be generated.
  26. * @param [in] cred_slot Credential slot to which this key will be bound.
  27. * @param [out] err_info Extended error info
  28. *
  29. * @return 0 if successful, error code otherwise.
  30. */
  31. uint32_t tme_hwkm_master_generatekey(uint32_t key_id,
  32. struct tme_key_policy *policy,
  33. uint32_t cred_slot,
  34. struct tme_ext_err_info *err_info);
  35. /**
  36. * Derive a KEY using either HKDF or NIST algorithms.
  37. *
  38. * @param [in] key_id The ID of the key to be derived.
  39. * @param [in] kdf_info Specifies how the key is to be derived
  40. * and the properties of the derived key.
  41. * @param [in] cred_slot Credential slot to which this key will be bound.
  42. * @param [out] err_info Extended error info
  43. *
  44. * @return 0 if successful, error code otherwise.
  45. */
  46. uint32_t tme_hwkm_master_derivekey(uint32_t key_id,
  47. struct tme_kdf_spec *kdf_info,
  48. uint32_t cred_slot,
  49. struct tme_ext_err_info *err_info);
  50. /**
  51. * Wrap a key so that it can be safely moved outside the TME.
  52. *
  53. * @param [in] kwkey_id Denotes a key, already present in the
  54. * Key Table, to be used to secure the target key.
  55. * @param [in] targetkey_id Denotes the key to be wrapped.
  56. * @param [in] cred_slot Credential slot to which this key is bound.
  57. * @param [out] wrapped Buffer for wrapped key output from response
  58. * @param [out] err_info Extended error info
  59. *
  60. * @return 0 if successful, error code otherwise.
  61. */
  62. uint32_t tme_hwkm_master_wrapkey(uint32_t key_id,
  63. uint32_t targetkey_id,
  64. uint32_t cred_slot,
  65. struct tme_wrapped_key *wrapped,
  66. struct tme_ext_err_info *err_info);
  67. /**
  68. * Unwrap a key from outside the TME and store in the Key Table.
  69. *
  70. * @param [in] key_id The ID of the key to be unwrapped.
  71. * @param [in] kwkey_id Denotes a key, already present in the
  72. * Key Table, to be used to unwrap the key.
  73. * @param [in] cred_slot Credential slot to which this key will be bound.
  74. * @param [in] wrapped The key to be unwrapped.
  75. * @param [out] err_info Extended error info
  76. *
  77. * @return 0 if successful, error code otherwise.
  78. */
  79. uint32_t tme_hwkm_master_unwrapkey(uint32_t key_id,
  80. uint32_t kwkey_id,
  81. uint32_t cred_slot,
  82. struct tme_wrapped_key *wrapped,
  83. struct tme_ext_err_info *err_info);
  84. /**
  85. * Import a plaintext key from outside the TME and store in the Key Table.
  86. *
  87. * @param [in] key_id The ID of the key to be imported.
  88. * @param [in] policy The Key Policy to be associated with the key.
  89. * @param [in] keyMaterial The plaintext key material.
  90. * @param [in] cred_slot Credential slot to which this key will be bound.
  91. * @param [out] err_info Extended error info
  92. *
  93. * @return 0 if successful, error code otherwise.
  94. */
  95. uint32_t tme_hwkm_master_importkey(uint32_t key_id,
  96. struct tme_key_policy *policy,
  97. struct tme_plaintext_key *key_material,
  98. uint32_t cred_slot,
  99. struct tme_ext_err_info *err_info);
  100. /**
  101. * Broadcast Transport Key to HWKM slaves.
  102. *
  103. * @param [out] err_info Extended error info
  104. *
  105. * @return 0 if successful, error code otherwise.
  106. */
  107. uint32_t tme_hwkm_master_broadcast_transportkey(
  108. struct tme_ext_err_info *err_info);
  109. #endif /* _TME_HWKM_MASTER_H_ */