blob: 6cdb8d8babd4cca4cac51e41d400519fcbdc29e6 [file] [log] [blame]
Etienne Carriere75141172020-05-16 11:58:23 +02001// SPDX-License-Identifier: BSD-2-Clause
Igor Opaniuk44aff4b2016-09-16 10:18:00 +03002/*
3 * Copyright (c) 2015, Linaro Limited
Zexi Yue18381f2023-10-30 11:29:51 +08004
Igor Opaniuk44aff4b2016-09-16 10:18:00 +03005 */
6
7#include <tee_ta_api.h>
Jerome Forissier24ce5ab2017-09-25 12:44:22 -07008#include <trace.h>
Igor Opaniuk44aff4b2016-09-16 10:18:00 +03009
Zexi Yue18381f2023-10-30 11:29:51 +080010#include "ta_crypto_perf.h"
11#include "ta_crypto_perf_priv.h"
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030012
13/*
14 * Trusted Application Entry Points
15 */
16
17/* Called each time a new instance is created */
18TEE_Result TA_CreateEntryPoint(void)
19{
20 return TEE_SUCCESS;
21}
22
23/* Called each time an instance is destroyed */
24void TA_DestroyEntryPoint(void)
25{
26}
27
28/* Called each time a session is opened */
29TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes,
30 TEE_Param pParams[4],
31 void **ppSessionContext)
32{
33 (void)nParamTypes;
34 (void)pParams;
35 (void)ppSessionContext;
36 return TEE_SUCCESS;
37}
38
39/* Called each time a session is closed */
40void TA_CloseSessionEntryPoint(void *pSessionContext)
41{
42 (void)pSessionContext;
43
44 cmd_clean_res();
45}
46
47/* Called when a command is invoked */
48TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
49 uint32_t nCommandID, uint32_t nParamTypes,
50 TEE_Param pParams[4])
51{
52 (void)pSessionContext;
53
54 switch (nCommandID) {
Zexi Yue18381f2023-10-30 11:29:51 +080055 case TA_CRYPTO_PERF_CMD_CIPHER_PREPARE_KEY:
56 return cmd_cipher_prepare_key(nParamTypes, pParams);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030057
Zexi Yue18381f2023-10-30 11:29:51 +080058 case TA_CRYPTO_PERF_CMD_CIPHER_PROCESS:
59 return cmd_cipher_process(nParamTypes, pParams, false);
60 case TA_CRYPTO_PERF_CMD_CIPHER_PROCESS_SDP:
Etienne Carriereb85a5f92017-05-03 18:21:56 +020061#ifdef CFG_SECURE_DATA_PATH
Zexi Yue18381f2023-10-30 11:29:51 +080062 return cmd_cipher_process(nParamTypes, pParams, true);
Etienne Carriereb85a5f92017-05-03 18:21:56 +020063#else
64 EMSG("Invalid SDP commands: TA was built without SDP support");
65 return TEE_ERROR_NOT_SUPPORTED;
66#endif
Zexi Yue18381f2023-10-30 11:29:51 +080067 case TA_CRYPTO_PERF_CMD_HASH_PREPARE_OP:
68 return cmd_hash_prepare_op(nParamTypes, pParams);
69 case TA_CRYPTO_PERF_CMD_HASH_PROCESS:
70 return cmd_hash_process(nParamTypes, pParams);
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030071
72 default:
73 return TEE_ERROR_BAD_PARAMETERS;
74 }
75}