#include "config.h"\r
#include <string.h>\r
#include <set>\r
+#include "log.h"\r
\r
using namespace std;\r
\r
/**\r
* Initialization routine of PropertyAccess Module. This function should be\r
* called when TA stub starts with UUID of this TA.\r
- * @param UUID[in] UUID of this TA\r
+ * @param uuid[in] UUID of our TA\r
+ * @param taDir[in] Directory in which TA resides\r
* @param clientLogin[in] login method to this TA from client.\r
* Refer Table 4-13: Client Identities\r
* @return TEE_ERROR_OUT_OF_MEMORY on failure to initialize else TEE_SUCCESS\r
*/\r
-TEE_Result InitPropertyModule(char* UUID, uint32_t clientLogin) {\r
+TEE_Result InitPropertyModule(const std::string& uuid,\r
+ const std::string& taDir, uint32_t clientLogin) {\r
PropertyValue pv;\r
pv.type = "identity";\r
pv.value = "" + clientLogin;\r
- string thisTA_UUID(UUID);\r
+\r
clientLoginGlobal = clientLogin;\r
- thisTAUUIDGlobal = thisTA_UUID;\r
+ thisTAUUIDGlobal = uuid;\r
+\r
try {\r
clientProperty = new ClientProperty(pv);\r
clientProperty->start();\r
teeProperty = new TEEProperty();\r
teeProperty->start();\r
- taProperty = new TAProperty(\r
- string(TEE_TASTORE_ROOT) + thisTA_UUID + "-ext/" + thisTA_UUID\r
- + ".manifest");\r
+ taProperty = new TAProperty(taDir + uuid + ".manifest");\r
taProperty->start();\r
} catch (std::bad_alloc &ba) {\r
return TEE_ERROR_OUT_OF_MEMORY;\r
/*-----------------------------------------------------------------------------\r
* Functions\r
*-----------------------------------------------------------------------------*/\r
-TEE_Result InitPropertyModule(char* UUID, uint32_t clientLogin);\r
+TEE_Result InitPropertyModule(const std::string& uuid,\r
+ const std::string& taDir, uint32_t clientLogin);\r
void DeInitPropertyModule();\r
\r
#ifdef __cplusplus\r
//for export function
getSharedMemoryAddress(0);
+ std::string fullPath(argv[0]);
+
+ // parse UUID from TA's full executable path
+ size_t lastSlashPos = fullPath.rfind('/');
+ size_t taExtPos = fullPath.rfind('.');
+ std::string uuid = fullPath.substr(lastSlashPos + 1, taExtPos - lastSlashPos - 1);
+
+ // grab full TA directory to be able to open the manifest
+ std::string taDir = fullPath.substr(0, lastSlashPos + 1);
+ LOGI(TEE_STUB, "UUID: %s, TA directory: %s", uuid.c_str(), taDir.c_str());
+
// Initialize Properties module
// TODO: fetch login method from Context, not to be hardcoded
TEE_Result initStatus;
- char uuid[100];
- int uuidlen = strlen(argv[0]);
- LOGI(TEE_STUB, "argv[0]: %s\n", argv[0]);
- LOGI(TEE_STUB, "argv[1]: %s\n", argv[1]);
- // fetch uuid from argv[0]
- int i, j;
- for (i = uuidlen - 38, j = 0; i < uuidlen - 6; j++, i++) {
- uuid[j] = argv[0][i];
- }
- uuid[j] = '\0';
// Inititalize the property module
- initStatus = InitPropertyModule(uuid, TEE_LOGIN_PUBLIC);
+ initStatus = InitPropertyModule(uuid, taDir, TEE_LOGIN_PUBLIC);
+
// Pass UUID to SSF
TEE_UUID out;
PropertyValue pv;
pv.type = "uuid";
- pv.value = string(uuid);
+ pv.value = uuid;
PropertyUtility::convertToUUID(pv, out);
ssf_sharedthisTAUUID = out;