[Skiboot] [PATCH v6a 4/4] secvar/backend: improve edk2 driver unit testcases

Eric Richter erichte at linux.ibm.com
Tue Sep 29 08:06:09 AEST 2020


From: Nayna Jain <nayna at linux.ibm.com>

This patch adds following more unit test cases and improve comments.

* Check for successful processing of queued updates
* Check for queued updates when one update fail, especially when PK is
added.
* Check for queued updates when one update fail, especially when PK is
deleted.
* Check hw-key-hash addition/deleting/verification.
* Update dbxcert file
* Update rc checks against specific failure error return codes.

Signed-off-by: Nayna Jain <nayna at linux.ibm.com>
---
 libstb/secvar/test/data/dbxcert.h            | 161 ++++++++++++
 libstb/secvar/test/secvar-test-edk2-compat.c | 263 ++++++++++++++++---
 2 files changed, 387 insertions(+), 37 deletions(-)
 create mode 100644 libstb/secvar/test/data/dbxcert.h

diff --git a/libstb/secvar/test/data/dbxcert.h b/libstb/secvar/test/data/dbxcert.h
new file mode 100644
index 00000000..26faa543
--- /dev/null
+++ b/libstb/secvar/test/data/dbxcert.h
@@ -0,0 +1,161 @@
+unsigned char dbx_cert_auth[] = {
+0xe4 ,0x07 ,0x09 ,0x1c ,0x10 ,0x05 ,0x0f ,0x00  ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00 ,0x00
+,0xd3 ,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 ,0x05 ,0xb7 ,0x06 ,0x09 ,0x2a ,0x86
+,0x48 ,0x86 ,0xf7 ,0x0d ,0x01 ,0x07 ,0x02 ,0xa0  ,0x82 ,0x05 ,0xa8 ,0x30 ,0x82 ,0x05 ,0xa4 ,0x02
+,0x01 ,0x01 ,0x31 ,0x0f ,0x30 ,0x0d ,0x06 ,0x09  ,0x60 ,0x86 ,0x48 ,0x01 ,0x65 ,0x03 ,0x04 ,0x02
+,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,0xac ,0x85 ,0xf9 ,0x5d ,0xaf ,0xa4 ,0x19
+,0x70 ,0xb9 ,0xe4 ,0xfa ,0xbf ,0x5b ,0x00 ,0x2f  ,0x46 ,0xd9 ,0xc4 ,0x9a ,0x32 ,0x96 ,0xb7 ,0x7f
+,0x22 ,0xf9 ,0xa4 ,0xea ,0xba ,0xc8 ,0xb8 ,0x59  ,0xbd ,0x12 ,0x30 ,0x76 ,0x50 ,0x4f ,0x62 ,0x72
+,0x05 ,0xe2 ,0xf4 ,0x29 ,0x91 ,0x05 ,0x28 ,0xba  ,0x3c ,0xf0 ,0x6b ,0x1e ,0x54 ,0xa2 ,0x47 ,0xa7
+,0xfc ,0x64 ,0x20 ,0x9c ,0xf1 ,0x95 ,0xe3 ,0xd1  ,0xc9 ,0x37 ,0xe8 ,0xeb ,0x4e ,0xda ,0x2b ,0x5f
+,0x1c ,0x7a ,0xb3 ,0xe2 ,0x0a ,0x01 ,0x5c ,0x7a  ,0x1e ,0xfc ,0x24 ,0x60 ,0x14 ,0x75 ,0xcd ,0xe9
+,0x9e ,0x77 ,0xbf ,0x3a ,0x6f ,0xd7 ,0x7f ,0x42  ,0x14 ,0x94 ,0x27 ,0x0b ,0x6e ,0x1d ,0x78 ,0x9b
+,0xc5 ,0x82 ,0x28 ,0xf7 ,0x78 ,0xc4 ,0xdf ,0x4e  ,0x85 };
+
+unsigned int dbx_cert_auth_len = 2521;
diff --git a/libstb/secvar/test/secvar-test-edk2-compat.c b/libstb/secvar/test/secvar-test-edk2-compat.c
index 3ec4afdc..8259ffa1 100644
--- a/libstb/secvar/test/secvar-test-edk2-compat.c
+++ b/libstb/secvar/test/secvar-test-edk2-compat.c
@@ -19,13 +19,65 @@
 #include "./data/multipleDB.h"
 #include "./data/multiplePK.h"
 #include "./data/dbx.h"
