blob: 006d6c2c3c1d9697ee0f2777a95029a62fb7ce65 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
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 "storage.h"
29
30#include <tee_api.h>
Pascal Brand90f23352016-05-19 15:15:47 +020031#include <trace.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020032
33#define ASSERT_PARAM_TYPE(pt) \
34do { \
35 if ((pt) != param_types) \
36 return TEE_ERROR_BAD_PARAMETERS; \
37} while (0)
38
Jens Wiklanderc5231592015-11-11 09:27:27 +010039#define VAL2HANDLE(v) (void *)(uintptr_t)(v)
40
Pascal Brandc639ac82015-07-02 08:53:34 +020041TEE_Result ta_storage_cmd_open(uint32_t param_types, TEE_Param params[4])
42{
Jens Wiklanderc5231592015-11-11 09:27:27 +010043 TEE_Result res;
44 TEE_ObjectHandle o;
45
Pascal Brandc639ac82015-07-02 08:53:34 +020046 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
47 (TEE_PARAM_TYPE_MEMREF_INPUT,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020048 TEE_PARAM_TYPE_VALUE_INOUT,
49 TEE_PARAM_TYPE_VALUE_INPUT,
Pascal Brandc639ac82015-07-02 08:53:34 +020050 TEE_PARAM_TYPE_NONE));
51
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020052 res = TEE_OpenPersistentObject(params[2].value.a,
Pascal Brandc639ac82015-07-02 08:53:34 +020053 params[0].memref.buffer,
54 params[0].memref.size,
Jens Wiklanderc5231592015-11-11 09:27:27 +010055 params[1].value.a, &o);
56
57 params[1].value.b = (uintptr_t)o;
58 return res;
Pascal Brandc639ac82015-07-02 08:53:34 +020059}
60
61TEE_Result ta_storage_cmd_create(uint32_t param_types, TEE_Param params[4])
62{
Jens Wiklanderc5231592015-11-11 09:27:27 +010063 TEE_Result res;
64 TEE_ObjectHandle o;
65
Pascal Brandc639ac82015-07-02 08:53:34 +020066 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
67 (TEE_PARAM_TYPE_MEMREF_INPUT,
68 TEE_PARAM_TYPE_VALUE_INOUT,
69 TEE_PARAM_TYPE_VALUE_INPUT,
70 TEE_PARAM_TYPE_MEMREF_INPUT));
71
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020072 res = TEE_CreatePersistentObject(params[2].value.b,
Jens Wiklanderc5231592015-11-11 09:27:27 +010073 params[0].memref.buffer, params[0].memref.size,
74 params[1].value.a,
75 (TEE_ObjectHandle)(uintptr_t)params[2].value.a,
76 params[3].memref.buffer, params[3].memref.size, &o);
77 params[1].value.b = (uintptr_t)o;
78 return res;
Pascal Brandc639ac82015-07-02 08:53:34 +020079}
80
Pascal Brandeb84c442016-04-19 17:49:49 +020081TEE_Result ta_storage_cmd_create_overwrite(uint32_t param_types,
82 TEE_Param params[4])
83{
84 TEE_Result res;
85
86 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
87 (TEE_PARAM_TYPE_MEMREF_INPUT,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020088 TEE_PARAM_TYPE_VALUE_INPUT,
Pascal Brandeb84c442016-04-19 17:49:49 +020089 TEE_PARAM_TYPE_NONE,
90 TEE_PARAM_TYPE_NONE));
91
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020092 res = TEE_CreatePersistentObject(params[1].value.a,
Pascal Brandeb84c442016-04-19 17:49:49 +020093 params[0].memref.buffer, params[0].memref.size,
94 TEE_DATA_FLAG_OVERWRITE,
95 NULL, NULL, 0, NULL);
96 return res;
97}
98
Pascal Brandc639ac82015-07-02 08:53:34 +020099TEE_Result ta_storage_cmd_close(uint32_t param_types, TEE_Param params[4])
100{
101 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
102 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
103 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
104
Jens Wiklanderc5231592015-11-11 09:27:27 +0100105 TEE_CloseObject((TEE_ObjectHandle)(uintptr_t)params[0].value.a);
Pascal Brandc639ac82015-07-02 08:53:34 +0200106
107 return TEE_SUCCESS;
108}
109
110TEE_Result ta_storage_cmd_read(uint32_t param_types, TEE_Param params[4])
111{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100112 TEE_ObjectHandle o = VAL2HANDLE(params[1].value.a);
113
Pascal Brandc639ac82015-07-02 08:53:34 +0200114 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
115 (TEE_PARAM_TYPE_MEMREF_OUTPUT,
116 TEE_PARAM_TYPE_VALUE_INOUT, TEE_PARAM_TYPE_NONE,
117 TEE_PARAM_TYPE_NONE));
118
Jens Wiklanderc5231592015-11-11 09:27:27 +0100119 return TEE_ReadObjectData(o, params[0].memref.buffer,
Pascal Brandc639ac82015-07-02 08:53:34 +0200120 params[0].memref.size, &params[1].value.b);
121}
122
123TEE_Result ta_storage_cmd_write(uint32_t param_types, TEE_Param params[4])
124{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100125 TEE_ObjectHandle o = VAL2HANDLE(params[1].value.a);
126
Pascal Brandc639ac82015-07-02 08:53:34 +0200127 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
128 (TEE_PARAM_TYPE_MEMREF_INPUT,
129 TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
130 TEE_PARAM_TYPE_NONE));
131
Jens Wiklanderc5231592015-11-11 09:27:27 +0100132 return TEE_WriteObjectData(o, params[0].memref.buffer,
Pascal Brandc639ac82015-07-02 08:53:34 +0200133 params[0].memref.size);
134}
135
136TEE_Result ta_storage_cmd_seek(uint32_t param_types, TEE_Param params[4])
137{
138 TEE_Result res;
139 TEE_ObjectInfo info;
Jens Wiklanderc5231592015-11-11 09:27:27 +0100140 TEE_ObjectHandle o = VAL2HANDLE(params[0].value.a);
Pascal Brandc639ac82015-07-02 08:53:34 +0200141
142 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
143 (TEE_PARAM_TYPE_VALUE_INPUT,
144 TEE_PARAM_TYPE_VALUE_INOUT, TEE_PARAM_TYPE_NONE,
145 TEE_PARAM_TYPE_NONE));
146
Jens Wiklanderc5231592015-11-11 09:27:27 +0100147 res = TEE_SeekObjectData(o, params[0].value.b, params[1].value.a);
148 if (res != TEE_SUCCESS)
149 return res;
150 res = TEE_GetObjectInfo1(o, &info);
Pascal Brandc639ac82015-07-02 08:53:34 +0200151
152 params[1].value.b = info.dataPosition;
153
154 return res;
155}
156
157TEE_Result ta_storage_cmd_unlink(uint32_t param_types, TEE_Param params[4])
158{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100159 TEE_ObjectHandle o = VAL2HANDLE(params[0].value.a);
160
Pascal Brandc639ac82015-07-02 08:53:34 +0200161 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
162 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
163 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
164
Jens Wiklanderc5231592015-11-11 09:27:27 +0100165 TEE_CloseAndDeletePersistentObject1(o);
Pascal Brandc639ac82015-07-02 08:53:34 +0200166
167 return TEE_SUCCESS;
168}
169
170TEE_Result ta_storage_cmd_rename(uint32_t param_types, TEE_Param params[4])
171{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100172 TEE_ObjectHandle o = VAL2HANDLE(params[0].value.a);
173
Pascal Brandc639ac82015-07-02 08:53:34 +0200174 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
175 (TEE_PARAM_TYPE_VALUE_INPUT,
176 TEE_PARAM_TYPE_MEMREF_INPUT, TEE_PARAM_TYPE_NONE,
177 TEE_PARAM_TYPE_NONE));
178
Jens Wiklanderc5231592015-11-11 09:27:27 +0100179 return TEE_RenamePersistentObject(o, params[1].memref.buffer,
Pascal Brandc639ac82015-07-02 08:53:34 +0200180 params[1].memref.size);
181}
182
183TEE_Result ta_storage_cmd_trunc(uint32_t param_types, TEE_Param params[4])
184{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100185 TEE_ObjectHandle o = VAL2HANDLE(params[0].value.a);
186
Pascal Brandc639ac82015-07-02 08:53:34 +0200187 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
188 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
189 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
190
Jens Wiklanderc5231592015-11-11 09:27:27 +0100191 return TEE_TruncateObjectData(o, params[0].value.b);
Pascal Brandc639ac82015-07-02 08:53:34 +0200192}
193
194TEE_Result ta_storage_cmd_alloc_enum(uint32_t param_types, TEE_Param params[4])
195{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100196 TEE_Result res;
197 TEE_ObjectEnumHandle oe;
198
Pascal Brandc639ac82015-07-02 08:53:34 +0200199 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
200 (TEE_PARAM_TYPE_VALUE_OUTPUT, TEE_PARAM_TYPE_NONE,
201 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
202
Jens Wiklanderc5231592015-11-11 09:27:27 +0100203 res = TEE_AllocatePersistentObjectEnumerator(&oe);
204 params[0].value.a = (uintptr_t)oe;
205 return res;
Pascal Brandc639ac82015-07-02 08:53:34 +0200206}
207
208TEE_Result ta_storage_cmd_free_enum(uint32_t param_types, TEE_Param params[4])
209{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100210 TEE_ObjectEnumHandle oe = VAL2HANDLE(params[0].value.a);
211
Pascal Brandc639ac82015-07-02 08:53:34 +0200212 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
213 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
214 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
215
Jens Wiklanderc5231592015-11-11 09:27:27 +0100216 TEE_FreePersistentObjectEnumerator(oe);
Pascal Brandc639ac82015-07-02 08:53:34 +0200217 return TEE_SUCCESS;
218}
219
220TEE_Result ta_storage_cmd_reset_enum(uint32_t param_types, TEE_Param params[4])
221{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100222 TEE_ObjectEnumHandle oe = VAL2HANDLE(params[0].value.a);
223
Pascal Brandc639ac82015-07-02 08:53:34 +0200224 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
225 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
226 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
227
Jens Wiklanderc5231592015-11-11 09:27:27 +0100228 TEE_ResetPersistentObjectEnumerator(oe);
Pascal Brandc639ac82015-07-02 08:53:34 +0200229 return TEE_SUCCESS;
230}
231
232TEE_Result ta_storage_cmd_start_enum(uint32_t param_types, TEE_Param params[4])
233{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100234 TEE_ObjectEnumHandle oe = VAL2HANDLE(params[0].value.a);
235
Pascal Brandc639ac82015-07-02 08:53:34 +0200236 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
237 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
238 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
239
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200240 return TEE_StartPersistentObjectEnumerator(oe, params[0].value.b);
Pascal Brandc639ac82015-07-02 08:53:34 +0200241}
242
243TEE_Result ta_storage_cmd_next_enum(uint32_t param_types, TEE_Param params[4])
244{
Jens Wiklanderc5231592015-11-11 09:27:27 +0100245 TEE_ObjectEnumHandle oe = VAL2HANDLE(params[0].value.a);
Pascal Brandc603e0d2016-04-25 12:37:18 +0200246 TEE_ObjectInfo *obj;
Jens Wiklanderc5231592015-11-11 09:27:27 +0100247
Pascal Brandc603e0d2016-04-25 12:37:18 +0200248 if (TEE_PARAM_TYPE_GET(param_types, 0) != TEE_PARAM_TYPE_VALUE_INPUT)
249 return TEE_ERROR_BAD_PARAMETERS;
250 if (TEE_PARAM_TYPE_GET(param_types, 2) != TEE_PARAM_TYPE_MEMREF_OUTPUT)
251 return TEE_ERROR_BAD_PARAMETERS;
252 if (TEE_PARAM_TYPE_GET(param_types, 3) != TEE_PARAM_TYPE_NONE)
253 return TEE_ERROR_BAD_PARAMETERS;
Pascal Brandc639ac82015-07-02 08:53:34 +0200254
Pascal Brandc603e0d2016-04-25 12:37:18 +0200255 if (TEE_PARAM_TYPE_GET(param_types, 1) == TEE_PARAM_TYPE_NONE)
256 obj = NULL;
257 else if (TEE_PARAM_TYPE_GET(param_types, 1) ==
258 TEE_PARAM_TYPE_MEMREF_OUTPUT) {
259 if (params[1].memref.size < sizeof(TEE_ObjectInfo)) {
260 params[1].memref.size = sizeof(TEE_ObjectInfo);
261 return TEE_ERROR_SHORT_BUFFER;
262 }
263 params[1].memref.size = sizeof(TEE_ObjectInfo);
264 obj = (TEE_ObjectInfo *)params[1].memref.buffer;
265 } else
266 return TEE_ERROR_BAD_PARAMETERS;
Pascal Brandc639ac82015-07-02 08:53:34 +0200267
268 if (params[2].memref.size < TEE_OBJECT_ID_MAX_LEN)
269 return TEE_ERROR_SHORT_BUFFER;
270
Pascal Brandc603e0d2016-04-25 12:37:18 +0200271 return TEE_GetNextPersistentObject(oe, obj,
272 params[2].memref.buffer,
273 &params[2].memref.size);
Pascal Brandc639ac82015-07-02 08:53:34 +0200274}
Pascal Brand90f23352016-05-19 15:15:47 +0200275
276static TEE_Result check_obj(TEE_ObjectInfo *o1, TEE_ObjectInfo *o2)
277{
278 if ((o1->objectType != o2->objectType) ||
279 (o1->keySize != o2->keySize) ||
280 (o1->maxKeySize != o2->maxKeySize) ||
281 (o1->objectUsage != o2->objectUsage))
282 return TEE_ERROR_GENERIC;
283 return TEE_SUCCESS;
284}
285
286TEE_Result ta_storage_cmd_key_in_persistent(uint32_t param_types,
287 TEE_Param params[4])
288{
289 TEE_Result result = TEE_SUCCESS;
290 TEE_ObjectHandle transient_key = (TEE_ObjectHandle)NULL;
291 TEE_ObjectHandle persistent_key = (TEE_ObjectHandle)NULL;
292 TEE_ObjectHandle key = (TEE_ObjectHandle)NULL;
293 TEE_OperationHandle encrypt_op = (TEE_OperationHandle)NULL;
294 TEE_ObjectInfo keyInfo;
295 TEE_ObjectInfo keyInfo2;
296 TEE_ObjectInfo keyInfo3;
297 uint32_t alg = TEE_ALG_AES_CBC_NOPAD;
298 void *IV = NULL;
299 size_t IVlen = 16;
300 size_t key_size = 256;
301 uint32_t objectID = 1;
302 uint32_t flags = TEE_DATA_FLAG_ACCESS_READ |
303 TEE_DATA_FLAG_ACCESS_WRITE |
304 TEE_DATA_FLAG_ACCESS_WRITE_META |
305 TEE_DATA_FLAG_SHARE_READ |
306 TEE_DATA_FLAG_SHARE_WRITE;
307
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200308 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
309 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
310 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
Pascal Brand90f23352016-05-19 15:15:47 +0200311
312 result = TEE_AllocateTransientObject(TEE_TYPE_AES, key_size,
313 &transient_key);
314 if (result != TEE_SUCCESS) {
315 EMSG("Failed to Allocate transient object handle : 0x%x",
316 result);
317 goto cleanup1;
318 }
319
320 result = TEE_GenerateKey(transient_key, key_size, NULL, 0);
321 if (result != TEE_SUCCESS) {
322 EMSG("Failed to generate a transient key: 0x%x", result);
323 goto cleanup2;
324 }
325
326 TEE_GetObjectInfo1(transient_key, &keyInfo);
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200327 result = TEE_CreatePersistentObject(params[0].value.a,
Pascal Brand90f23352016-05-19 15:15:47 +0200328 &objectID, sizeof(objectID),
329 flags, transient_key, NULL, 0,
330 &persistent_key);
331 if (result != TEE_SUCCESS) {
332 EMSG("Failed to create a persistent key: 0x%x", result);
333 goto cleanup2;
334 }
335
336 TEE_GetObjectInfo1(persistent_key, &keyInfo2);
337 result = check_obj(&keyInfo, &keyInfo2);
338 if (result != TEE_SUCCESS) {
339 EMSG("keyInfo and keyInfo2 are different");
340 goto cleanup2;
341 }
342
343 TEE_CloseObject(persistent_key);
344
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200345 result = TEE_OpenPersistentObject(params[0].value.a,
Pascal Brand90f23352016-05-19 15:15:47 +0200346 &objectID, sizeof(objectID),
347 flags, &key);
348 if (result != TEE_SUCCESS) {
349 EMSG("Failed to open persistent key: 0x%x", result);
350 goto cleanup2;
351 }
352
353 TEE_GetObjectInfo(key, &keyInfo3);
354 result = check_obj(&keyInfo3, &keyInfo2);
355 if (result != TEE_SUCCESS) {
356 EMSG("keyInfo2 and keyInfo3 are different");
357 goto cleanup2;
358 }
359
360 result = TEE_AllocateOperation(&encrypt_op, alg, TEE_MODE_ENCRYPT,
361 keyInfo3.maxObjectSize);
362 if (result != TEE_SUCCESS) {
363 EMSG("Failed to allocate an operation: 0x%x", result);
364 goto cleanup3;
365 }
366
367 result = TEE_SetOperationKey(encrypt_op, key);
368 if (result != TEE_SUCCESS) {
369 EMSG("Failed to set operation key: 0x%x", result);
370 goto cleanup4;
371 }
372
373 IV = TEE_Malloc(IVlen, 0);
374 if (!IV) {
375 EMSG("Out of memory for IV.");
376 result = TEE_ERROR_OUT_OF_MEMORY;
377 goto cleanup4;
378 }
379
380 TEE_CipherInit(encrypt_op, IV, IVlen);
381 TEE_Free(IV);
382
383cleanup4:
384 TEE_FreeOperation(encrypt_op);
385cleanup3:
386 TEE_CloseAndDeletePersistentObject1(key);
387cleanup2:
388 TEE_FreeTransientObject(transient_key);
389cleanup1:
390 return result;
391}
392
Pascal Brand29ee18f2016-05-23 14:13:56 +0200393TEE_Result ta_storage_cmd_loop(uint32_t param_types, TEE_Param params[4])
394{
395 TEE_ObjectHandle object = TEE_HANDLE_NULL;
396 TEE_Result res;
397 int object_id = 0;
398 uint32_t flags = TEE_DATA_FLAG_OVERWRITE |
399 TEE_DATA_FLAG_ACCESS_WRITE_META;
400 int i = 0;
401
Pascal Brand29ee18f2016-05-23 14:13:56 +0200402 (void)params;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200403 ASSERT_PARAM_TYPE(TEE_PARAM_TYPES
404 (TEE_PARAM_TYPE_VALUE_INPUT, TEE_PARAM_TYPE_NONE,
405 TEE_PARAM_TYPE_NONE, TEE_PARAM_TYPE_NONE));
Pascal Brand29ee18f2016-05-23 14:13:56 +0200406
407 for (i = 0; i < 20; i++) {
408 DMSG("\n\nLOOP : %d", i);
409 object = TEE_HANDLE_NULL;
410 object_id = i;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200411 res = TEE_CreatePersistentObject(params[0].value.a,
Pascal Brand29ee18f2016-05-23 14:13:56 +0200412 &object_id, sizeof(int), flags,
413 TEE_HANDLE_NULL, NULL, 0,
414 &object);
415
416 if (res != TEE_SUCCESS) {
417 EMSG("FAIL");
418 return res;
419 }
420
421 res = TEE_CloseAndDeletePersistentObject1(object);
422 if (res != TEE_SUCCESS) {
423 EMSG("FAIL");
424 return res;
425 }
426 }
427
428 return TEE_SUCCESS;
429}