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

Unified Diff: src/platform/tpm_lite/src/testsuite/writelimit.c

Issue 1056001: Additional cases for the test suite, and more commands added to TLCL (Closed)
Patch Set: Various fixes for review Created 10 years, 9 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 | « src/platform/tpm_lite/src/testsuite/lock.c ('k') | src/platform/tpm_lite/src/tlcl/generator.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/platform/tpm_lite/src/testsuite/writelimit.c
diff --git a/src/platform/tpm_lite/src/testsuite/writelimit.c b/src/platform/tpm_lite/src/testsuite/writelimit.c
new file mode 100644
index 0000000000000000000000000000000000000000..b2a251a48fbbab7534000edd9f6c6c6488acfc69
--- /dev/null
+++ b/src/platform/tpm_lite/src/testsuite/writelimit.c
@@ -0,0 +1,60 @@
+/* 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 recovery when we hit the NVRAM write limit for an unowned TPM.
+ */
+
+#include <stdio.h>
+#include <stdint.h>
+#include <stdlib.h>
+#include <tss/tcs.h>
+
+#include "tlcl.h"
+
+#define INDEX0 0xda70
+#define TPM_MAX_NV_WRITES_NOOWNER 64
+
+int main(void) {
+ int i;
+ uint32_t result;
+ uint8_t disable, deactivated; /* the TPM specs use these exact names */
+
+ TlclLibinit();
+
+ TlclStartup();
+ TlclSelftestfull();
+
+ TlclAssertPhysicalPresence();
+
+ result = TlclGetFlags(&disable, &deactivated);
+ printf("disable is %d, deactivated is %d\n", disable, deactivated);
+
+ if (disable || deactivated) {
+ TlclPhysicalEnable();
+ (void) TlclPhysicalSetDeactivated(0);
+ printf("TPM will be active after next reboot\n");
+ exit(0);
+ }
+
+ for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
+ printf("writing %d\n", i);
+ if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
+ switch (result) {
+ case TPM_E_MAXNVWRITES:
+ printf("Max NV writes exceeded - forcing clear\n");
+ TlclForceClear();
+ printf("Please reboot and run this program again\n");
+ exit(0);
+ default:
+ error("unexpected error code %d (0x%x)\n");
+ }
+ }
+ }
+
+ /* Done for now.
+ */
+ printf("Test completed successfully\n");
+ exit(0);
+}
« no previous file with comments | « src/platform/tpm_lite/src/testsuite/lock.c ('k') | src/platform/tpm_lite/src/tlcl/generator.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698