Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 1 | /* |
| 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> |
Jerome Forissier | 24ce5ab | 2017-09-25 12:44:22 -0700 | [diff] [blame^] | 29 | #include <trace.h> |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 30 | |
| 31 | #include "ta_aes_perf.h" |
| 32 | #include "ta_aes_perf_priv.h" |
| 33 | |
| 34 | /* |
| 35 | * Trusted Application Entry Points |
| 36 | */ |
| 37 | |
| 38 | /* Called each time a new instance is created */ |
| 39 | TEE_Result TA_CreateEntryPoint(void) |
| 40 | { |
| 41 | return TEE_SUCCESS; |
| 42 | } |
| 43 | |
| 44 | /* Called each time an instance is destroyed */ |
| 45 | void TA_DestroyEntryPoint(void) |
| 46 | { |
| 47 | } |
| 48 | |
| 49 | /* Called each time a session is opened */ |
| 50 | TEE_Result TA_OpenSessionEntryPoint(uint32_t nParamTypes, |
| 51 | TEE_Param pParams[4], |
| 52 | void **ppSessionContext) |
| 53 | { |
| 54 | (void)nParamTypes; |
| 55 | (void)pParams; |
| 56 | (void)ppSessionContext; |
| 57 | return TEE_SUCCESS; |
| 58 | } |
| 59 | |
| 60 | /* Called each time a session is closed */ |
| 61 | void TA_CloseSessionEntryPoint(void *pSessionContext) |
| 62 | { |
| 63 | (void)pSessionContext; |
| 64 | |
| 65 | cmd_clean_res(); |
| 66 | } |
| 67 | |
| 68 | /* Called when a command is invoked */ |
| 69 | TEE_Result TA_InvokeCommandEntryPoint(void *pSessionContext, |
| 70 | uint32_t nCommandID, uint32_t nParamTypes, |
| 71 | TEE_Param pParams[4]) |
| 72 | { |
| 73 | (void)pSessionContext; |
| 74 | |
| 75 | switch (nCommandID) { |
| 76 | case TA_AES_PERF_CMD_PREPARE_KEY: |
| 77 | return cmd_prepare_key(nParamTypes, pParams); |
| 78 | |
| 79 | case TA_AES_PERF_CMD_PROCESS: |
Etienne Carriere | b85a5f9 | 2017-05-03 18:21:56 +0200 | [diff] [blame] | 80 | return cmd_process(nParamTypes, pParams, false); |
| 81 | case TA_AES_PERF_CMD_PROCESS_SDP: |
| 82 | #ifdef CFG_SECURE_DATA_PATH |
| 83 | return cmd_process(nParamTypes, pParams, true); |
| 84 | #else |
| 85 | EMSG("Invalid SDP commands: TA was built without SDP support"); |
| 86 | return TEE_ERROR_NOT_SUPPORTED; |
| 87 | #endif |
Igor Opaniuk | 44aff4b | 2016-09-16 10:18:00 +0300 | [diff] [blame] | 88 | |
| 89 | default: |
| 90 | return TEE_ERROR_BAD_PARAMETERS; |
| 91 | } |
| 92 | } |