[PATCH 04/15] uefirtauthvar: add test for setting authenticated variable created by another key
Ivan Hu
ivan.hu at canonical.com
Wed Oct 22 09:38:04 UTC 2014
While one existing variable, but set authenticated variable, which created
by another valid key, firmware should check the authenticated variable
and return return EFI_SECURITY_VIOLATION.
Signed-off-by: Ivan Hu <ivan.hu at canonical.com>
---
src/uefi/uefirtauthvar/authvardefs.h | 123 ++++++++++++++++++++++++++++++++
src/uefi/uefirtauthvar/uefirtauthvar.c | 36 ++++++++++
2 files changed, 159 insertions(+)
diff --git a/src/uefi/uefirtauthvar/authvardefs.h b/src/uefi/uefirtauthvar/authvardefs.h
index 156ece4..ec66614 100644
--- a/src/uefi/uefirtauthvar/authvardefs.h
+++ b/src/uefi/uefirtauthvar/authvardefs.h
@@ -266,4 +266,127 @@ static uint8_t AuthVarDel[] = {
0x65, 0xb6, 0xff, 0xbf, 0xbd, 0x08, 0xe1, 0xed, 0x0c, 0x19, 0xb2
};
+/*
+ * AuthVarCreateDiffer, the same as AuthVarCreate, but using different valid key and new timestamp
+ * timestamp: 2014.09.08:05:52:01
+ * GUID: 7f5c5d52-2f14-4f12-967cdb60db05a0fd
+ * attributes = UEFI_VAR_NON_VOLATILE, UEFI_VAR_BOOTSERVICE_ACCESS,
+ * UEFI_VAR_RUNTIME_ACCESS, UEFI_VARIABLE_TIME_BASED_AUTHENTICATED_WRITE_ACCESS
+ * Variable name: AuthVarTest
+ * data content: 1234567890abcdef
+ */
+static uint8_t AuthVarCreateDiff[] = {
+ 0xde, 0x07, 0x09, 0x08, 0x05, 0x34, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x0b, 0x05, 0x00, 0x00, 0x00, 0x02, 0xf1, 0x0e,
+ 0x9d, 0xd2, 0xaf, 0x4a, 0xdf, 0x68, 0xee, 0x49, 0x8a, 0xa9, 0x34, 0x7d,
+ 0x37, 0x56, 0x65, 0xa7, 0x30, 0x82, 0x04, 0xef, 0x06, 0x09, 0x2a, 0x86,
+ 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x02, 0xa0, 0x82, 0x04, 0xe0, 0x30,
+ 0x82, 0x04, 0xdc, 0x02, 0x01, 0x01, 0x31, 0x0f, 0x30, 0x0d, 0x06, 0x09,
+ 0x60, 0x86, 0x48, 0x01, 0x65, 0x03, 0x04, 0x02, 0x01, 0x05, 0x00, 0x30,
+ 0x0b, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01, 0x07, 0x01,
+ 0xa0, 0x82, 0x02, 0xfd, 0x30, 0x82, 0x02, 0xf9, 0x30, 0x82, 0x01, 0xe1,
+ 0xa0, 0x03, 0x02, 0x01, 0x02, 0x02, 0x09, 0x00, 0xe2, 0x7d, 0x10, 0xea,
+ 0xd8, 0x0d, 0x98, 0x77, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86,
+ 0xf7, 0x0d, 0x01, 0x01, 0x0b, 0x05, 0x00, 0x30, 0x13, 0x31, 0x11, 0x30,
+ 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c, 0x08, 0x74, 0x65, 0x73, 0x74,
+ 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x1e, 0x17, 0x0d, 0x31, 0x34, 0x31, 0x30,
+ 0x30, 0x38, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a, 0x17, 0x0d, 0x31,
+ 0x34, 0x31, 0x31, 0x30, 0x37, 0x30, 0x35, 0x34, 0x39, 0x35, 0x38, 0x5a,
+ 0x30, 0x13, 0x31, 0x11, 0x30, 0x0f, 0x06, 0x03, 0x55, 0x04, 0x03, 0x0c,
+ 0x08, 0x74, 0x65, 0x73, 0x74, 0x2d, 0x6b, 0x65, 0x79, 0x30, 0x82, 0x01,
+ 0x22, 0x30, 0x0d, 0x06, 0x09, 0x2a, 0x86, 0x48, 0x86, 0xf7, 0x0d, 0x01,
+ 0x01, 0x01, 0x05, 0x00, 0x03, 0x82,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0, 0x31,
+ 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30, 0x61, 0x62, 0x63,
+ 0x64, 0x65, 0x66
+};
+
#endif
diff --git a/src/uefi/uefirtauthvar/uefirtauthvar.c b/src/uefi/uefirtauthvar/uefirtauthvar.c
index b30fc5b..10feb2f 100644
--- a/src/uefi/uefirtauthvar/uefirtauthvar.c
+++ b/src/uefi/uefirtauthvar/uefirtauthvar.c
@@ -258,9 +258,45 @@ static int uefirtauthvar_test2(fwts_framework *fw)
return FWTS_ERROR;
}
+/*
+ * With one existing variable, but set authenticated variable which created by another valid key,
+ * expect EFI_SECURITY_VIOLATION returned.
+ */
+static int uefirtauthvar_test3(fwts_framework *fw)
+{
+ long ioret;
+ uint64_t status;
+ int supcheck;
+
+ ioret = setvar(>estguid, attributes, sizeof(AuthVarCreateDiff), AuthVarCreateDiff, &status);
+
+ if (ioret == -1) {
+ supcheck = check_fw_support(fw, status);
+ if (supcheck != FWTS_OK)
+ return supcheck;
+
+ if (status == EFI_SECURITY_VIOLATION) {
+ fwts_passed(fw, "Authenticated variable test with another valid authenticated variable passed.");
+ return FWTS_OK;
+ }
+
+ fwts_failed(fw, LOG_LEVEL_MEDIUM,
+ "UEFISetDiffAuthVar",
+ "Set different valid authenticated variable fail");
+ fwts_uefi_print_status_info(fw, status);
+ }
+
+ fwts_failed(fw, LOG_LEVEL_HIGH,
+ "UEFISetDiffAuthVar",
+ "Set authenticated variable expected fail but success");
+
+ return FWTS_ERROR;
+}
+
static fwts_framework_minor_test uefirtauthvar_tests[] = {
{ uefirtauthvar_test1, "Create authenticated variable test." },
{ uefirtauthvar_test2, "Authenticated variable test with the same authenticated variable." },
+ { uefirtauthvar_test3, "Authenticated variable test with another valid authenticated variable." },
{ NULL, NULL }
};
--
1.7.9.5
More information about the fwts-devel
mailing list