rmm_el3_token_sign.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /*
  2. * Copyright (c) 2024, NVIDIA Corporation. All rights reserved.
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. */
  6. #ifndef RMM_EL3_TOKEN_SIGN_H
  7. #define RMM_EL3_TOKEN_SIGN_H
  8. #include <stdint.h>
  9. #include <lib/cassert.h>
  10. #include <services/rmmd_svc.h>
  11. /*
  12. * Defines member of structure and reserves space
  13. * for the next member with specified offset.
  14. */
  15. /* cppcheck-suppress [misra-c2012-20.7] */
  16. #define SET_MEMBER(member, start, end) \
  17. union { \
  18. member; \
  19. unsigned char reserved##end[((end) - (start))]; \
  20. }
  21. #define EL3_TOKEN_RESPONSE_MAX_SIG_LEN U(512)
  22. struct el3_token_sign_request {
  23. SET_MEMBER(uint32_t sig_alg_id, 0x0, 0x8);
  24. SET_MEMBER(uint64_t rec_granule, 0x8, 0x10);
  25. SET_MEMBER(uint64_t req_ticket, 0x10, 0x18);
  26. SET_MEMBER(uint32_t hash_alg_id, 0x18, 0x20);
  27. SET_MEMBER(uint8_t hash_buf[SHA512_DIGEST_SIZE], 0x20, 0x60);
  28. };
  29. CASSERT(__builtin_offsetof(struct el3_token_sign_request, sig_alg_id) == 0x0U,
  30. assert_el3_token_sign_request_sig_alg_mismatch);
  31. CASSERT(__builtin_offsetof(struct el3_token_sign_request, rec_granule) == 0x8U,
  32. assert_el3_token_sign_request_rec_granule_mismatch);
  33. CASSERT(__builtin_offsetof(struct el3_token_sign_request, req_ticket) == 0x10U,
  34. assert_el3_token_sign_request_req_ticket_mismatch);
  35. CASSERT(__builtin_offsetof(struct el3_token_sign_request, hash_alg_id) == 0x18U,
  36. assert_el3_token_sign_request_hash_alg_id_mismatch);
  37. CASSERT(__builtin_offsetof(struct el3_token_sign_request, hash_buf) == 0x20U,
  38. assert_el3_token_sign_request_hash_buf_mismatch);
  39. struct el3_token_sign_response {
  40. SET_MEMBER(uint64_t rec_granule, 0x0, 0x8);
  41. SET_MEMBER(uint64_t req_ticket, 0x8, 0x10);
  42. SET_MEMBER(uint16_t sig_len, 0x10, 0x12);
  43. SET_MEMBER(uint8_t signature_buf[EL3_TOKEN_RESPONSE_MAX_SIG_LEN], 0x12, 0x212);
  44. };
  45. CASSERT(__builtin_offsetof(struct el3_token_sign_response, rec_granule) == 0x0U,
  46. assert_el3_token_sign_resp_rec_granule_mismatch);
  47. CASSERT(__builtin_offsetof(struct el3_token_sign_response, req_ticket) == 0x8U,
  48. assert_el3_token_sign_resp_req_ticket_mismatch);
  49. CASSERT(__builtin_offsetof(struct el3_token_sign_response, sig_len) == 0x10U,
  50. assert_el3_token_sign_resp_sig_len_mismatch);
  51. CASSERT(__builtin_offsetof(struct el3_token_sign_response, signature_buf) == 0x12U,
  52. assert_el3_token_sign_resp_sig_buf_mismatch);
  53. #endif /* RMM_EL3_TOKEN_SIGN_H */