rse_crypto_defs.h 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2023-2024, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef RSE_CRYPTO_DEFS_H
  8. #define RSE_CRYPTO_DEFS_H
  9. /* Declares types that encode errors, algorithms, key types, policies, etc. */
  10. #include "psa/crypto_types.h"
  11. /*
  12. * Value identifying export public key function API, used to dispatch the request
  13. * to the corresponding API implementation in the Crypto service backend.
  14. *
  15. */
  16. #define RSE_CRYPTO_EXPORT_PUBLIC_KEY_SID (uint16_t)(0x206)
  17. /*
  18. * The persistent key identifiers for RSE builtin keys.
  19. */
  20. enum rse_key_id_builtin_t {
  21. RSE_BUILTIN_KEY_ID_HOST_S_ROTPK = 0x7FFF816Cu,
  22. RSE_BUILTIN_KEY_ID_HOST_NS_ROTPK,
  23. RSE_BUILTIN_KEY_ID_HOST_CCA_ROTPK,
  24. };
  25. /*
  26. * This type is used to overcome a limitation within RSE firmware in the number of maximum
  27. * IOVECs it can use especially in psa_aead_encrypt and psa_aead_decrypt.
  28. */
  29. #define RSE_CRYPTO_MAX_NONCE_LENGTH (16u)
  30. struct rse_crypto_aead_pack_input {
  31. uint8_t nonce[RSE_CRYPTO_MAX_NONCE_LENGTH];
  32. uint32_t nonce_length;
  33. };
  34. /*
  35. * Structure used to pack non-pointer types in a call to PSA Crypto APIs
  36. */
  37. struct rse_crypto_pack_iovec {
  38. psa_key_id_t key_id; /* !< Key id */
  39. psa_algorithm_t alg; /* !< Algorithm */
  40. uint32_t op_handle; /*
  41. * !< Frontend context handle
  42. * associated to a multipart operation
  43. */
  44. uint32_t ad_length; /*
  45. * !< Additional Data length for
  46. * multipart AEAD
  47. */
  48. uint32_t plaintext_length; /*
  49. * !< Plaintext length for multipart
  50. * AEAD
  51. */
  52. struct rse_crypto_aead_pack_input aead_in; /*
  53. * !< Packs AEAD-related
  54. * inputs
  55. */
  56. uint16_t function_id; /*
  57. * !< Used to identify the function in the
  58. * API dispatcher to the service backend
  59. * See rse_crypto_func_sid for detail
  60. */
  61. uint16_t step; /* !< Key derivation step */
  62. union {
  63. size_t capacity; /* !< Key derivation capacity */
  64. uint64_t value; /*
  65. * !< Key derivation integer for
  66. * update
  67. */
  68. };
  69. };
  70. #endif /* RSE_CRYPTO_DEFS_H */