delegated_attestation.c 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. * Copyright (c) 2022-2023, Arm Limited. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #include <delegated_attestation.h>
  8. #include <psa/client.h>
  9. #include <psa_manifest/sid.h>
  10. psa_status_t
  11. rse_delegated_attest_get_delegated_key(uint8_t ecc_curve,
  12. uint32_t key_bits,
  13. uint8_t *key_buf,
  14. size_t key_buf_size,
  15. size_t *key_size,
  16. uint32_t hash_algo)
  17. {
  18. psa_status_t status;
  19. psa_invec in_vec[] = {
  20. {&ecc_curve, sizeof(ecc_curve)},
  21. {&key_bits, sizeof(key_bits)},
  22. {&hash_algo, sizeof(hash_algo)}
  23. };
  24. psa_outvec out_vec[] = {
  25. {key_buf, key_buf_size}
  26. };
  27. if (key_size == NULL) {
  28. return PSA_ERROR_INVALID_ARGUMENT;
  29. }
  30. status = psa_call(RSE_DELEGATED_SERVICE_HANDLE,
  31. RSE_DELEGATED_ATTEST_GET_DELEGATED_KEY,
  32. in_vec, IOVEC_LEN(in_vec),
  33. out_vec, IOVEC_LEN(out_vec));
  34. if (status == PSA_SUCCESS) {
  35. *key_size = out_vec[0].len;
  36. }
  37. return status;
  38. }
  39. psa_status_t
  40. rse_delegated_attest_get_token(const uint8_t *dak_pub_hash,
  41. size_t dak_pub_hash_size,
  42. uint8_t *token_buf,
  43. size_t token_buf_size,
  44. size_t *token_size)
  45. {
  46. psa_status_t status;
  47. psa_invec in_vec[] = {
  48. {dak_pub_hash, dak_pub_hash_size}
  49. };
  50. psa_outvec out_vec[] = {
  51. {token_buf, token_buf_size}
  52. };
  53. if (token_size == NULL) {
  54. return PSA_ERROR_INVALID_ARGUMENT;
  55. }
  56. status = psa_call(RSE_DELEGATED_SERVICE_HANDLE,
  57. RSE_DELEGATED_ATTEST_GET_PLATFORM_TOKEN,
  58. in_vec, IOVEC_LEN(in_vec),
  59. out_vec, IOVEC_LEN(out_vec));
  60. if (status == PSA_SUCCESS) {
  61. *token_size = out_vec[0].len;
  62. }
  63. return status;
  64. }