Sync from SUSE:SLFO:Main grub2 revision 3010d884e9d64ab422fda75d82b89c60
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
--- a/include/grub/tpm.h
|
||||
+++ b/include/grub/tpm.h
|
||||
Index: grub-2.12/include/grub/tpm.h
|
||||
===================================================================
|
||||
--- grub-2.12.orig/include/grub/tpm.h
|
||||
+++ grub-2.12/include/grub/tpm.h
|
||||
@@ -36,6 +36,12 @@
|
||||
|
||||
#define EV_IPL 0x0d
|
||||
@@ -13,7 +15,7 @@
|
||||
grub_err_t grub_tpm_measure (unsigned char *buf, grub_size_t size,
|
||||
grub_uint8_t pcr, const char *description);
|
||||
int grub_tpm_present (void);
|
||||
@@ -45,5 +51,7 @@
|
||||
@@ -45,5 +51,7 @@ grub_is_tpm_fail_fatal (void)
|
||||
{
|
||||
return grub_env_get_bool ("tpm_fail_fatal", false);
|
||||
}
|
||||
@@ -21,29 +23,32 @@
|
||||
+void grub_tpm_digest_free (struct grub_tpm_digest *d);
|
||||
|
||||
#endif
|
||||
--- a/grub-core/commands/efi/tpm.c
|
||||
+++ b/grub-core/commands/efi/tpm.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <grub/efi/efi.h>
|
||||
#include <grub/efi/cc.h>
|
||||
#include <grub/efi/tpm.h>
|
||||
+#include <grub/tpm2/tpm2.h>
|
||||
#include <grub/mm.h>
|
||||
Index: grub-2.12/grub-core/commands/efi/tpm.c
|
||||
===================================================================
|
||||
--- grub-2.12.orig/grub-core/commands/efi/tpm.c
|
||||
+++ grub-2.12/grub-core/commands/efi/tpm.c
|
||||
@@ -28,6 +28,8 @@
|
||||
#include <grub/tpm.h>
|
||||
#include <grub/term.h>
|
||||
@@ -186,6 +187,91 @@
|
||||
|
||||
+#include <tpm2_cmd.h>
|
||||
+
|
||||
typedef TCG_PCR_EVENT grub_tpm_event_t;
|
||||
|
||||
static grub_guid_t tpm_guid = EFI_TPM_GUID;
|
||||
@@ -186,6 +188,91 @@ grub_tpm1_log_event (grub_efi_handle_t t
|
||||
return grub_efi_log_event_status (status);
|
||||
}
|
||||
|
||||
+static void
|
||||
+grub_tpm2_select_pcr(TPML_PCR_SELECTION *o, unsigned int pcrIndex, unsigned int algo)
|
||||
+grub_tpm2_select_pcr (TPML_PCR_SELECTION_t *o, unsigned int pcrIndex, unsigned int algo)
|
||||
+{
|
||||
+ TPMS_PCR_SELECTION *pcr;
|
||||
+ TPMS_PCR_SELECTION_t *pcr;
|
||||
+
|
||||
+ pcr = &o->pcrSelections[o->count++];
|
||||
+ pcr->hash = algo;
|
||||
+ pcr->sizeOfSelect = 3;
|
||||
+ pcr->pcrSelect[TPM2_PCR_TO_SELECT(pcrIndex)] |= TPM2_PCR_TO_BIT(pcrIndex);
|
||||
+ TPMS_PCR_SELECTION_SelectPCR (pcr, pcrIndex);
|
||||
+}
|
||||
+
|
||||
+struct grub_tpm_hash_info {
|
||||
@@ -77,10 +82,10 @@
|
||||
+grub_tpm2_read_pcr (grub_int8_t pcrIndex, const char *algo, struct grub_tpm_digest **ret)
|
||||
+{
|
||||
+ const struct grub_tpm_hash_info *info;
|
||||
+ TPML_PCR_SELECTION inSelection, outSelection;
|
||||
+ TPML_PCR_SELECTION_t inSelection, outSelection;
|
||||
+ grub_uint32_t pcrUpdateCounter;
|
||||
+ TPML_DIGEST digests = { 0 };
|
||||
+ TPM2B_DIGEST *d;
|
||||
+ TPML_DIGEST_t digests = { 0 };
|
||||
+ TPM2B_DIGEST_t *d;
|
||||
+ struct grub_tpm_digest *result;
|
||||
+ int rc;
|
||||
+
|
||||
@@ -92,7 +97,7 @@
|
||||
+ grub_memset(&outSelection, 0, sizeof(outSelection));
|
||||
+ grub_tpm2_select_pcr(&inSelection, pcrIndex, info->id);
|
||||
+
|
||||
+ rc = TPM2_PCR_Read(
|
||||
+ rc = grub_tpm2_pcr_read(
|
||||
+ NULL,
|
||||
+ &inSelection,
|
||||
+ &pcrUpdateCounter,
|
||||
@@ -123,7 +128,7 @@
|
||||
static grub_err_t
|
||||
grub_tpm2_log_event (grub_efi_handle_t tpm_handle, unsigned char *buf,
|
||||
grub_size_t size, grub_uint8_t pcr,
|
||||
@@ -323,3 +409,26 @@
|
||||
@@ -323,3 +410,26 @@ grub_tpm_present (void)
|
||||
return grub_tpm2_present (tpm);
|
||||
}
|
||||
}
|
||||
@@ -150,16 +155,15 @@
|
||||
+
|
||||
+ return result;
|
||||
+}
|
||||
--- a/include/grub/tpm2/tpm2.h
|
||||
+++ b/include/grub/tpm2/tpm2.h
|
||||
@@ -23,6 +23,10 @@
|
||||
#include <grub/tpm2/internal/structs.h>
|
||||
#include <grub/tpm2/internal/functions.h>
|
||||
|
||||
+/* Defined in: TCG TPM Specification, v1.59, Part 2, Section 10.6.1. */
|
||||
+#define TPM2_PCR_TO_SELECT(x) ((x) / 8)
|
||||
+#define TPM2_PCR_TO_BIT(x) (1 << ((x) % 8))
|
||||
+
|
||||
/* Well-Known Windows SRK handle */
|
||||
#define TPM2_SRK_HANDLE 0x81000001
|
||||
Index: grub-2.12/grub-core/Makefile.core.def
|
||||
===================================================================
|
||||
--- grub-2.12.orig/grub-core/Makefile.core.def
|
||||
+++ grub-2.12/grub-core/Makefile.core.def
|
||||
@@ -2606,6 +2606,7 @@ module = {
|
||||
common = commands/tpm.c;
|
||||
efi = commands/efi/tpm.c;
|
||||
enable = efi;
|
||||
+ cppflags = '-I$(srcdir)/lib/tss2';
|
||||
};
|
||||
|
||||
module = {
|
||||
|
Reference in New Issue
Block a user