+#include "./data/dbxcert.h"
 #include "./data/dbxsha512.h"
 #include "./data/dbxmalformed.h"
 
+bool test_hw_key_hash = false;
+
+/* Hardcoding HW KEY HASH to avoid emulating device-tree in unit-tests. */
+const unsigned char hw_key_hash[64] = {
+0xb6, 0xdf, 0xfe, 0x75, 0x53, 0xf9, 0x2e, 0xcb, 0x2b, 0x05, 0x55, 0x35, 0xd7, 0xda, 0xfe, 0x32, \
+0x98, 0x93, 0x35, 0x1e, 0xd7, 0x4b, 0xbb, 0x21, 0x6b, 0xa0, 0x56, 0xa7, 0x1e, 0x3c, 0x0b, 0x56, \
+0x6f, 0x0c, 0x4d, 0xbe, 0x31, 0x42, 0x13, 0x68, 0xcb, 0x32, 0x11, 0x6f, 0x13, 0xbb, 0xdd, 0x9e, \
+0x4f, 0xe3, 0x83, 0x8b, 0x1c, 0x6a, 0x2e, 0x07, 0xdb, 0x95, 0x16, 0xc9, 0x33, 0xaa, 0x20, 0xef
+};
+
+const unsigned char new_hw_key_hash[64] = {
+0xa6, 0xdf, 0xfe, 0x75, 0x53, 0xf9, 0x2e, 0xcb, 0x2b, 0x05, 0x55, 0x35, 0xd7, 0xda, 0xfe, 0x32, \
+0x98, 0x93, 0x35, 0x1e, 0xd7, 0x4b, 0xbb, 0x21, 0x6b, 0xa0, 0x56, 0xa7, 0x1e, 0x3c, 0x0b, 0x56, \
+0x6f, 0x0c, 0x4d, 0xbe, 0x31, 0x42, 0x13, 0x68, 0xcb, 0x32, 0x11, 0x6f, 0x13, 0xbb, 0xdd, 0x9e, \
+0x4f, 0xe3, 0x83, 0x8b, 0x1c, 0x6a, 0x2e, 0x07, 0xdb, 0x95, 0x16, 0xc9, 0x33, 0xaa, 0x20, 0xef
+};
+
 int reset_keystore(struct list_head *bank __unused) { return 0; }
-int add_hw_key_hash(struct list_head *bank __unused) { return 0; }
-int delete_hw_key_hash(struct list_head *bank __unused) { return 0; }
-int verify_hw_key_hash(void) { return 0; }
+int verify_hw_key_hash(void)
+{
+
+	/* This check is added just to simulate mismatch of hashes. */
+	if (test_hw_key_hash)
+		if (memcmp(new_hw_key_hash, hw_key_hash, 64) != 0)
+			return OPAL_PERMISSION;
+
+	return OPAL_SUCCESS;
+}
+
+
+int add_hw_key_hash(struct list_head *bank)
+{
+	struct secvar *var;
+	uint32_t hw_key_hash_size = 64;
+
+	var = new_secvar("HWKH", 5, hw_key_hash,
+			hw_key_hash_size, SECVAR_FLAG_PROTECTED);
+	list_add_tail(bank, &var->link);
+
+	return OPAL_SUCCESS;
+}
+
+int delete_hw_key_hash(struct list_head *bank)
+{
+	struct secvar *var;
+
+	var = find_secvar("HWKH", 5, bank);
+	if (!var)
+		return OPAL_SUCCESS;
+
+	list_del(&var->link);
+	dealloc_secvar(var);
+
+	return OPAL_SUCCESS;
+}
 
 const char *secvar_test_name = "edk2-compat";
 
