blob: 26f4ed0c2811d8cabd73f019f4cf449b0c2155dc [file] [log] [blame]
Etienne Carriere75141172020-05-16 11:58:23 +02001// SPDX-License-Identifier: BSD-2-Clause
Pascal Brandc639ac82015-07-02 08:53:34 +02002/*
3 * Copyright (c) 2014, STMicroelectronics International N.V.
4 * All rights reserved.
Pascal Brandc639ac82015-07-02 08:53:34 +02005 */
6
7#include <tee_ta_api.h>
8#include <user_ta_header_defines.h>
9#include <ta_rpc.h>
10
11/*
12 * Trusted Application Entry Points
13 */
14
15/* Called each time a new instance is created */
16TEE_Result TA_CreateEntryPoint(void)
17{
18 return TEE_SUCCESS;
19}
20
21/* Called each time an instance is destroyed */
22void TA_DestroyEntryPoint(void)
23{
24}
25
26/* Called each time a session is opened */
27TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, TEE_Param pParams[4],
28 void **ppSessionContext)
29{
30 (void)nParamTypes;
31 (void)pParams;
32 (void)ppSessionContext;
33 return TEE_SUCCESS;
34}
35
36/* Called each time a session is closed */
37void TA_CloseSessionEntryPoint(void *pSessionContext)
38{
39 (void)pSessionContext;
40}
41
42/* Called when a command is invoked */
43TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext,
44 uint32_t nCommandID, uint32_t nParamTypes,
45 TEE_Param pParams[4])
46{
47 (void)pSessionContext;
48
49 switch (nCommandID) {
50 case TA_RPC_CMD_CRYPT_SHA224:
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010051 return rpc_sha224(false, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020052
53 case TA_RPC_CMD_CRYPT_SHA256:
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010054 return rpc_sha256(false, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020055
56 case TA_RPC_CMD_CRYPT_AES256ECB_ENC:
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010057 return rpc_aes256ecb_encrypt(false, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020058
59 case TA_RPC_CMD_CRYPT_AES256ECB_DEC:
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010060 return rpc_aes256ecb_decrypt(false, nParamTypes, pParams);
Pascal Brandc639ac82015-07-02 08:53:34 +020061
62 case TA_RPC_CMD_OPEN:
63 return rpc_open(pSessionContext, nParamTypes, pParams);
64
Jens Wiklanderf7b9c632017-01-03 17:32:26 +010065 case TA_RPC_CMD_CRYPT_PRIVMEM_SHA224:
66 return rpc_sha224(true, nParamTypes, pParams);
67
68 case TA_RPC_CMD_CRYPT_PRIVMEM_SHA256:
69 return rpc_sha256(true, nParamTypes, pParams);
70
71 case TA_RPC_CMD_CRYPT_PRIVMEM_AES256ECB_ENC:
72 return rpc_aes256ecb_encrypt(true, nParamTypes, pParams);
73
74 case TA_RPC_CMD_CRYPT_PRIVMEM_AES256ECB_DEC:
75 return rpc_aes256ecb_decrypt(true, nParamTypes, pParams);
76
Pascal Brandc639ac82015-07-02 08:53:34 +020077 default:
78 return TEE_ERROR_BAD_PARAMETERS;
79 }
80}