blob: edefea99f4b291b850b71f2ec5b8f7084574f3df [file] [log] [blame]
Igor Opaniuk44aff4b2016-09-16 10:18:00 +03001/*
2 * Copyright (c) 2015, Linaro Limited
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 *
8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 *
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <tee_ta_api.h>
29
30#include "ta_aes_perf.h"
31#include "ta_aes_perf_priv.h"
32
33/*
34 * Trusted Application Entry Points
35 */
36
37/* Called each time a new instance is created */
38TEE_Result TA_CreateEntryPoint(void)
39{
40 return TEE_SUCCESS;
41}
42
43/* Called each time an instance is destroyed */
44void TA_DestroyEntryPoint(void)
45{
46}
47
48/* Called each time a session is opened */
49TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes,
50 TEE_Param pParams[4],
51 void **ppSessionContext)
52{
53 (void)nParamTypes;
54 (void)pParams;
55 (void)ppSessionContext;
56 return TEE_SUCCESS;
57}
58
59/* Called each time a session is closed */
60void TA_CloseSessionEntryPoint(void *pSessionContext)
61{
62 (void)pSessionContext;
63
64 cmd_clean_res();
65}
66
67/* Called when a command is invoked */
68TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
69 uint32_t nCommandID, uint32_t nParamTypes,
70 TEE_Param pParams[4])
71{
72 (void)pSessionContext;
73
74 switch (nCommandID) {
75 case TA_AES_PERF_CMD_PREPARE_KEY:
76 return cmd_prepare_key(nParamTypes, pParams);
77
78 case TA_AES_PERF_CMD_PROCESS:
Etienne Carriereb85a5f92017-05-03 18:21:56 +020079 return cmd_process(nParamTypes, pParams, false);
80 case TA_AES_PERF_CMD_PROCESS_SDP:
81#ifdef CFG_SECURE_DATA_PATH
82 return cmd_process(nParamTypes, pParams, true);
83#else
84 EMSG("Invalid SDP commands: TA was built without SDP support");
85 return TEE_ERROR_NOT_SUPPORTED;
86#endif
Igor Opaniuk44aff4b2016-09-16 10:18:00 +030087
88 default:
89 return TEE_ERROR_BAD_PARAMETERS;
90 }
91}