| OLD | NEW |
| 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 * Use of this source code is governed by a BSD-style license that can be |
| 3 * found in the LICENSE file. | 3 * found in the LICENSE file. |
| 4 */ | 4 */ |
| 5 | 5 |
| 6 /* Test of two-stage locking using bGlobalLock and PP. | 6 /* Test of two-stage locking using bGlobalLock and PP. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| 11 #include <stdlib.h> | 11 #include <stdlib.h> |
| 12 #include <tss/tcs.h> | 12 #include <tss/tcs.h> |
| 13 | 13 |
| 14 #include "tlcl.h" | 14 #include "tlcl.h" |
| 15 #include "utility.h" | 15 #include "utility.h" |
| 16 | 16 |
| 17 #define INDEX0 0xcafe | 17 #define INDEX0 0xcafe |
| 18 #define INDEX1 0xcaff | 18 #define INDEX1 0xcaff |
| 19 | 19 |
| 20 int main(int argc, char** argv) { | 20 int main(int argc, char** argv) { |
| 21 uint32_t zero = 0; | 21 uint32_t zero = 0; |
| 22 uint32_t perm; | 22 uint32_t perm; |
| 23 uint32_t result; | 23 uint32_t result; |
| 24 uint32_t x; | 24 uint32_t x; |
| 25 | 25 |
| 26 TlclLibInit(); | 26 TlclLibInit(); |
| 27 | 27 |
| 28 TlclStartup(); | 28 TlclStartup(); |
| 29 TlclSelftestfull(); | 29 TlclSelfTestFull(); |
| 30 | 30 |
| 31 TlclAssertPhysicalPresence(); | 31 TlclAssertPhysicalPresence(); |
| 32 | 32 |
| 33 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)); | 33 result = TlclRead(INDEX0, (uint8_t*) &x, sizeof(x)); |
| 34 if (result == TPM_E_BADINDEX) { | 34 if (result == TPM_E_BADINDEX) { |
| 35 perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK; | 35 perm = TPM_NV_PER_PPWRITE | TPM_NV_PER_GLOBALLOCK; |
| 36 TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)); | 36 TlclDefineSpace(INDEX0, perm, sizeof(uint32_t)); |
| 37 } | 37 } |
| 38 result = TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t)); | 38 result = TlclWrite(INDEX0, (uint8_t*) &zero, sizeof(uint32_t)); |
| 39 assert(result == TPM_SUCCESS); | 39 assert(result == TPM_SUCCESS); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 x = 3; | 72 x = 3; |
| 73 result = TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)); | 73 result = TlclWrite(INDEX1, (uint8_t*) &x, sizeof(x)); |
| 74 if (result != TPM_E_BAD_PRESENCE) { | 74 if (result != TPM_E_BAD_PRESENCE) { |
| 75 error("INDEX1 is not locked\n"); | 75 error("INDEX1 is not locked\n"); |
| 76 exit(3); | 76 exit(3); |
| 77 } | 77 } |
| 78 | 78 |
| 79 printf("Test completed successfully\n"); | 79 printf("Test completed successfully\n"); |
| 80 exit(0); | 80 exit(0); |
| 81 } | 81 } |
| OLD | NEW |