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

Side by Side Diff: src/testsuite/redefine.c

Issue 2663002: Add space redefinition test, early NV read test and early extend test. (Closed) Base URL: ssh://git@chromiumos-git/tpm_lite.git
Patch Set: Fix printf Created 10 years, 6 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
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 two-stage locking using bGlobalLock and PP.
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 0xcafe
17 #define INDEX1 0xcaff
18
19 int main(int argc, char** argv) {
20 uint32_t perm;
21 uint32_t result;
22 uint32_t x;
23
24 TlclLibInit();
25
26 #if !USE_TPM_EMULATOR
27 TlclStartup();
28 TlclSelftestfull();
29 #endif
30
31 TlclAssertPhysicalPresence();
32
33 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
34 if (result == TPM_E_BADINDEX) {
35 warning("creating INDEX0\n");
36 } else {
37 warning("redefining INDEX0\n");
38 }
39 perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK;
40 TlclDefineSpace(INDEX0, perm, sizeof(uint32_t));
41
42 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
43 if (result == TPM_E_BADINDEX) {
44 warning("redefining INDEX1\n");
45 } else {
46 warning("creating INDEX1\n");
47 }
48 perm = TPM_NV_PER_PPWRITE;
49 TlclDefineSpace(INDEX1, perm, sizeof(uint32_t));
50
51 // Sets the global lock.
52 TlclSetGlobalLock();
53
54 // Verifies that index0 cannot be redefined.
55 result = TlclDefineSpaceResult(INDEX0, perm, sizeof(uint32_t));
56 if (result == TPM_SUCCESS) {
57 error("unexpected success redefining INDEX0\n");
58 exit(1);
59 }
60
61 // Turns off PP.
62 TlclLockPhysicalPresence();
63
64 // Verifies that neither index0 nor index1 cannot be redefined.
65 result = TlclDefineSpaceResult(INDEX0, perm, sizeof(uint32_t));
66 if (result == TPM_SUCCESS) {
67 error("unexpected success redefining INDEX0\n");
68 exit(1);
69 }
70 result = TlclDefineSpaceResult(INDEX1, perm, sizeof(uint32_t));
71 if (result == TPM_SUCCESS) {
72 error("unexpected success redefining INDEX1\n");
73 exit(1);
74 }
75
76 printf("Test completed successfully\n");
77 exit(0);
78 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698