@@ -37,7 +89,10 @@ int run_test()
 	struct secvar *tmp;
 	char empty[64] = {0};
 
-	// Check pre-process creates the empty variables
+	/* The sequence of test cases here is important to ensure that
+	 * timestamp checks work as expected. */
+
+	/* Check pre-process creates the empty variables. */
 	ASSERT(0 == list_length(&variable_bank));
 	rc = edk2_compat_pre_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_SUCCESS == rc);
@@ -47,24 +102,87 @@ int run_test()
 	ASSERT(64 == tmp->data_size);
 	ASSERT(!(memcmp(tmp->data, empty, 64)));
 
-	// Add PK to update and .process()
+	/* Add test to verify hw_key_hash.
+	 * This is to ensure that mismatch of test happens.
+	 * The test uses test_hw_key_hash variable to ensure that
+	 * mismatch happens. For all next tests, test_hw_key_hash variable
+	 * should be zero to avoid hard-coded mismatch.
+	 */
+	test_hw_key_hash = 1;
+	setup_mode = false;
 	printf("Add PK");
 	tmp = new_secvar("PK", 3, PK_auth, PK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
 	ASSERT(1 == list_length(&update_bank));
-
 	rc = edk2_compat_process(&variable_bank, &update_bank);
+	printf("rc is %04x %d\n", rc, rc);
 	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(0 == list_length(&update_bank));
+	ASSERT(setup_mode);
+
+	/* Set test_hw_key_hash to zero to avoid hardcoded mismatch. */
+	test_hw_key_hash = 0;
+
+	/* Add PK and a failed update. */
+	printf("Add PK and failed dbx");
+	tmp = new_secvar("PK", 3, PK_auth, PK_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
+
+	tmp = new_secvar("dbx", 4, wrongdbxauth, wrong_dbx_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(2 == list_length(&update_bank));
+
+	rc = edk2_compat_process(&variable_bank, &update_bank);
+	ASSERT(OPAL_PARAMETER == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	rc = edk2_compat_post_process(&variable_bank, &update_bank);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(setup_mode);
+
+	/* Add PK and db, db update should fail, so all updates fail. */
+	printf("Add PK");
+	tmp = new_secvar("PK", 3, PK_auth, PK_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
+	printf("Add db");
+	tmp = new_secvar("db", 3, DB_auth, sizeof(DB_auth), 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(2 == list_length(&update_bank));
+	rc = edk2_compat_process(&variable_bank, &update_bank);
+	ASSERT(OPAL_PERMISSION == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	rc = edk2_compat_post_process(&variable_bank, &update_bank);
 	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(setup_mode);
+
+	/* Add PK to update and .process(). */
+	printf("Add PK");
+	tmp = new_secvar("PK", 3, PK_auth, PK_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
+
+	rc = edk2_compat_process(&variable_bank, &update_bank);
+	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(6 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
+	rc = edk2_compat_post_process(&variable_bank, &update_bank);
+	ASSERT(5 == list_length(&variable_bank));
 	tmp = find_secvar("PK", 3, &variable_bank);
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
-	ASSERT(PK_auth_len > tmp->data_size); // esl should be smaller without auth
+	ASSERT(PK_auth_len > tmp->data_size); /* esl should be smaller without auth. */
 	ASSERT(!setup_mode);
 
-	// Add db, should fail with no KEK
+	/* Add db, should fail with no KEK. */
 	printf("Add db");
 	tmp = new_secvar("db", 3, DB_auth, DB_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -72,16 +190,14 @@ int run_test()
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	printf("rc is %d %04x\n", rc, rc);
-	ASSERT(OPAL_SUCCESS != rc);
+	ASSERT(OPAL_PERMISSION == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
 	tmp = find_secvar("db", 3, &variable_bank);
 	ASSERT(NULL != tmp);
 
+	/* Add valid KEK, .process(), succeeds. */
 	printf("Add KEK");
-
-	// Add valid KEK, .process(), succeeds 
 	tmp = new_secvar("KEK", 4, KEK_auth, KEK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
@@ -95,8 +211,7 @@ int run_test()
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add valid KEK, .process(), timestamp check fails 
-
+	/* Add valid KEK, .process(), timestamp check fails. */
 	tmp = new_secvar("KEK", 4, OldTS_KEK_auth, OldTS_KEK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
@@ -110,7 +225,7 @@ int run_test()
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add db, .process(), should succeed
+	/* Add db, .process(), should succeed. */
 	printf("Add db again\n");
 	tmp = new_secvar("db", 3, DB_auth, DB_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -126,7 +241,7 @@ int run_test()
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add db, .process(), should fail because of timestamp 
+	/* Add db, .process(), should fail because of timestamp. */
 	printf("Add db again\n");
 	tmp = new_secvar("db", 3, DB_auth, DB_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -135,8 +250,13 @@ int run_test()
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_PERMISSION == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("db", 3, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
 
-	// Add valid sha256 dbx
+	/* Add valid sha256 dbx. */
 	printf("Add sha256 dbx\n");
 	tmp = new_secvar("dbx", 4, dbxauth, dbx_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -145,8 +265,13 @@ int run_test()
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("db", 3, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
 
-	// Add invalid KEK, .process(), should fail
+	/* Add invalid KEK, .process(), should fail. Timestamp check failure. */
 	printf("Add invalid KEK\n");
 	tmp = new_secvar("KEK", 4, InvalidKEK_auth, InvalidKEK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -154,14 +279,14 @@ int run_test()
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS != rc);
+	ASSERT(OPAL_PERMISSION == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
 	tmp = find_secvar("KEK", 4, &variable_bank);
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add ill formatted KEK, .process(), should fail
+	/* Add ill formatted KEK, .process(), should fail. */
 	printf("Add invalid KEK\n");
 	tmp = new_secvar("KEK", 4, MalformedKEK_auth, MalformedKEK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -169,44 +294,56 @@ int run_test()
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS != rc);
+	ASSERT(OPAL_PARAMETER == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
 	tmp = find_secvar("KEK", 4, &variable_bank);
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add multiple KEK ESLs, one of them should sign the db 
+	/* Add multiple db and then multiple KEKs.
+	 * The db should be signed with a KEK yet to be added.
+	 */
+	printf("Add multiple db\n");
+	tmp = new_secvar("db", 3, multipleDB_auth, multipleDB_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
 	printf("Add multiple KEK\n");
 	tmp = new_secvar("KEK", 4, multipleKEK_auth, multipleKEK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
-	ASSERT(1 == list_length(&update_bank));
+	ASSERT(2 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(OPAL_PERMISSION == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
-	tmp = find_secvar("KEK", 4, &variable_bank);
-	ASSERT(NULL != tmp);
-	ASSERT(0 != tmp->data_size);
 
-	// Add multiple DB ESLs signed with second key of the KEK 
+	/* Add multiple KEK ESLs, one of them should sign the db. */
+	printf("Add multiple KEK\n");
+	tmp = new_secvar("KEK", 4, multipleKEK_auth, multipleKEK_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
 	printf("Add multiple db\n");
 	tmp = new_secvar("db", 3, multipleDB_auth, multipleDB_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
-	ASSERT(1 == list_length(&update_bank));
+	ASSERT(2 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_SUCCESS == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("KEK", 4, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
 	tmp = find_secvar("db", 3, &variable_bank);
 	ASSERT(NULL != tmp);
 	ASSERT(0 != tmp->data_size);
 
-	// Add db with signeddata PKCS7 format.
+	/* Add db with signeddata PKCS7 format. */
 	printf("DB with signed data\n");
 	tmp = new_secvar("db", 3, dbsigneddata_auth, dbsigneddata_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -215,9 +352,42 @@ int run_test()
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("db", 3, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
 
-	// Delete PK. 
+	/* Delete PK and invalid dbx - to test queued updates for deleting PK. */
 	printf("Delete PK\n");
+	/* Add hw_key_hash explicitly to ensure it is deleted as part of PK deletion. */
+	add_hw_key_hash(&variable_bank);
+	ASSERT(6 == list_length(&variable_bank));
+	tmp = new_secvar("PK", 3, noPK_auth, noPK_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(1 == list_length(&update_bank));
+	printf("Add invalid dbx\n");
+	tmp = new_secvar("dbx", 4, wrongdbxauth, wrong_dbx_auth_len, 0);
+	ASSERT(0 == edk2_compat_validate(tmp));
+	list_add_tail(&update_bank, &tmp->link);
+	ASSERT(2 == list_length(&update_bank));
+	rc = edk2_compat_process(&variable_bank, &update_bank);
+	ASSERT(OPAL_PARAMETER == rc);
+	ASSERT(6 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	rc = edk2_compat_post_process(&variable_bank, &update_bank);
+	ASSERT(5 == list_length(&variable_bank));
+	tmp = find_secvar("PK", 3, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
+	ASSERT(!setup_mode);
+
+	/* Delete PK. */
+	printf("Delete PK\n");
+	/* Add hw_key_hash explicitly to ensure it is deleted as part of PK deletion. */
+	add_hw_key_hash(&variable_bank);
+	ASSERT(6 == list_length(&variable_bank));
 	tmp = new_secvar("PK", 3, noPK_auth, noPK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
@@ -227,12 +397,14 @@ int run_test()
 	ASSERT(OPAL_SUCCESS == rc);
 	ASSERT(5 == list_length(&variable_bank));
 	ASSERT(0 == list_length(&update_bank));
+	rc = edk2_compat_post_process(&variable_bank, &update_bank);
+	ASSERT(5 == list_length(&variable_bank));
 	tmp = find_secvar("PK", 3, &variable_bank);
 	ASSERT(NULL != tmp);
 	ASSERT(0 == tmp->data_size);
 	ASSERT(setup_mode);
 
-	// Add multiple PK. 
+	/* Add multiple PK. */
 	printf("Multiple PK\n");
 	tmp = new_secvar("PK", 3, multiplePK_auth, multiplePK_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -240,9 +412,15 @@ int run_test()
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS != rc);
-
+	ASSERT(OPAL_PARAMETER == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("PK", 3, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 == tmp->data_size);
+	ASSERT(setup_mode);
 
+	/* Add invalid dbx like with wrong GUID. */
 	printf("Add invalid dbx\n");
 	tmp = new_secvar("dbx", 4, wrongdbxauth, wrong_dbx_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -250,8 +428,11 @@ int run_test()
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS != rc);
+	ASSERT(OPAL_PARAMETER == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
 
+	/* Ensure sha512 dbx is considered as valid. */
 	printf("Add sha512 dbx\n");
 	tmp = new_secvar("dbx", 4, dbx512, dbx512_auth_len, 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
@@ -260,15 +441,23 @@ int run_test()
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
 	ASSERT(OPAL_SUCCESS == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
+	tmp = find_secvar("dbx", 4, &variable_bank);
+	ASSERT(NULL != tmp);
+	ASSERT(0 != tmp->data_size);
 
+	/* We do not support cert as dbx. */
 	printf("Add db(cert) as dbx\n");
-	tmp = new_secvar("dbx", 4, DB_auth, sizeof(DB_auth), 0);
+	tmp = new_secvar("dbx", 4, dbx_cert_auth, sizeof(dbx_cert_auth), 0);
 	ASSERT(0 == edk2_compat_validate(tmp));
 	list_add_tail(&update_bank, &tmp->link);
 	ASSERT(1 == list_length(&update_bank));
 
 	rc = edk2_compat_process(&variable_bank, &update_bank);
-	ASSERT(OPAL_SUCCESS != rc);
+	ASSERT(OPAL_PARAMETER == rc);
+	ASSERT(5 == list_length(&variable_bank));
+	ASSERT(0 == list_length(&update_bank));
 
 	return 0;
 }
-- 
2.21.1



More information about the Skiboot mailing list