cca_attestation.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (c) 2024, Arm Limited and Contributors. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #include <assert.h>
  7. #include <psa/crypto_sizes.h>
  8. #include <psa/crypto_types.h>
  9. #include <psa/crypto_values.h>
  10. #include <cca_attestation.h>
  11. #include <delegated_attestation.h>
  12. #include <services/rmmd_svc.h>
  13. psa_status_t
  14. cca_attestation_get_realm_key(uintptr_t buf, size_t *len, unsigned int type)
  15. {
  16. size_t dak_len;
  17. psa_status_t ret = PSA_SUCCESS;
  18. /*
  19. * Current RMM implementations only support the public key size for
  20. * ECC-P384, i.e. ATTEST_KEY_CURVE_ECC_SECP384R1 attestation key.
  21. *
  22. * This ECC key has following properties:
  23. * ecc_curve: 0x12 (PSA_ECC_FAMILY_SECP_R1)
  24. * key_bits: 384
  25. * hash_alg: 0x02000009 (PSA_ALG_SHA_256)
  26. */
  27. assert(type == ATTEST_KEY_CURVE_ECC_SECP384R1);
  28. ret = rse_delegated_attest_get_delegated_key(PSA_ECC_FAMILY_SECP_R1,
  29. 384, (uint8_t *)buf, *len,
  30. &dak_len, PSA_ALG_SHA_256);
  31. if (ret != PSA_SUCCESS) {
  32. return ret;
  33. }
  34. if (dak_len != PSA_BITS_TO_BYTES(384)) {
  35. return PSA_ERROR_INVALID_ARGUMENT;
  36. }
  37. *len = dak_len;
  38. return ret;
  39. }
  40. psa_status_t
  41. cca_attestation_get_plat_token(uintptr_t buf, size_t *len,
  42. uintptr_t hash, size_t hash_size)
  43. {
  44. size_t token_len = 0;
  45. psa_status_t ret = PSA_SUCCESS;
  46. ret = rse_delegated_attest_get_token((const uint8_t *)hash, hash_size,
  47. (uint8_t *)buf, *len, &token_len);
  48. if (ret != PSA_SUCCESS) {
  49. return ret;
  50. }
  51. *len = token_len;
  52. return ret;
  53. }