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

Side by Side Diff: tests/tpm_lite/redefine.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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/tpm_lite/readonly.c ('k') | tests/tpm_lite/redefine_unowned.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 protection from space redefinition.
7 *
8 * This test is actually not that interesting because, if I am right, space
9 * redefinition is not allowed with PP only. It requires
10 * TPM_TAG_RQU_AUTH1_COMMAND with owner authentication.
11 */
12
13 #include <stdio.h>
14 #include <stdint.h>
15 #include <stdlib.h>
16
17 #include "tlcl.h"
18 #include "utility.h"
19
20 #define INDEX0 0xcafe
21 #define INDEX1 0xcaff
22
23 int main(int argc, char** argv) {
24 uint32_t perm;
25 uint32_t result;
26 uint32_t x;
27
28 TlclLibInit();
29 TlclStartup();
30 TlclSelfTestFull();
31 TlclAssertPhysicalPresence();
32
33 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x));
34 if (result == TPM_E_BADINDEX) {
35 VBDEBUG(("creating INDEX0\n"));
36 } else {
37 VBDEBUG(("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 VBDEBUG(("redefining INDEX1\n"));
45 } else {
46 VBDEBUG(("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 = TlclDefineSpace(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 = TlclDefineSpace(INDEX0, perm, sizeof(uint32_t));
66 if (result == TPM_SUCCESS) {
67 error("unexpected success redefining INDEX0\n");
68 exit(1);
69 }
70 result = TlclDefineSpace(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
« no previous file with comments | « tests/tpm_lite/readonly.c ('k') | tests/tpm_lite/redefine_unowned.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698