| OLD | NEW |
| 1 | 1 |
| 2 /* | 2 /* |
| 3 * Licensed Materials - Property of IBM | 3 * Licensed Materials - Property of IBM |
| 4 * | 4 * |
| 5 * trousers - An open source TCG Software Stack | 5 * trousers - An open source TCG Software Stack |
| 6 * | 6 * |
| 7 * (C) Copyright International Business Machines Corp. 2004-2006 | 7 * (C) Copyright International Business Machines Corp. 2004-2006 |
| 8 * | 8 * |
| 9 */ | 9 */ |
| 10 | 10 |
| 11 | 11 |
| 12 #include <stdlib.h> | 12 #include <stdlib.h> |
| 13 #include <stdio.h> | 13 #include <stdio.h> |
| 14 #include <string.h> | 14 #include <string.h> |
| 15 | 15 |
| 16 #include "trousers/tss.h" | 16 #include "trousers/tss.h" |
| 17 #include "trousers/trousers.h" | 17 #include "trousers/trousers.h" |
| 18 #include "trousers_types.h" | 18 #include "trousers_types.h" |
| 19 #include "trousers_types.h" | 19 #include "trousers_types.h" |
| 20 #include "spi_utils.h" | 20 #include "spi_utils.h" |
| 21 #include "capabilities.h" | 21 #include "capabilities.h" |
| 22 #include "tsplog.h" | 22 #include "tsplog.h" |
| 23 #include "tcs_tsp.h" | 23 #include "tcs_tsp.h" |
| 24 #include "tspps.h" | 24 #include "tspps.h" |
| 25 #include "hosttable.h" | 25 #include "hosttable.h" |
| 26 #include "tcsd_wrap.h" | 26 #include "tcsd_wrap.h" |
| 27 #include "tcsd.h" | 27 #include "tcsd.h" |
| 28 #include "obj.h" | 28 #include "obj.h" |
| 29 | 29 |
| 30 TSS_UUID owner_evict_uuid = {0, 0, 0, 0, 0, {0, 0, 0, 0, 1, 0}}; |
| 30 | 31 |
| 31 TSS_RESULT | 32 TSS_RESULT |
| 32 Tspi_Context_LoadKeyByUUID(TSS_HCONTEXT tspContext, /* in */ | 33 Tspi_Context_LoadKeyByUUID(TSS_HCONTEXT tspContext, /* in */ |
| 33 TSS_FLAG persistentStorageType, /* in */ | 34 TSS_FLAG persistentStorageType, /* in */ |
| 34 TSS_UUID uuidData, /* in */ | 35 TSS_UUID uuidData, /* in */ |
| 35 TSS_HKEY * phKey) /* out */ | 36 TSS_HKEY * phKey) /* out */ |
| 36 { | 37 { |
| 37 TSS_RESULT result; | 38 TSS_RESULT result; |
| 38 TSS_UUID parentUUID; | 39 TSS_UUID parentUUID; |
| 39 UINT32 keyBlobSize, parentPSType; | 40 UINT32 keyBlobSize, parentPSType; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 if (secret_PerformAuth_OIAP(keyHandle, TPM_ORD_LoadKey,
hPolicy, FALSE, | 79 if (secret_PerformAuth_OIAP(keyHandle, TPM_ORD_LoadKey,
hPolicy, FALSE, |
| 79 &info.paramDigest, &info.aut
hData)) | 80 &info.paramDigest, &info.aut
hData)) |
| 80 return result; | 81 return result; |
| 81 | 82 |
| 82 if ((result = RPC_LoadKeyByUUID(tspContext, uuidData, &i
nfo, | 83 if ((result = RPC_LoadKeyByUUID(tspContext, uuidData, &i
nfo, |
| 83 &tcsKeyHandle))) | 84 &tcsKeyHandle))) |
| 84 return result; | 85 return result; |
| 85 } else if (result) | 86 } else if (result) |
| 86 return result; | 87 return result; |
| 87 | 88 |
| 88 » » if ((result = RPC_GetRegisteredKeyBlob(tspContext, uuidData, &ke
yBlobSize, | 89 » » /*check if provided UUID has an owner evict key UUID prefix */ |
| 89 » » » » » » &keyBlob))) | 90 » » if (!memcmp(&uuidData, &owner_evict_uuid, sizeof(TSS_UUID)-1)) { |
| 90 » » » return result; | 91 » » » if ((result = obj_rsakey_add(tspContext, TSS_RSAKEY_FLAG
_OWNEREVICT, |
| 92 » » » » » » phKey))) |
| 93 » » » » return result; |
| 94 » » } else { |
| 95 » » » if ((result = RPC_GetRegisteredKeyBlob(tspContext, uuidD
ata, &keyBlobSize, |
| 96 » » » » » » » &keyBlob))) |
| 97 » » » » return result; |
| 91 | 98 |
| 92 » » if ((result = obj_rsakey_add_by_key(tspContext, &uuidData, keyBl
ob, | 99 » » » if ((result = obj_rsakey_add_by_key(tspContext, &uuidDat
a, keyBlob, |
| 93 » » » » » » TSS_OBJ_FLAG_SYSTEM_PS, phKe
y))) { | 100 » » » » » » » TSS_OBJ_FLAG_SYSTEM_
PS, phKey))) { |
| 101 » » » » free (keyBlob); |
| 102 » » » » return result; |
| 103 » » » } |
| 104 » |
| 105 » » » result = obj_rsakey_set_tcs_handle(*phKey, tcsKeyHandle)
; |
| 106 |
| 94 free (keyBlob); | 107 free (keyBlob); |
| 95 return result; | |
| 96 } | 108 } |
| 97 | |
| 98 result = obj_rsakey_set_tcs_handle(*phKey, tcsKeyHandle); | |
| 99 | |
| 100 free (keyBlob); | |
| 101 #else | 109 #else |
| 102 if ((result = load_from_system_ps(tspContext, &uuidData, phKey))
) | 110 if ((result = load_from_system_ps(tspContext, &uuidData, phKey))
) |
| 103 return result; | 111 return result; |
| 104 #endif | 112 #endif |
| 105 } else if (persistentStorageType == TSS_PS_TYPE_USER) { | 113 } else if (persistentStorageType == TSS_PS_TYPE_USER) { |
| 106 if ((result = ps_get_parent_uuid_by_uuid(&uuidData, &parentUUID)
)) | 114 if ((result = ps_get_parent_uuid_by_uuid(&uuidData, &parentUUID)
)) |
| 107 return result; | 115 return result; |
| 108 | 116 |
| 109 /* If the parent is not in memory, recursively call ourselves on
it */ | 117 /* If the parent is not in memory, recursively call ourselves on
it */ |
| 110 if (obj_rsakey_get_by_uuid(&parentUUID, &parentTspHandle) != TSS
_SUCCESS) { | 118 if (obj_rsakey_get_by_uuid(&parentUUID, &parentTspHandle) != TSS
_SUCCESS) { |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 545 } | 553 } |
| 546 | 554 |
| 547 if ((result = __tspi_add_mem_entry(tspContext, *ppKeyHierarchy))) { | 555 if ((result = __tspi_add_mem_entry(tspContext, *ppKeyHierarchy))) { |
| 548 free(*ppKeyHierarchy); | 556 free(*ppKeyHierarchy); |
| 549 *ppKeyHierarchy = NULL; | 557 *ppKeyHierarchy = NULL; |
| 550 *pulKeyHierarchySize = 0; | 558 *pulKeyHierarchySize = 0; |
| 551 } | 559 } |
| 552 | 560 |
| 553 return result; | 561 return result; |
| 554 } | 562 } |
| OLD | NEW |