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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file.
4 */
5
6 /* Test of recovery when we hit the NVRAM write limit for an unowned TPM.
7 */
8
9 #include <stdio.h>
10 #include <stdint.h>
11 #include <stdlib.h>
12 #include <tss/tcs.h>
13
14 #include "tlcl.h"
15
16 #define INDEX0 0xda70
17 #define TPM_MAX_NV_WRITES_NOOWNER 64
18
19 int main(void) {
20 int i;
21 uint32_t result;
22 uint8_t disable, deactivated; /* the TPM specs use these exact names */
23
24 TlclLibinit();
25
26 TlclStartup();
27 TlclSelftestfull();
28
29 TlclAssertPhysicalPresence();
30
31 result = TlclGetFlags(&disable, &deactivated);
32 printf("disable is %d, deactivated is %d\n", disable, deactivated);
33
34 if (disable || deactivated) {
35 TlclPhysicalEnable();
36 (void) TlclPhysicalSetDeactivated(0);
37 printf("TPM will be active after next reboot\n");
38 exit(0);
39 }
40
41 for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) {
42 printf("writing %d\n", i);
43 if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) {
44 switch (result) {
45 case TPM_E_MAXNVWRITES:
46 printf("Max NV writes exceeded - forcing clear\n");
47 TlclForceClear();
48 printf("Please reboot and run this program again\n");
49 exit(0);
50 default:
51 error("unexpected error code %d (0x%x)\n");
52 }
53 }
54 }
55
56 /* Done for now.
57 */
58 printf("Test completed successfully\n");
59 exit(0);
60 }
OLDNEW
« 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