diff options
author | James Bottomley <JBottomley@Parallels.com> | 2015-01-14 14:26:17 -0800 |
---|---|---|
committer | James Bottomley <JBottomley@Parallels.com> | 2015-03-17 17:07:53 -0700 |
commit | 2df44d17b0abf3a406dd00be7a813aaa8d6d7f3b (patch) | |
tree | 20438c4824f734431ab0a16a4890c27014be8f6c | |
parent | 0ddcd791f319eabf0adf468e8405c8acf73a6aa1 (diff) | |
download | efitools-2df44d17b0abf3a406dd00be7a813aaa8d6d7f3b.tar.gz |
guid.c: add function to calculate owner GUID for known authenticated variables
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
-rw-r--r-- | include/guid.h | 1 | ||||
-rw-r--r-- | lib/guid.c | 22 |
2 files changed, 23 insertions, 0 deletions
diff --git a/include/guid.h b/include/guid.h index 17aa6af..5ca8b1c 100644 --- a/include/guid.h +++ b/include/guid.h @@ -4,6 +4,7 @@ const char *guid_to_str(EFI_GUID *guid); int str_to_guid(const char *str, EFI_GUID *guid); int compare_guid(EFI_GUID *g1, EFI_GUID *g2); +EFI_GUID *get_owner_guid(char *var); #endif extern EFI_GUID GV_GUID; @@ -7,6 +7,8 @@ #include <guid.h> #include <stdio.h> +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) + #ifndef BUILD_EFI /* EFI has %g for this, so it's only needed in platform c */ const char *guid_to_str(EFI_GUID *guid) @@ -40,8 +42,28 @@ compare_guid(EFI_GUID *g1, EFI_GUID *g2) { return memcmp(g1, g2, sizeof(*g1)); } + +EFI_GUID * +get_owner_guid(char *var) +{ + char *variables[] = { "PK", "KEK", "db", "dbx", "dbt", "MokList" }; + EFI_GUID *owners[] = { &GV_GUID, &GV_GUID, &SIG_DB, &SIG_DB, &SIG_DB, &MOK_OWNER }; + EFI_GUID *owner = NULL; + int i; + + for(i = 0; i < ARRAY_SIZE(variables); i++) { + if (strcmp(var, variables[i]) == 0) { + owner = owners[i]; + break; + } + } + + return owner; +} #endif + + /* all the necessary guids */ EFI_GUID GV_GUID = EFI_GLOBAL_VARIABLE; EFI_GUID SIG_DB = { 0xd719b2cb, 0x3d3a, 0x4596, {0xa3, 0xbc, 0xda, 0xd0, 0xe, 0x67, 0x65, 0x6f }}; |