Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Unified Diff: tests/tpm_lite/redefine_unowned.c

Issue 3389004: Rehaul of firmware TPM tests (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: remove leaked change Created 10 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/tpm_lite/redefine.c ('k') | tests/tpm_lite/spaceperm.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/tpm_lite/redefine_unowned.c
diff --git a/tests/tpm_lite/redefine_unowned.c b/tests/tpm_lite/redefine_unowned.c
new file mode 100644
index 0000000000000000000000000000000000000000..eb5dfe5d45b3acd272c13eff9787efc1d9fbfc73
--- /dev/null
+++ b/tests/tpm_lite/redefine_unowned.c
@@ -0,0 +1,64 @@
+/* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+/* Test of protection from space redefinition when an owner is NOT present.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+#include "tlcl.h"
+#include "tlcl_tests.h"
+#include "utility.h"
+
+int main(int argc, char** argv) {
+ uint32_t perm;
+ uint32_t result;
+ uint32_t x;
+
+ TlclLibInit();
+ TPM_CHECK(TlclStartupIfNeeded());
+ TPM_CHECK(TlclSelfTestFull());
+ TPM_CHECK(TlclAssertPhysicalPresence());
+
+ assert(!TlclIsOwned());
+
+ /* Ensures spaces exist. */
+ TPM_CHECK(TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)));
+ TPM_CHECK(TlclRead(INDEX1, (uint8_t*) &x, sizeof(x)));
+
+ /* Redefines spaces a couple of times. */
+ perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
+ TPM_CHECK(TlclDefineSpace(INDEX0, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)));
+
+ perm = TPM_NV_PER_PPWRITE;
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
+
+ // Sets the global lock.
+ TlclSetGlobalLock();
+
+ // Verifies that index0 cannot be redefined.
+ result = TlclDefineSpace(INDEX0, perm, sizeof(uint32_t));
+ assert(result == TPM_E_AREA_LOCKED);
+
+ // Checks that index1 can.
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, 2 * sizeof(uint32_t)));
+ TPM_CHECK(TlclDefineSpace(INDEX1, perm, sizeof(uint32_t)));
+
+ // Turns off PP.
+ TlclLockPhysicalPresence();
+
+ // Verifies that neither index0 nor index1 can be redefined.
+ result = TlclDefineSpace(INDEX0, perm, sizeof(uint32_t));
+ assert(result == TPM_E_BAD_PRESENCE);
+ result = TlclDefineSpace(INDEX1, perm, sizeof(uint32_t));
+ assert(result == TPM_E_BAD_PRESENCE);
+
+ printf("TEST SUCCEEDED\n");
+ exit(0);
+}
« no previous file with comments | « tests/tpm_lite/redefine.c ('k') | tests/tpm_lite/spaceperm.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698