| OLD | NEW |
| 1 /* Software-Based Trusted Platform Module (TPM) Emulator for Linux | 1 /* Software-based Trusted Platform Module (TPM) Emulator |
| 2 * Copyright (C) 2004 Mario Strasser <mast@gmx.net>, | 2 * Copyright (C) 2004-2010 Mario Strasser <mast@gmx.net> |
| 3 * Swiss Federal Institute of Technology (ETH) Zurich | |
| 4 * | 3 * |
| 5 * This module is free software; you can redistribute it and/or modify | 4 * This module is free software; you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License as published | 5 * it under the terms of the GNU General Public License as published |
| 7 * by the Free Software Foundation; either version 2 of the License, | 6 * by the Free Software Foundation; either version 2 of the License, |
| 8 * or (at your option) any later version. | 7 * or (at your option) any later version. |
| 9 * | 8 * |
| 10 * This module is distributed in the hope that it will be useful, | 9 * This module is distributed in the hope that it will be useful, |
| 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
| 14 * | 13 * |
| 15 * $Id$ | 14 * $Id: tpm_migration.c 367 2010-02-13 15:52:18Z mast $ |
| 16 */ | 15 */ |
| 17 | 16 |
| 18 #include "tpm_emulator.h" | 17 #include "tpm_emulator.h" |
| 19 #include "tpm_commands.h" | 18 #include "tpm_commands.h" |
| 20 #include "tpm_handles.h" | 19 #include "tpm_handles.h" |
| 21 #include "tpm_data.h" | 20 #include "tpm_data.h" |
| 22 #include "tpm_marshalling.h" | 21 #include "tpm_marshalling.h" |
| 23 #include "crypto/sha1.h" | 22 #include "crypto/sha1.h" |
| 24 #include "crypto/hmac.h" | 23 #include "crypto/hmac.h" |
| 25 | 24 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 TPM_MIGRATE_SCHEME migrationType, | 64 TPM_MIGRATE_SCHEME migrationType, |
| 66 TPM_MIGRATIONKEYAUTH *migrationKeyAuth, | 65 TPM_MIGRATIONKEYAUTH *migrationKeyAuth, |
| 67 UINT32 encDataSize, BYTE *encData, | 66 UINT32 encDataSize, BYTE *encData, |
| 68 TPM_AUTH *auth1, TPM_AUTH *auth2, | 67 TPM_AUTH *auth1, TPM_AUTH *auth2, |
| 69 UINT32 *randomSize, BYTE **random, | 68 UINT32 *randomSize, BYTE **random, |
| 70 UINT32 *outDataSize, BYTE **outData) | 69 UINT32 *outDataSize, BYTE **outData) |
| 71 { | 70 { |
| 72 TPM_RESULT res; | 71 TPM_RESULT res; |
| 73 TPM_KEY_DATA *parent; | 72 TPM_KEY_DATA *parent; |
| 74 TPM_SESSION_DATA *session; | 73 TPM_SESSION_DATA *session; |
| 75 BYTE *ptr, *buf, *key_buf; | 74 BYTE *key_buf; |
| 76 UINT32 len, key_buf_size; | 75 UINT32 key_buf_size; |
| 77 TPM_STORE_ASYMKEY store; | 76 TPM_STORE_ASYMKEY store; |
| 78 TPM_PUBKEY_DATA key; | 77 TPM_PUBKEY_DATA key; |
| 79 | 78 |
| 80 info("TPM_CreateMigrationBlob()"); | 79 info("TPM_CreateMigrationBlob()"); |
| 81 /* get parent key */ | 80 /* get parent key */ |
| 82 parent = tpm_get_key(parentHandle); | 81 parent = tpm_get_key(parentHandle); |
| 83 if (parent == NULL) return TPM_INVALID_KEYHANDLE; | 82 if (parent == NULL) return TPM_INVALID_KEYHANDLE; |
| 84 /* verify parent authorization */ | 83 /* verify parent authorization */ |
| 85 res = tpm_verify_auth(auth1, parent->usageAuth, parentHandle); | 84 res = tpm_verify_auth(auth1, parent->usageAuth, parentHandle); |
| 86 if (res != TPM_SUCCESS) return res; | 85 if (res != TPM_SUCCESS) return res; |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 964 } | 963 } |
| 965 if (tpm_encrypt_private_key(parent, &store, *outData, outDataSize)) { | 964 if (tpm_encrypt_private_key(parent, &store, *outData, outDataSize)) { |
| 966 debug("tpm_encrypt_private_key() failed"); | 965 debug("tpm_encrypt_private_key() failed"); |
| 967 tpm_free(*outData); | 966 tpm_free(*outData); |
| 968 tpm_free(buf); | 967 tpm_free(buf); |
| 969 return TPM_ENCRYPT_ERROR; | 968 return TPM_ENCRYPT_ERROR; |
| 970 } | 969 } |
| 971 tpm_free(buf); | 970 tpm_free(buf); |
| 972 return TPM_SUCCESS; | 971 return TPM_SUCCESS; |
| 973 } | 972 } |
| OLD | NEW |