os_test: get client identity
Add helper method to query current client identity for session login
testing.
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Jerome Forissier <jerome@forissier.org>
Signed-off-by: Vesa Jääskeläinen <vesa.jaaskelainen@vaisala.com>
diff --git a/ta/os_test/include/os_test.h b/ta/os_test/include/os_test.h
index 6c3d4c4..88124f0 100644
--- a/ta/os_test/include/os_test.h
+++ b/ta/os_test/include/os_test.h
@@ -48,5 +48,6 @@
TEE_Result ta_entry_call_lib_dl(uint32_t param_types, TEE_Param params[4]);
TEE_Result ta_entry_call_lib_dl_panic(uint32_t param_types, TEE_Param params[4]);
TEE_Result ta_entry_get_global_var(uint32_t param_types, TEE_Param params[4]);
+TEE_Result ta_entry_client_identity(uint32_t param_types, TEE_Param params[4]);
#endif /*OS_TEST_H */
diff --git a/ta/os_test/include/ta_os_test.h b/ta/os_test/include/ta_os_test.h
index 4a53dd8..fc0b010 100644
--- a/ta/os_test/include/ta_os_test.h
+++ b/ta/os_test/include/ta_os_test.h
@@ -50,5 +50,6 @@
#define TA_OS_TEST_CMD_CALL_LIB_DL_PANIC 17
#define TA_OS_TEST_CMD_GET_GLOBAL_VAR 18
#define TA_OS_TEST_CMD_NULL_MEMREF_PARAMS 19
+#define TA_OS_TEST_CMD_CLIENT_IDENTITY 20
#endif /*TA_OS_TEST_H */
diff --git a/ta/os_test/os_test.c b/ta/os_test/os_test.c
index ccf16e3..9d22684 100644
--- a/ta/os_test/os_test.c
+++ b/ta/os_test/os_test.c
@@ -1214,3 +1214,34 @@
return TEE_SUCCESS;
}
+
+TEE_Result ta_entry_client_identity(uint32_t param_types, TEE_Param params[4])
+{
+ TEE_PropSetHandle *propset = NULL;
+ TEE_Result res = TEE_ERROR_GENERIC;
+ TEE_Identity identity = { };
+
+ if (param_types != TEE_PARAM_TYPES(TEE_PARAM_TYPE_VALUE_OUTPUT,
+ TEE_PARAM_TYPE_MEMREF_OUTPUT,
+ TEE_PARAM_TYPE_NONE,
+ TEE_PARAM_TYPE_NONE))
+ return TEE_ERROR_BAD_PARAMETERS;
+
+ if (params[1].memref.size < sizeof(TEE_UUID)) {
+ params[1].memref.size = sizeof(TEE_UUID);
+ return TEE_ERROR_SHORT_BUFFER;
+ }
+
+ res = TEE_GetPropertyAsIdentity(TEE_PROPSET_CURRENT_CLIENT,
+ "gpd.client.identity", &identity);
+ if (res != TEE_SUCCESS) {
+ EMSG("TEE_GetPropertyAsIdentity: returned %#"PRIx32, res);
+ return res;
+ }
+
+ params[0].value.a = identity.login;
+ memcpy(params[1].memref.buffer, &identity.uuid, sizeof(TEE_UUID));
+ params[1].memref.size = sizeof(TEE_UUID);
+
+ return res;
+}
diff --git a/ta/os_test/ta_entry.c b/ta/os_test/ta_entry.c
index 7abda1c..516e6f2 100644
--- a/ta/os_test/ta_entry.c
+++ b/ta/os_test/ta_entry.c
@@ -127,6 +127,9 @@
case TA_OS_TEST_CMD_GET_GLOBAL_VAR:
return ta_entry_get_global_var(nParamTypes, pParams);
+ case TA_OS_TEST_CMD_CLIENT_IDENTITY:
+ return ta_entry_client_identity(nParamTypes, pParams);
+
default:
return TEE_ERROR_BAD_PARAMETERS;
}