| 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 /* Testing: ForceClear and behavior of disable and permanent deactivated flags. | 6 /* Testing: ForceClear and behavior of disable and permanent deactivated flags. |
| 7 * | 7 * |
| 8 * ForceClear sets the permanent disable and deactivated flags to their default | 8 * ForceClear sets the permanent disable and deactivated flags to their default |
| 9 * value of TRUE. The specs say nothing about STCLEAR flags, so they should be | 9 * value of TRUE. The specs say nothing about STCLEAR flags, so they should be |
| 10 * left alone. This test checks that both flags may be reset without a reboot, | 10 * left alone. This test checks that both flags may be reset without a reboot, |
| 11 * resulting in a fully enabled and activated TPM. (We know that because | 11 * resulting in a fully enabled and activated TPM. (We know that because |
| 12 * ForceClear requires that the TPM be enabled and activated to run.) | 12 * ForceClear requires that the TPM be enabled and activated to run.) |
| 13 */ | 13 */ |
| 14 | 14 |
| 15 #include <stdio.h> | 15 #include <stdio.h> |
| 16 | 16 |
| 17 #include "tlcl.h" | 17 #include "tlcl.h" |
| 18 #include "tlcl_tests.h" |
| 18 #include "utility.h" | 19 #include "utility.h" |
| 19 | 20 |
| 20 #define CHECK(command) do { if ((command) != TPM_SUCCESS) \ | |
| 21 error(#command "\n"); } \ | |
| 22 while(0) | |
| 23 | |
| 24 int main(int argc, char** argv) { | 21 int main(int argc, char** argv) { |
| 25 uint8_t disable, deactivated; | 22 uint8_t disable, deactivated; |
| 26 int i; | 23 int i; |
| 27 | 24 |
| 28 TlclLibInit(); | 25 TlclLibInit(); |
| 29 CHECK(TlclStartup()); | 26 TPM_CHECK(TlclStartupIfNeeded()); |
| 30 CHECK(TlclSelfTestFull()); | 27 TPM_CHECK(TlclSelfTestFull()); |
| 31 | 28 TPM_CHECK(TlclAssertPhysicalPresence()); |
| 32 CHECK(TlclAssertPhysicalPresence()); | 29 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL)); |
| 33 printf("PP asserted\n"); | |
| 34 | |
| 35 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | |
| 36 printf("disable is %d, deactivated is %d\n", disable, deactivated); | 30 printf("disable is %d, deactivated is %d\n", disable, deactivated); |
| 37 | 31 |
| 38 for (i = 0; i < 2; i++) { | 32 for (i = 0; i < 2; i++) { |
| 39 | 33 TPM_CHECK(TlclForceClear()); |
| 40 CHECK(TlclForceClear()); | 34 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL)); |
| 41 printf("tpm is cleared\n"); | |
| 42 | |
| 43 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | |
| 44 printf("disable is %d, deactivated is %d\n", disable, deactivated); | 35 printf("disable is %d, deactivated is %d\n", disable, deactivated); |
| 45 | 36 assert(disable == 1 && deactivated == 1); |
| 46 CHECK(TlclSetEnable()); | 37 TPM_CHECK(TlclSetEnable()); |
| 47 printf("disable flag is cleared\n"); | 38 TPM_CHECK(TlclSetDeactivated(0)); |
| 48 | 39 TPM_CHECK(TlclGetFlags(&disable, &deactivated, NULL)); |
| 49 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | |
| 50 printf("disable is %d, deactivated is %d\n", disable, deactivated); | 40 printf("disable is %d, deactivated is %d\n", disable, deactivated); |
| 51 | 41 assert(disable == 0 && deactivated == 0); |
| 52 CHECK(TlclSetDeactivated(0)); | |
| 53 printf("deactivated flag is cleared\n"); | |
| 54 | |
| 55 CHECK(TlclGetFlags(&disable, &deactivated, NULL)); | |
| 56 printf("disable is %d, deactivated is %d\n", disable, deactivated); | |
| 57 } | 42 } |
| 58 | 43 |
| 44 printf("TEST SUCCEEDED\n"); |
| 59 return 0; | 45 return 0; |
| 60 } | 46 } |
| OLD | NEW |