dice_protection_environment.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef DICE_PROTECTION_ENVIRONMENT_H
  8. #define DICE_PROTECTION_ENVIRONMENT_H
  9. #include <stdbool.h>
  10. #include <stddef.h>
  11. #include <stdint.h>
  12. #include <dice.h>
  13. /* Additional defines for max size limit. These limits are set by DPE in RSE. */
  14. #define DICE_AUTHORITY_DESCRIPTOR_MAX_SIZE 64
  15. #define DICE_CONFIG_DESCRIPTOR_MAX_SIZE 64
  16. #define DICE_CODE_DESCRIPTOR_MAX_SIZE 32
  17. typedef int32_t dpe_error_t;
  18. #define DPE_NO_ERROR ((dpe_error_t)0)
  19. #define DPE_INTERNAL_ERROR ((dpe_error_t)1)
  20. #define DPE_INVALID_COMMAND ((dpe_error_t)2)
  21. #define DPE_INVALID_ARGUMENT ((dpe_error_t)3)
  22. #define DPE_ARGUMENT_NOT_SUPPORTED ((dpe_error_t)4)
  23. #define DPE_SESSION_EXHAUSTED ((dpe_error_t)5)
  24. /* Custom values in RSE based DPE implementation */
  25. #define DPE_INSUFFICIENT_MEMORY ((dpe_error_t)128)
  26. #define DPE_ERR_CBOR_FORMATTING ((dpe_error_t)129)
  27. /**
  28. * Client facing API. Parameters are according to the DPE spec version r0.9
  29. *
  30. * \brief Performs the DICE computation to derive a new context and optionally
  31. * creates an intermediate certificate. Software component measurement
  32. * must be provided in dice_inputs.
  33. *
  34. * \param[in] context_handle Input context handle for the DPE
  35. * context.
  36. * \param[in] cert_id Logical certificate id to which derived
  37. * context belongs to.
  38. * \param[in] retain_parent_context Flag to indicate whether to retain the
  39. * parent context. True only if a client
  40. * will call further DPE commands on the
  41. * same context.
  42. * \param[in] allow_new_context_to_derive Flag to indicate whether derived context
  43. * can derive further. True only if the
  44. * new context will load further components.
  45. * \param[in] create_certificate Flag to indicate whether to create an
  46. * intermediate certificate. True only if
  47. * it is the last component in the layer.
  48. * \param[in] dice_inputs DICE input values.
  49. * \param[in] target_locality Identifies the locality to which the
  50. * derived context will be bound. Could be
  51. * MHU id.
  52. * \param[in] return_certificate Indicates whether to return the generated
  53. * certificate when create_certificate is true.
  54. * \param[in] allow_new_context_to_export Indicates whether the DPE permits export of
  55. * the CDI from the newly derived context.
  56. * \param[in] export_cdi Indicates whether to export derived CDI.
  57. * \param[out] new_context_handle New handle for the derived context.
  58. * \param[out] new_parent_context_handle New handle for the parent context.
  59. * \param[out] new_certificate_buf If create_certificate and return_certificate
  60. * are both true, this argument holds the new
  61. * certificate generated for the new context
  62. * \param[in] new_certificate_buf_size Size of the allocated buffer for
  63. * new certificate.
  64. * \param[out] new_certificate_actual_size Actual size of the new certificate.
  65. * \param[out] exported_cdi_buf If export_cdi is true, this is the
  66. * exported CDI value.
  67. * \param[in] exported_cdi_buf_size Size of the allocated buffer for
  68. * exported cdi.
  69. * \param[out] exported_cdi_actual_size Actual size of the exported cdi.
  70. *
  71. * \return Returns error code of type dpe_error_t
  72. */
  73. dpe_error_t dpe_derive_context(int context_handle,
  74. uint32_t cert_id,
  75. bool retain_parent_context,
  76. bool allow_new_context_to_derive,
  77. bool create_certificate,
  78. const DiceInputValues *dice_inputs,
  79. int32_t target_locality,
  80. bool return_certificate,
  81. bool allow_new_context_to_export,
  82. bool export_cdi,
  83. int *new_context_handle,
  84. int *new_parent_context_handle,
  85. uint8_t *new_certificate_buf,
  86. size_t new_certificate_buf_size,
  87. size_t *new_certificate_actual_size,
  88. uint8_t *exported_cdi_buf,
  89. size_t exported_cdi_buf_size,
  90. size_t *exported_cdi_actual_size);
  91. #endif /* DICE_PROTECTION_ENVIRONMENT_H */