| 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 recovery when we hit the NVRAM write limit for an unowned TPM. | 6 /* Test of recovery when we hit the NVRAM write limit for an unowned TPM. |
| 7 */ | 7 */ |
| 8 | 8 |
| 9 #include <stdio.h> | 9 #include <stdio.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 TPM_CHECK(TlclForceClear()); | 29 TPM_CHECK(TlclForceClear()); |
| 30 TPM_CHECK(TlclSetEnable()); | 30 TPM_CHECK(TlclSetEnable()); |
| 31 TPM_CHECK(TlclSetDeactivated(0)); | 31 TPM_CHECK(TlclSetDeactivated(0)); |
| 32 | 32 |
| 33 for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) { | 33 for (i = 0; i < TPM_MAX_NV_WRITES_NOOWNER + 2; i++) { |
| 34 printf("writing %d\n", i); | 34 printf("writing %d\n", i); |
| 35 if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) { | 35 if ((result = TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))) != TPM_SUCCESS) { |
| 36 switch (result) { | 36 switch (result) { |
| 37 case TPM_E_MAXNVWRITES: | 37 case TPM_E_MAXNVWRITES: |
| 38 assert(i >= TPM_MAX_NV_WRITES_NOOWNER); | 38 assert(i >= TPM_MAX_NV_WRITES_NOOWNER); |
| 39 break; |
| 39 default: | 40 default: |
| 40 error("unexpected error code %d (0x%x)\n", result, result); | 41 error("unexpected error code %d (0x%x)\n", result, result); |
| 41 } | 42 } |
| 42 } | 43 } |
| 43 } | 44 } |
| 44 | 45 |
| 45 /* Reset write count */ | 46 /* Reset write count */ |
| 46 TPM_CHECK(TlclForceClear()); | 47 TPM_CHECK(TlclForceClear()); |
| 47 TPM_CHECK(TlclSetEnable()); | 48 TPM_CHECK(TlclSetEnable()); |
| 48 TPM_CHECK(TlclSetDeactivated(0)); | 49 TPM_CHECK(TlclSetDeactivated(0)); |
| 49 | 50 |
| 50 /* Try writing again. */ | 51 /* Try writing again. */ |
| 51 TPM_CHECK(TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))); | 52 TPM_CHECK(TlclWrite(INDEX0, (uint8_t*)&i, sizeof(i))); |
| 52 | 53 |
| 53 printf("TEST SUCCEEDED\n"); | 54 printf("TEST SUCCEEDED\n"); |
| 54 exit(0); | 55 exit(0); |
| 55 } | 56 } |
| OLD | NEW |