1 // SPDX-License-Identifier: BSD-3-Clause
2 /*
3 * Copyright (C) Foundries Ltd. 2020 - All Rights Reserved
4 * Author: Jorge Ramirez <jorge@foundries.io>
5 */
6
7 #include <crypto/crypto_se.h>
8 #include <kernel/pseudo_ta.h>
9 #include <pta_scp03.h>
10
11 #define PTA_NAME "pta.scp03"
12
invoke_command(void * session_context __unused,uint32_t command_id,uint32_t pt,TEE_Param params[TEE_NUM_PARAMS])13 static TEE_Result invoke_command(void *session_context __unused,
14 uint32_t command_id, uint32_t pt,
15 TEE_Param params[TEE_NUM_PARAMS])
16 {
17 const uint32_t exp_pt = TEE_PARAM_TYPES(TEE_PARAM_TYPE_VALUE_INPUT,
18 TEE_PARAM_TYPE_NONE,
19 TEE_PARAM_TYPE_NONE,
20 TEE_PARAM_TYPE_NONE);
21 bool rotate_keys = false;
22
23 FMSG("command entry point for pseudo-TA \"%s\"", PTA_NAME);
24
25 if (pt != exp_pt)
26 return TEE_ERROR_BAD_PARAMETERS;
27
28 switch (command_id) {
29 case PTA_CMD_ENABLE_SCP03:
30 if (params[0].value.a == PTA_SCP03_SESSION_ROTATE_KEYS)
31 rotate_keys = true;
32
33 return crypto_se_enable_scp03(rotate_keys);
34 default:
35 break;
36 }
37
38 return TEE_ERROR_NOT_IMPLEMENTED;
39 }
40
41 pseudo_ta_register(.uuid = PTA_SCP03_UUID, .name = PTA_NAME,
42 .flags = PTA_DEFAULT_FLAGS,
43 .invoke_command_entry_point = invoke_command);
44