OLD | NEW |
(Empty) | |
| 1 /* Software-based Mobile Trusted Module (MTM) Emulator |
| 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
| 3 * |
| 4 * This module is free software; you can redistribute it and/or modify |
| 5 * it under the terms of the GNU General Public License as published |
| 6 * by the Free Software Foundation; either version 2 of the License, |
| 7 * or (at your option) any later version. |
| 8 * |
| 9 * This module is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 * GNU General Public License for more details. |
| 13 * |
| 14 * $Id$ |
| 15 */ |
| 16 |
| 17 #include "mtm_data.h" |
| 18 #include "tpm/tpm_data.h" |
| 19 |
| 20 MTM_DATA mtmData; |
| 21 |
| 22 static void set_counter(unsigned int num, const char *label) |
| 23 { |
| 24 TPM_COUNTER_VALUE *counter = &tpmData.permanent.data.counters[num]; |
| 25 counter->valid = TRUE; |
| 26 counter->tag = TPM_TAG_COUNTER_VALUE; |
| 27 memcpy(counter->label, label, sizeof(counter->label)); |
| 28 counter->counter = 1; |
| 29 memset(counter->usageAuth, 0, sizeof(TPM_SECRET)); |
| 30 } |
| 31 |
| 32 void mtm_init_data(void) |
| 33 { |
| 34 int i; |
| 35 info("initializing MTM data to default values"); |
| 36 /* reset all data to NULL, FALSE or 0 */ |
| 37 memset(&mtmData, 0, sizeof(mtmData)); |
| 38 mtmData.permanent.data.tag = MTM_TAG_PERMANENT_DATA; |
| 39 /* set specification version */ |
| 40 mtmData.permanent.data.specMajor = 0x01; |
| 41 mtmData.permanent.data.specMinor = 0x00; |
| 42 /* define verified PCRs */ |
| 43 mtmData.permanent.data.verifiedPCRs.sizeOfSelect = TPM_NUM_PCR / 8; |
| 44 for (i = 0; i < TPM_NUM_PCR / 8; i++) { |
| 45 mtmData.permanent.data.verifiedPCRs.pcrSelect[i] = 0x00; |
| 46 } |
| 47 /* map MTM counters to TPM counters */ |
| 48 set_counter(MTM_COUNTER_SELECT_BOOTSTRAP, "MTM1"); |
| 49 set_counter(MTM_COUNTER_SELECT_RIMPROTECT, "MTM2"); |
| 50 set_counter(MTM_COUNTER_SELECT_STORAGEPROTECT, "MTM3"); |
| 51 /* the field integrityCheckRootData is filled when the first verification key
is loaded */ |
| 52 memset(mtmData.permanent.data.integrityCheckRootData, 0xff, |
| 53 sizeof(mtmData.permanent.data.integrityCheckRootData)); |
| 54 /* set internal verification key */ |
| 55 memcpy(mtmData.permanent.data.internalVerificationKey, |
| 56 "\x77\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" |
| 57 "\x00\x00\x00\x77", sizeof(TPM_SECRET)); |
| 58 /* init flags */ |
| 59 mtmData.stany.flags.tag = MTM_TAG_STANY_FLAGS; |
| 60 mtmData.stany.flags.loadVerificationRootKeyEnabled = TRUE; |
| 61 } |
| 62 |
OLD | NEW |