pcr.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. #ifndef SRC_PCR_H_
  3. #define SRC_PCR_H_
  4. #include <stdbool.h>
  5. #include <tss2/tss2_esys.h>
  6. #include "tool_rc.h"
  7. typedef struct tpm2_algorithm tpm2_algorithm;
  8. struct tpm2_algorithm {
  9. int count;
  10. TPMI_ALG_HASH alg[TPM2_NUM_PCR_BANKS];
  11. };
  12. typedef struct tpm2_pcrs tpm2_pcrs;
  13. struct tpm2_pcrs {
  14. size_t count;
  15. TPML_DIGEST pcr_values[TPM2_MAX_PCRS];
  16. };
  17. /**
  18. * Echo out all PCR banks according to g_pcrSelection & g_pcrs->.
  19. * @param pcrSelect
  20. * Description of which PCR registers are selected.
  21. * @param pcrs
  22. * Struct containing PCR digests.
  23. * @return
  24. * True on success, false otherwise.
  25. */
  26. bool pcr_print_pcr_struct(TPML_PCR_SELECTION *pcrSelect, tpm2_pcrs *pcrs);
  27. /**
  28. * Echo out all PCR banks according to g_pcrSelection & g_pcrs->.
  29. * Assume that data structures are all little endian.
  30. * @param pcrSelect
  31. * Description of which PCR registers are selected.
  32. * @param pcrs
  33. * Struct containing PCR digests.
  34. * @return
  35. * True on success, false otherwise.
  36. */
  37. bool pcr_print_pcr_struct_le(TPML_PCR_SELECTION *pcrSelect, tpm2_pcrs *pcrs);
  38. /**
  39. * Set the PCR value into pcrId if string in arg is a valid PCR index.
  40. * @param arg
  41. * PCR index as string
  42. * @param pcrId
  43. * Caller-allocated PCR index as integer
  44. * @return
  45. * True on success, false otherwise.
  46. */
  47. bool pcr_get_id(const char *arg, UINT32 *pcr_id);
  48. bool pcr_print_pcr_selections(TPML_PCR_SELECTION *pcr_selections);
  49. bool pcr_parse_selections(const char *arg, TPML_PCR_SELECTION *pcr_selections);
  50. tool_rc pcr_get_banks(ESYS_CONTEXT *esys_context,
  51. TPMS_CAPABILITY_DATA *capability_data, tpm2_algorithm *algs);
  52. bool pcr_init_pcr_selection(TPMS_CAPABILITY_DATA *cap_data,
  53. TPML_PCR_SELECTION *pcr_selections, TPMI_ALG_HASH alg_id);
  54. bool pcr_check_pcr_selection(TPMS_CAPABILITY_DATA *cap_data,
  55. TPML_PCR_SELECTION *pcr_selections);
  56. tool_rc pcr_read_pcr_values(ESYS_CONTEXT *esys_context,
  57. TPML_PCR_SELECTION *pcr_selections, tpm2_pcrs *pcrs);
  58. #endif /* SRC_PCR_H_ */