blob: 92b5c6a179d0c2a7bd0b45ef917ba6e631a43a07 [file] [log] [blame]
Pascal Brandc639ac82015-07-02 08:53:34 +02001/*
2 * Copyright (c) 2014, STMicroelectronics International N.V.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License Version 2 as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 */
13
14#include <string.h>
15#include <stdio.h>
16
17#include <adbg.h>
18#include <xtest_test.h>
19#include <xtest_helpers.h>
20
21#include <tee_client_api.h>
22#include <ta_storage.h>
23#include <tee_api_defines.h>
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020024#include <tee_api_defines_extensions.h>
Pascal Brandc639ac82015-07-02 08:53:34 +020025#include <tee_api_types.h>
Jerome Forissiere3688342015-09-24 10:45:17 -070026#ifdef WITH_GP_TESTS
Pascal Brand8a74e362015-09-10 12:41:52 +020027#include <TTA_DS_protocol.h>
28#endif
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020029#include <util.h>
30
31static uint32_t storage_ids[] = {
32 TEE_STORAGE_PRIVATE,
33#ifdef CFG_REE_FS
34 TEE_STORAGE_PRIVATE_REE,
35#endif
36#ifdef CFG_RPMB_FS
37 TEE_STORAGE_PRIVATE_RPMB,
38#endif
Jerome Forissiera966bb42016-08-16 16:41:47 +020039#ifdef CFG_SQL_FS
40 TEE_STORAGE_PRIVATE_SQL,
41#endif
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020042};
Pascal Brandc639ac82015-07-02 08:53:34 +020043
44static uint8_t file_00[] = {
45 0x00, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
46 0xF0, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
47 0xE9, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
48 0xF0, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x8E
49};
50
51static uint8_t file_01[] = {
52 0x01, 0x00
53};
54
55static uint8_t file_02[] = {
56 0x02, 0x11, 0x02
57};
58
59static uint8_t file_03[] = {
60 0x03, 0x13, 0x03
61};
62
Pascal Brandeb84c442016-04-19 17:49:49 +020063static uint8_t file_04[] = {
64 0x00, 0x01, 0x02
65};
66
Pascal Brandc639ac82015-07-02 08:53:34 +020067static uint8_t data_00[] = {
68 0x00, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
69 0x00, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
70 0x00, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
71 0x00, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x00
72};
73
74static uint8_t data_01[] = {
75 0x01, 0x6E, 0x04, 0x57, 0x08, 0xFB, 0x71, 0x96,
76 0x01, 0x2E, 0x55, 0x3D, 0x02, 0xC3, 0xA6, 0x92,
77 0x01, 0xC3, 0xEF, 0x8A, 0xB2, 0x34, 0x53, 0xE6,
78 0x01, 0x74, 0x9C, 0xD6, 0x36, 0xE7, 0xA8, 0x01
79};
80
81static TEEC_Result fs_open(TEEC_Session *sess, void *id, uint32_t id_size,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020082 uint32_t flags, uint32_t *obj, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +020083{
Aijun Sun473d9072015-08-06 15:24:49 +080084 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +020085 TEEC_Result res;
86 uint32_t org;
87
88 op.params[0].tmpref.buffer = id;
89 op.params[0].tmpref.size = id_size;
90 op.params[1].value.a = flags;
91 op.params[1].value.b = 0;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020092 op.params[2].value.a = storage_id;
Pascal Brandc639ac82015-07-02 08:53:34 +020093
94 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +020095 TEEC_VALUE_INOUT, TEEC_VALUE_INPUT,
Pascal Brandc639ac82015-07-02 08:53:34 +020096 TEEC_NONE);
97
98 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_OPEN, &op, &org);
99
100 if (res == TEEC_SUCCESS)
101 *obj = op.params[1].value.b;
102
103 return res;
104}
105
106static TEEC_Result fs_create(TEEC_Session *sess, void *id, uint32_t id_size,
107 uint32_t flags, uint32_t attr, void *data,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200108 uint32_t data_size, uint32_t *obj,
109 uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200110{
Aijun Sun473d9072015-08-06 15:24:49 +0800111 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200112 TEEC_Result res;
113 uint32_t org;
114
115 op.params[0].tmpref.buffer = id;
116 op.params[0].tmpref.size = id_size;
117 op.params[1].value.a = flags;
118 op.params[1].value.b = 0;
119 op.params[2].value.a = attr;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200120 op.params[2].value.b = storage_id;
Pascal Brandc639ac82015-07-02 08:53:34 +0200121 op.params[3].tmpref.buffer = data;
122 op.params[3].tmpref.size = data_size;
123
124 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
125 TEEC_VALUE_INOUT, TEEC_VALUE_INPUT,
126 TEEC_MEMREF_TEMP_INPUT);
127
128 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_CREATE, &op, &org);
129
130 if (res == TEEC_SUCCESS)
131 *obj = op.params[1].value.b;
132
133 return res;
134}
135
Pascal Brandeb84c442016-04-19 17:49:49 +0200136static TEEC_Result fs_create_overwrite(TEEC_Session *sess, void *id,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200137 uint32_t id_size, uint32_t storage_id)
Pascal Brandeb84c442016-04-19 17:49:49 +0200138{
139 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
140 TEEC_Result res;
141 uint32_t org;
142
143 op.params[0].tmpref.buffer = id;
144 op.params[0].tmpref.size = id_size;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200145 op.params[1].value.a = storage_id;
Pascal Brandeb84c442016-04-19 17:49:49 +0200146
147 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200148 TEEC_VALUE_INPUT, TEEC_NONE,
Pascal Brandeb84c442016-04-19 17:49:49 +0200149 TEEC_NONE);
150
151 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_CREATE_OVERWRITE, &op, &org);
152
153 return res;
154}
155
Pascal Brandc639ac82015-07-02 08:53:34 +0200156static TEEC_Result fs_close(TEEC_Session *sess, uint32_t obj)
157{
Aijun Sun473d9072015-08-06 15:24:49 +0800158 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200159 uint32_t org;
160
161 op.params[0].value.a = obj;
162
163 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
164 TEEC_NONE, TEEC_NONE);
165
166 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_CLOSE, &op, &org);
167}
168
169static TEEC_Result fs_read(TEEC_Session *sess, uint32_t obj, void *data,
170 uint32_t data_size, uint32_t *count)
171{
172 TEEC_Result res;
Aijun Sun473d9072015-08-06 15:24:49 +0800173 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200174 uint32_t org;
175
176 op.params[0].tmpref.buffer = data;
177 op.params[0].tmpref.size = data_size;
178 op.params[1].value.a = obj;
179 op.params[1].value.b = 0;
180
181 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_OUTPUT,
182 TEEC_VALUE_INOUT, TEEC_NONE,
183 TEEC_NONE);
184
185 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_READ, &op, &org);
186
187 if (res == TEEC_SUCCESS)
188 *count = op.params[1].value.b;
189
190 return res;
191}
192
193static TEEC_Result fs_write(TEEC_Session *sess, uint32_t obj, void *data,
194 uint32_t data_size)
195{
Aijun Sun473d9072015-08-06 15:24:49 +0800196 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200197 uint32_t org;
198
199 op.params[0].tmpref.buffer = data;
200 op.params[0].tmpref.size = data_size;
201 op.params[1].value.a = obj;
202 op.params[1].value.b = 0;
203
204 op.paramTypes = TEEC_PARAM_TYPES(TEEC_MEMREF_TEMP_INPUT,
205 TEEC_VALUE_INPUT, TEEC_NONE,
206 TEEC_NONE);
207
208 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_WRITE, &op, &org);
209}
210
211static TEEC_Result fs_seek(TEEC_Session *sess, uint32_t obj, int32_t offset,
212 int32_t whence)
213{
Aijun Sun473d9072015-08-06 15:24:49 +0800214 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200215 uint32_t org;
216
217 op.params[0].value.a = obj;
218 op.params[0].value.b = offset;
219 op.params[1].value.a = whence;
220
221 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_VALUE_INOUT,
222 TEEC_NONE, TEEC_NONE);
223
224 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_SEEK, &op, &org);
225}
226
227static TEEC_Result fs_unlink(TEEC_Session *sess, uint32_t obj)
228{
Aijun Sun473d9072015-08-06 15:24:49 +0800229 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200230 uint32_t org;
231
232 op.params[0].value.a = obj;
233
234 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
235 TEEC_NONE, TEEC_NONE);
236
237 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_UNLINK, &op, &org);
238}
239
240static TEEC_Result fs_trunc(TEEC_Session *sess, uint32_t obj, uint32_t len)
241{
Aijun Sun473d9072015-08-06 15:24:49 +0800242 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200243 uint32_t org;
244
245 op.params[0].value.a = obj;
246 op.params[0].value.b = len;
247
248 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
249 TEEC_NONE, TEEC_NONE);
250
251 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_TRUNC, &op, &org);
252}
253
254static TEEC_Result fs_rename(TEEC_Session *sess, uint32_t obj, void *id,
255 uint32_t id_size)
256{
Aijun Sun473d9072015-08-06 15:24:49 +0800257 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200258 uint32_t org;
259
260 op.params[0].value.a = obj;
261 op.params[1].tmpref.buffer = id;
262 op.params[1].tmpref.size = id_size;
263
264 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT,
265 TEEC_MEMREF_TEMP_INPUT, TEEC_NONE,
266 TEEC_NONE);
267
268 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_RENAME, &op, &org);
269}
270
271static TEEC_Result fs_alloc_enum(TEEC_Session *sess, uint32_t *e)
272{
273 TEEC_Result res;
Aijun Sun473d9072015-08-06 15:24:49 +0800274 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200275 uint32_t org;
276
277 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_OUTPUT, TEEC_NONE,
278 TEEC_NONE, TEEC_NONE);
279
280 res = TEEC_InvokeCommand(sess, TA_STORAGE_CMD_ALLOC_ENUM, &op, &org);
281
282 if (res == TEEC_SUCCESS)
283 *e = op.params[0].value.a;
284
285 return res;
286}
287
288static TEEC_Result fs_free_enum(TEEC_Session *sess, uint32_t e)
289{
Aijun Sun473d9072015-08-06 15:24:49 +0800290 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200291 uint32_t org;
292
293 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE,
294 TEEC_NONE);
295
296 op.params[0].value.a = e;
297
298 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_FREE_ENUM, &op, &org);
299}
300
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200301static TEEC_Result fs_start_enum(TEEC_Session *sess, uint32_t e,
302 uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200303{
Aijun Sun473d9072015-08-06 15:24:49 +0800304 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200305 uint32_t org;
306
307 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
308 TEEC_NONE, TEEC_NONE);
309
310 op.params[0].value.a = e;
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200311 op.params[0].value.b = storage_id;
Pascal Brandc639ac82015-07-02 08:53:34 +0200312
313 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_START_ENUM, &op, &org);
314}
315
316static TEEC_Result fs_next_enum(TEEC_Session *sess, uint32_t e, void *obj_info,
317 size_t info_size, void *id, uint32_t id_size)
318{
Aijun Sun473d9072015-08-06 15:24:49 +0800319 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
Pascal Brandc639ac82015-07-02 08:53:34 +0200320 uint32_t org;
321
Pascal Brandc603e0d2016-04-25 12:37:18 +0200322 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
Pascal Brandc639ac82015-07-02 08:53:34 +0200323 TEEC_MEMREF_TEMP_OUTPUT, TEEC_NONE);
Pascal Brandc603e0d2016-04-25 12:37:18 +0200324 if (obj_info && info_size)
325 op.paramTypes |= (TEEC_MEMREF_TEMP_OUTPUT << 4);
Pascal Brandc639ac82015-07-02 08:53:34 +0200326
327 op.params[0].value.a = e;
328 op.params[1].tmpref.buffer = obj_info;
329 op.params[1].tmpref.size = info_size;
330 op.params[2].tmpref.buffer = id;
331 op.params[2].tmpref.size = id_size;
332
333 return TEEC_InvokeCommand(sess, TA_STORAGE_CMD_NEXT_ENUM, &op, &org);
334}
335
James Kung98c0ba12015-09-09 15:51:59 +0800336/* trunc */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200337static void test_truncate_file_length(ADBG_Case_t *c, uint32_t storage_id)
James Kung98c0ba12015-09-09 15:51:59 +0800338{
339 TEEC_Session sess;
340 uint32_t obj;
341 uint8_t out[10] = { 0 };
342 uint32_t count;
343 uint32_t orig;
344
345 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
346 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
347 return;
348
349 /* create */
350 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
351 fs_create(&sess, file_01, sizeof(file_01),
352 TEE_DATA_FLAG_ACCESS_WRITE |
353 TEE_DATA_FLAG_ACCESS_READ |
354 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200355 sizeof(data_00), &obj, storage_id)))
James Kung98c0ba12015-09-09 15:51:59 +0800356 goto exit;
357
358 /* trunc */
359 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_trunc(&sess, obj, 10)))
360 goto exit;
361
362 /* seek */
363 if (!ADBG_EXPECT_TEEC_SUCCESS(
364 c, fs_seek(&sess, obj, 5, TEE_DATA_SEEK_SET)))
365 goto exit;
366
367 /* verify */
368 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
369 goto exit;
370
371 /* check buffer */
372 (void)ADBG_EXPECT_BUFFER(c, &data_00[5], 5, out, count);
373
374 /* clean */
375 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
376 goto exit;
377
378exit:
379 TEEC_CloseSession(&sess);
380}
381
382/* extend */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200383static void test_extend_file_length(ADBG_Case_t *c, uint32_t storage_id)
James Kung98c0ba12015-09-09 15:51:59 +0800384{
385 TEEC_Session sess;
386 uint32_t obj;
387 uint8_t out[10] = { 0 };
388 uint8_t expect[10] = { 0 };
389 uint32_t count;
390 uint32_t orig;
391
392 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
393 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
394 return;
395
396 /* create */
397 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
398 fs_create(&sess, file_01, sizeof(file_01),
399 TEE_DATA_FLAG_ACCESS_WRITE |
400 TEE_DATA_FLAG_ACCESS_READ |
401 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200402 sizeof(data_00), &obj, storage_id)))
James Kung98c0ba12015-09-09 15:51:59 +0800403 goto exit;
404
405 /* extend */
406 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_trunc(&sess, obj, 40)))
407 goto exit;
408
409 /* seek */
410 if (!ADBG_EXPECT_TEEC_SUCCESS(
411 c, fs_seek(&sess, obj, 30, TEE_DATA_SEEK_SET)))
412 goto exit;
413
414 /* verify */
415 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
416 goto exit;
417
418 /* check buffer */
419 expect[0] = data_00[30];
420 expect[1] = data_00[31];
421 (void)ADBG_EXPECT_BUFFER(c, &expect[0], 10, out, count);
422
423 /* clean */
424 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
425 goto exit;
426
427exit:
428 TEEC_CloseSession(&sess);
429}
430
431/* file hole */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200432static void test_file_hole(ADBG_Case_t *c, uint32_t storage_id)
James Kung98c0ba12015-09-09 15:51:59 +0800433{
434 TEEC_Session sess;
435 uint32_t obj;
436 uint8_t out[10] = { 0 };
437 uint8_t expect[10] = { 0 };
438 uint32_t count;
439 uint32_t orig;
440
441 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
442 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
443 return;
444
445 /* create */
446 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
447 fs_create(&sess, file_01, sizeof(file_01),
448 TEE_DATA_FLAG_ACCESS_WRITE |
449 TEE_DATA_FLAG_ACCESS_READ |
450 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200451 sizeof(data_00), &obj, storage_id)))
James Kung98c0ba12015-09-09 15:51:59 +0800452 goto exit;
453
454 /* seek */
455 if (!ADBG_EXPECT_TEEC_SUCCESS(
456 c, fs_seek(&sess, obj, 80, TEE_DATA_SEEK_SET)))
457 goto exit;
458
459 /* write */
460 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_write(&sess, obj, data_00,
461 sizeof(data_00))))
462 goto exit;
463
464 /* seek */
465 if (!ADBG_EXPECT_TEEC_SUCCESS(
466 c, fs_seek(&sess, obj, 74, TEE_DATA_SEEK_SET)))
467 goto exit;
468
469 /* verify */
470 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
471 goto exit;
472
473 /* check buffer */
474 expect[6] = data_00[0];
475 expect[7] = data_00[1];
476 expect[8] = data_00[2];
477 expect[9] = data_00[3];
478 (void)ADBG_EXPECT_BUFFER(c, &expect[0], 10, out, count);
479
480 /* clean */
481 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
482 goto exit;
483
484exit:
485 TEEC_CloseSession(&sess);
486}
487
Jerome Forissiere3688342015-09-24 10:45:17 -0700488#ifdef WITH_GP_TESTS
Pascal Brand8a74e362015-09-10 12:41:52 +0200489static TEEC_Result ds_open_access_conf(TEEC_Session *sess)
490{
491 TEEC_Operation op;
492 uint32_t org;
493
494 op.paramTypes = TEEC_PARAM_TYPES(
495 TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
496
497 return TEEC_InvokeCommand(
498 sess, CMD_CreatePersistentObject_AccessConflict, &op, &org);
499}
500
501static TEEC_Result ds_res_obj_panic(TEEC_Session *sess)
502{
503 TEEC_Operation op;
504 uint32_t org;
505
506 op.paramTypes = TEEC_PARAM_TYPES(
507 TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
508
509 return TEEC_InvokeCommand(
510 sess, CMD_RestrictObjectUsagePanic, &op, &org);
511}
512
513static TEEC_Result ds_seek_obj_inv_handle(TEEC_Session *sess)
514{
515 TEEC_Operation op;
516 uint32_t org;
517
518 op.paramTypes = TEEC_PARAM_TYPES(
519 TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
520
521 op.params[0].value.a = CASE_DATA_OBJECT_NOT_PERSISTENT;
522
523 return TEEC_InvokeCommand(
524 sess, CMD_SeekObjectData_panic, &op, &org);
525}
526
527static TEEC_Result ds_seek_obj_bad_handle(TEEC_Session *sess)
528{
529 TEEC_Operation op;
530 uint32_t org;
531
532 op.paramTypes = TEEC_PARAM_TYPES(
533 TEEC_VALUE_INPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
534
535 op.params[0].value.a = CASE_DATA_BAD_HANDLE;
536
537 return TEEC_InvokeCommand(
538 sess, CMD_SeekObjectData_panic, &op, &org);
539}
540
541static TEEC_Result ds_seek_gp(
542 TEEC_Session *sess, TEE_Whence wh, uint32_t wh_off, uint32_t set_off,
543 void *in, size_t in_size, void *out, size_t out_size)
544{
545 TEEC_Operation op;
546 uint32_t org;
547
548 op.paramTypes = TEEC_PARAM_TYPES(
549 TEEC_VALUE_INPUT, TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT,
550 TEEC_MEMREF_TEMP_OUTPUT);
551
552 op.params[0].value.a = wh;
553 op.params[0].value.b = wh_off;
554 op.params[1].value.a = set_off;
555 op.params[2].tmpref.buffer = in;
556 op.params[2].tmpref.size = in_size;
557 op.params[3].tmpref.buffer = out;
558 op.params[3].tmpref.size = out_size;
559
560 return TEEC_InvokeCommand(sess, CMD_SeekWriteReadObjectData, &op, &org);
561}
562
563static TEEC_Result ds_init_object_and_attributes(TEEC_Session *sess,
564 uint32_t obj_type, uint32_t obj_size, const void *attr_meta,
565 size_t attr_meta_len, const void *attr_data, size_t attr_data_len,
566 uint32_t option)
567{
568 TEEC_Operation op;
569 uint32_t org;
570
571 op.paramTypes = TEEC_PARAM_TYPES(
572 TEEC_VALUE_INPUT, TEEC_MEMREF_TEMP_INPUT,
573 TEEC_MEMREF_TEMP_INPUT, TEEC_VALUE_INPUT);
574
575 op.params[0].value.a = obj_type;
576 op.params[0].value.b = obj_size;
577 op.params[1].tmpref.buffer = (void *)attr_meta;
578 op.params[1].tmpref.size = attr_meta_len;
579 op.params[2].tmpref.buffer = (void *)attr_data;
580 op.params[2].tmpref.size = attr_data_len;
581 op.params[3].value.a = option;
582
583 return TEEC_InvokeCommand(sess, CMD_InitObjectAndAttributes, &op, &org);
584}
585
586static TEEC_Result ds_rename_access_conflict(TEEC_Session *sess)
587{
588 TEEC_Operation op;
589 uint32_t org;
590
591 op.paramTypes = TEEC_PARAM_TYPES(
592 TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
593
594 return TEEC_InvokeCommand(
595 sess, CMD_RenamePersistentObject_AccessConflict, &op, &org);
596}
597
598static TEEC_Result ds_start_enum_no_item(TEEC_Session *sess)
599{
600 TEEC_Operation op;
601 uint32_t org;
602 TEEC_Result res;
603
604 op.paramTypes = TEEC_PARAM_TYPES(
605 TEEC_VALUE_OUTPUT, TEEC_NONE, TEEC_NONE, TEEC_NONE);
606
607 res = TEEC_InvokeCommand(
608 sess, CMD_StartNGetPersistentObjectEnumerator_itemNotFound, &op, &org);
609
610 if (res != TEEC_SUCCESS)
611 return res;
612
613 if (op.params[0].value.a != 0 || op.params[0].value.b != 0)
614 return TEEC_ERROR_GENERIC;
615
616 return res;
617}
618
619static TEEC_Result ds_rename_success(TEEC_Session *sess)
620{
621 TEEC_Operation op;
622 uint32_t org;
623
624 op.paramTypes = TEEC_PARAM_TYPES(
625 TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
626
627 return TEEC_InvokeCommand(
628 sess, CMD_RenamePersistentObject_Success, &op, &org);
629}
630
631static TEEC_Result ds_null_close_free_reset(TEEC_Session *sess)
632{
633 TEEC_Operation op;
634 uint32_t org;
635
636 op.paramTypes = TEEC_PARAM_TYPES(
637 TEEC_NONE, TEEC_NONE, TEEC_NONE, TEEC_NONE);
638
639 return TEEC_InvokeCommand(
640 sess, CMD_CloseFreeAndResetObjectSuccessHandleNull, &op, &org);
641}
642#endif
643
Pascal Brandc639ac82015-07-02 08:53:34 +0200644/* create */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200645static void xtest_tee_test_6001_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200646{
647 TEEC_Session sess;
648 uint32_t obj;
649 uint32_t orig;
650
651 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
652 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
653 return;
654
655 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
656 fs_create(&sess, file_00, sizeof(file_00),
657 TEE_DATA_FLAG_ACCESS_WRITE |
658 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200659 sizeof(data_00), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200660 goto exit;
661
662 /* clean */
663 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
664 goto exit;
665
666exit:
667 TEEC_CloseSession(&sess);
668}
669
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200670#define DEFINE_TEST_MULTIPLE_STORAGE_IDS(test_name) \
671static void test_name(ADBG_Case_t *c) \
672{ \
673 size_t i; \
674 \
675 for (i = 0; i < ARRAY_SIZE(storage_ids); i++) { \
676 Do_ADBG_BeginSubCase(c, "Storage id: %08x", storage_ids[i]); \
677 test_name##_single(c, storage_ids[i]); \
678 Do_ADBG_EndSubCase(c, "Storage id: %08x", storage_ids[i]); \
679 } \
680}
681
682DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6001)
683
Pascal Brandc639ac82015-07-02 08:53:34 +0200684/* open */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200685static void xtest_tee_test_6002_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200686{
687 TEEC_Session sess;
688 uint32_t obj;
689 uint32_t orig;
690
691 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
692 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
693 return;
694
695 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
696 fs_create(&sess, file_01, sizeof(file_01),
697 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200698 sizeof(data_00), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200699 goto exit;
700
701 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
702 goto exit;
703
704 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
705 fs_open(&sess, file_01, sizeof(file_01),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200706 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200707 goto exit;
708
709 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
710 goto exit;
711
712 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
713 fs_open(&sess, file_01, sizeof(file_01),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200714 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200715 goto exit;
716
717 /* clean */
718 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
719 goto exit;
720
721exit:
722 TEEC_CloseSession(&sess);
723}
724
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200725DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6002)
726
Pascal Brandc639ac82015-07-02 08:53:34 +0200727/* read */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200728static void xtest_tee_test_6003_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200729{
730 TEEC_Session sess;
731 uint32_t obj;
732 uint8_t out[10] = { 0 };
733 uint32_t count;
734 uint32_t orig;
735
736 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
737 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
738 return;
739
740 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
741 fs_create(&sess, file_02, sizeof(file_02),
742 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200743 sizeof(data_01), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200744 goto exit;
745
746 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
747 goto exit;
748
749 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
750 fs_open(&sess, file_02, sizeof(file_02),
751 TEE_DATA_FLAG_ACCESS_READ |
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200752 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200753 goto exit;
754
755 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
756 goto exit;
757
758 (void)ADBG_EXPECT_BUFFER(c, data_01, 10, out, count);
759
760 /* clean */
761 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
762 goto exit;
763
764exit:
765 TEEC_CloseSession(&sess);
766}
767
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200768DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6003)
769
Pascal Brandc639ac82015-07-02 08:53:34 +0200770/* write */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200771static void xtest_tee_test_6004_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200772{
773 TEEC_Session sess;
774 uint32_t obj;
775 uint8_t out[10] = { 0 };
776 uint32_t count;
777 uint32_t orig;
778
779 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
780 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
781 return;
782
783 /* create */
784 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
785 fs_create(&sess, file_02, sizeof(file_02),
786 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200787 sizeof(data_01), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200788 goto exit;
789
790 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
791 goto exit;
792
793 /* write new data */
794 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
795 fs_open(&sess, file_02, sizeof(file_02),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200796 TEE_DATA_FLAG_ACCESS_WRITE, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200797 goto exit;
798
799 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
800 fs_write(&sess, obj, data_00, sizeof(data_00))))
801 goto exit;
802
803 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
804 goto exit;
805
806 /* verify */
807 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
808 fs_open(&sess, file_02, sizeof(file_02),
809 TEE_DATA_FLAG_ACCESS_READ |
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200810 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200811 goto exit;
812
813 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
814 goto exit;
815
816 (void)ADBG_EXPECT_BUFFER(c, data_00, 10, out, count);
817
818 /* clean */
819 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
820 goto exit;
821
822exit:
823 TEEC_CloseSession(&sess);
824}
825
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200826DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6004)
827
Pascal Brandc639ac82015-07-02 08:53:34 +0200828/* seek */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200829static void xtest_tee_test_6005_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200830{
831 TEEC_Session sess;
832 uint32_t obj;
833 uint8_t out[10] = { 0 };
834 uint32_t count;
835 uint32_t orig;
836
837 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
838 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
839 return;
840
841 /* create */
842 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
843 fs_create(&sess, file_01, sizeof(file_01),
844 TEE_DATA_FLAG_ACCESS_WRITE |
845 TEE_DATA_FLAG_ACCESS_READ |
846 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200847 sizeof(data_00), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200848 goto exit;
849
850 /* seek */
851 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
852 fs_seek(&sess, obj, 10, TEE_DATA_SEEK_SET)))
853 goto exit;
854
855 /* verify */
856 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
857 goto exit;
858
859 (void)ADBG_EXPECT_BUFFER(c, &data_00[10], 10, out, count);
860
861 /* clean */
862 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
863 goto exit;
864
865exit:
866 TEEC_CloseSession(&sess);
867}
868
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200869DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6005)
870
Pascal Brandc639ac82015-07-02 08:53:34 +0200871/* unlink */
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200872static void xtest_tee_test_6006_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200873{
874 TEEC_Session sess;
875 uint32_t obj;
876 uint32_t orig;
877
878 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
879 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
880 return;
881
882 /* create */
883 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
884 fs_create(&sess, file_01, sizeof(file_01),
885 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200886 sizeof(data_00), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200887 goto exit;
888
889 /* del & close */
890 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
891 goto exit;
892
893 /* check result */
894 if (!ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_ITEM_NOT_FOUND,
895 fs_open(&sess, file_01, sizeof(file_01),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200896 TEE_DATA_FLAG_ACCESS_READ, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200897 goto exit;
898
899exit:
900 TEEC_CloseSession(&sess);
901}
902
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200903DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6006)
904
905static void xtest_tee_test_6007_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200906{
James Kung98c0ba12015-09-09 15:51:59 +0800907 Do_ADBG_BeginSubCase(c, "Test truncate file length");
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200908 test_truncate_file_length(c, storage_id);
James Kung98c0ba12015-09-09 15:51:59 +0800909 Do_ADBG_EndSubCase(c, "Test truncate file length");
Pascal Brandc639ac82015-07-02 08:53:34 +0200910
James Kung98c0ba12015-09-09 15:51:59 +0800911 Do_ADBG_BeginSubCase(c, "Test extend file length");
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200912 test_extend_file_length(c, storage_id);
James Kung98c0ba12015-09-09 15:51:59 +0800913 Do_ADBG_EndSubCase(c, "Test extend file length");
Pascal Brandc639ac82015-07-02 08:53:34 +0200914
James Kung98c0ba12015-09-09 15:51:59 +0800915 Do_ADBG_BeginSubCase(c, "Test file hole");
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200916 test_file_hole(c, storage_id);
James Kung98c0ba12015-09-09 15:51:59 +0800917 Do_ADBG_EndSubCase(c, "Test file hole");
Pascal Brandc639ac82015-07-02 08:53:34 +0200918}
919
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200920DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6007)
921
922static void xtest_tee_test_6008_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200923{
924 TEEC_Session sess;
925 uint32_t obj;
926 uint8_t out[10] = { 0 };
927 uint32_t count;
928 uint32_t orig;
929
930 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
931 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
932 return;
933
934 /* create */
935 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
936 fs_create(&sess, file_02, sizeof(file_02),
937 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200938 sizeof(data_01), &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200939 goto exit;
940
941 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
942 goto exit;
943
944 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
945 fs_open(&sess, file_02, sizeof(file_02),
946 TEE_DATA_FLAG_ACCESS_WRITE |
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200947 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200948 goto exit;
949
950 /* write new data */
951 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
952 fs_write(&sess, obj, data_00, sizeof(data_00))))
953 goto exit;
954
955 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
956 fs_rename(&sess, obj, file_03, sizeof(file_03))))
957 goto exit;
958
959 /* close */
960 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj)))
961 goto exit;
962
963 /* verify */
964 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
965 fs_open(&sess, file_03, sizeof(file_03),
966 TEE_DATA_FLAG_ACCESS_READ |
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200967 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +0200968 goto exit;
969
970 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_read(&sess, obj, out, 10, &count)))
971 goto exit;
972
973 /* check buffer */
974 (void)ADBG_EXPECT_BUFFER(c, data_00, 10, out, count);
975
976 /* clean */
977 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
978 goto exit;
979
980exit:
981 TEEC_CloseSession(&sess);
982}
983
Jerome Forissier0e99d6a2016-07-25 14:21:43 +0200984DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6008)
985
986static void xtest_tee_test_6009_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandc639ac82015-07-02 08:53:34 +0200987{
988 TEEC_Session sess;
989 uint32_t obj0;
990 uint32_t obj1;
991 uint32_t obj2;
992 uint32_t e = 0;
993 uint8_t info[200];
994 uint8_t id[200];
995 uint32_t orig;
996
997 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
998 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
999 return;
1000
1001 /* create file 00 */
1002 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1003 fs_create(&sess, file_00, sizeof(file_00),
1004 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001005 sizeof(data_01), &obj0, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001006 goto exit;
1007
1008 /* create file 01 */
1009 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1010 fs_create(&sess, file_01, sizeof(file_01),
1011 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001012 sizeof(data_01), &obj1, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001013 goto exit;
1014
1015 /* create file 02 */
1016 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1017 fs_create(&sess, file_02, sizeof(file_02),
1018 TEE_DATA_FLAG_ACCESS_WRITE, 0, data_01,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001019 sizeof(data_01), &obj2, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001020 goto exit;
1021
1022 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj0)))
1023 goto exit;
1024
1025 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj1)))
1026 goto exit;
1027
1028 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_close(&sess, obj2)))
1029 goto exit;
1030
1031 /* iterate */
1032 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_alloc_enum(&sess, &e)))
1033 goto exit;
1034
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001035 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_start_enum(&sess, e, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001036 goto exit;
1037
1038 /* get 00 */
1039 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1040 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
1041 goto exit;
1042
1043 /* get 01 */
1044 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Pascal Brandc603e0d2016-04-25 12:37:18 +02001045 fs_next_enum(&sess, e, NULL, 0, id, sizeof(id))))
Pascal Brandc639ac82015-07-02 08:53:34 +02001046 goto exit;
1047
1048 /* get 02 */
1049 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1050 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
1051 goto exit;
1052
1053 /* we should not have more files */
1054 if (!ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_ITEM_NOT_FOUND,
1055 fs_next_enum(&sess, e, info, sizeof(info), id, sizeof(id))))
1056 goto exit;
1057
1058 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_free_enum(&sess, e)))
1059 goto exit;
1060
1061 /* clean */
1062 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1063 fs_open(&sess, file_00, sizeof(file_00),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001064 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj0, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001065 goto exit;
1066
1067 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj0)))
1068 goto exit;
1069
1070 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1071 fs_open(&sess, file_01, sizeof(file_01),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001072 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj1, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001073 goto exit;
1074
1075 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj1)))
1076 goto exit;
1077
1078 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1079 fs_open(&sess, file_02, sizeof(file_02),
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001080 TEE_DATA_FLAG_ACCESS_WRITE_META, &obj2, storage_id)))
Pascal Brandc639ac82015-07-02 08:53:34 +02001081 goto exit;
1082
1083 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj2)))
1084 goto exit;
1085
1086exit:
1087 TEEC_CloseSession(&sess);
1088}
1089
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001090DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6009)
1091
Jerome Forissiere3688342015-09-24 10:45:17 -07001092#ifdef WITH_GP_TESTS
Pascal Brand8a74e362015-09-10 12:41:52 +02001093static void xtest_tee_test_6010(ADBG_Case_t *c)
1094{
1095 TEEC_Session sess;
1096 uint32_t orig;
1097 uint8_t out[4000] = {0};
1098 uint8_t in[0x12c] = {'b'};
Pascal Brand30844922015-09-17 12:12:42 +02001099 int i;
1100
1101 for (i=0; i<sizeof(in); i++)
1102 in[i] = i;
Pascal Brand8a74e362015-09-10 12:41:52 +02001103
1104 if (!ADBG_EXPECT_TEEC_SUCCESS(
1105 c, xtest_teec_open_session(
1106 &sess, &gp_tta_ds_uuid, NULL, &orig)))
1107 return;
1108
1109 Do_ADBG_BeginSubCase(
1110 c, "GP DS CreatePersistentObject AccessConflict (9d-1d-62)");
1111
1112 if (!ADBG_EXPECT_TEEC_RESULT(
1113 c, TEEC_ERROR_ACCESS_CONFLICT, ds_open_access_conf(&sess)))
1114 goto exit;
1115
1116 Do_ADBG_EndSubCase(
1117 c, "GP DS CreatePersistentObject AccessConflict (9d-1d-62)");
1118 Do_ADBG_BeginSubCase(
1119 c, "GP DS RestrictObjectUsagePanic (9d-5d-46)");
1120
1121 if (!ADBG_EXPECT_TEEC_RESULT(
1122 c, TEE_ERROR_TARGET_DEAD, ds_res_obj_panic(&sess)))
1123 goto exit;
1124
1125 TEEC_CloseSession(&sess);
1126
1127 Do_ADBG_EndSubCase(
1128 c, "GP DS RestrictObjectUsagePanic (9d-5d-46)");
1129 Do_ADBG_BeginSubCase(
1130 c, "GP DS SeekObjectData BadHandle (9d-c3-c8)");
1131
1132 if (!ADBG_EXPECT_TEEC_SUCCESS(
1133 c, xtest_teec_open_session(
1134 &sess, &gp_tta_ds_uuid, NULL, &orig)))
1135 return;
1136
1137 if (!ADBG_EXPECT_TEEC_RESULT(
1138 c, TEE_ERROR_TARGET_DEAD, ds_seek_obj_bad_handle(&sess)))
1139 goto exit;
1140
1141 TEEC_CloseSession(&sess);
1142
1143 Do_ADBG_EndSubCase(
1144 c, "GP DS SeekObjectData BadHandle (9d-c3-c8)");
1145 Do_ADBG_BeginSubCase(
1146 c, "GP DS SeekObjectData NotPersist (9d-db-4a)");
1147
1148 if (!ADBG_EXPECT_TEEC_SUCCESS(
1149 c, xtest_teec_open_session(
1150 &sess, &gp_tta_ds_uuid, NULL, &orig)))
1151 return;
1152
1153 if (!ADBG_EXPECT_TEEC_RESULT(
1154 c, TEE_ERROR_TARGET_DEAD, ds_seek_obj_inv_handle(&sess)))
1155 goto exit;
1156
1157 TEEC_CloseSession(&sess);
1158
1159 Do_ADBG_EndSubCase(
1160 c, "GP DS SeekObjectData NotPersist (9d-db-4a)");
1161 Do_ADBG_BeginSubCase(c, "GP DS SeekWriteRead SEEK_END (9d-e4-58)");
1162
1163 if (!ADBG_EXPECT_TEEC_SUCCESS(
1164 c, xtest_teec_open_session(
1165 &sess, &gp_tta_ds_uuid, NULL, &orig)))
1166 return;
1167
1168 if (!ADBG_EXPECT_TEEC_SUCCESS(
1169 c, ds_seek_gp(
1170 &sess, TEE_DATA_SEEK_END, 0, 2, data_00, sizeof(data_00), out,
1171 sizeof(out))))
1172 goto exit;
1173
1174 /* check buffer */
1175 (void)ADBG_EXPECT_BUFFER(
1176 c, data_00, sizeof(data_00), out, sizeof(data_00));
Pascal Brand30844922015-09-17 12:12:42 +02001177 memset(out, 0xab, sizeof(out));
Pascal Brand8a74e362015-09-10 12:41:52 +02001178
1179 if (!ADBG_EXPECT_TEEC_SUCCESS(
1180 c, ds_seek_gp(
Pascal Brand30844922015-09-17 12:12:42 +02001181 &sess, TEE_DATA_SEEK_END, sizeof(in)/2, 0, in, sizeof(in), out,
Pascal Brand8a74e362015-09-10 12:41:52 +02001182 sizeof(out))))
1183 goto exit;
1184
Pascal Brand30844922015-09-17 12:12:42 +02001185 (void)ADBG_EXPECT_BUFFER(c, in, sizeof(in) / 2,
1186 out + (sizeof(in) / 2), sizeof(in) / 2);
1187 memset(in, 0, sizeof(in));
1188 (void)ADBG_EXPECT_BUFFER(c, in, sizeof(in) / 2,
1189 out, sizeof(in)/2);
1190 memset(out, 0xab, sizeof(out));
Pascal Brand8a74e362015-09-10 12:41:52 +02001191
1192 Do_ADBG_EndSubCase(c, "GP DS SeekWriteRead SEEK_END (9d-e4-58)");
1193 Do_ADBG_BeginSubCase(c, "GP DS Rename Access Conflict (9d-29-d1)");
1194
1195 if (!ADBG_EXPECT_TEEC_RESULT(
1196 c, TEE_ERROR_ACCESS_CONFLICT, ds_rename_access_conflict(&sess)))
1197 goto exit;
1198
1199 Do_ADBG_EndSubCase(c, "GP DS Rename Access Conflict (9d-29-d1)");
1200 Do_ADBG_BeginSubCase(
1201 c, "GP DS StartPersistentObjectEnumerator ItemNotFound (9d-52-ec)");
1202
1203 if (!ADBG_EXPECT_TEEC_SUCCESS(c, ds_start_enum_no_item(&sess)))
1204 goto exit;
1205
1206 Do_ADBG_EndSubCase(
1207 c, "GP DS StartPersistentObjectEnumerator ItemNotFound (9d-52-ec)");
1208 Do_ADBG_BeginSubCase(
1209 c, "GP DS RenamePersistent ReadWrite (9d-19-88)");
1210
1211 if (!ADBG_EXPECT_TEEC_SUCCESS(c, ds_rename_success(&sess)))
1212 goto exit;
1213
1214 Do_ADBG_EndSubCase(
1215 c, "GP DS RenamePersistent ReadWrite (9d-19-88)");
1216 Do_ADBG_BeginSubCase(
1217 c, "GP DS Close Free Reset Null (9d-6d-87)");
1218
1219 if (!ADBG_EXPECT_TEEC_SUCCESS(c, ds_null_close_free_reset(&sess)))
1220 goto exit;
1221
1222 Do_ADBG_EndSubCase(
1223 c, "GP DS Close Free Reset Null (9d-6d-87)");
1224
1225exit:
1226 TEEC_CloseSession(&sess);
1227}
1228
1229static void xtest_tee_test_6011(ADBG_Case_t *c)
1230{
1231 TEEC_Session sess;
1232 uint32_t orig;
1233 /*
1234 * Test data from
1235 * Invoke_InitObjectAndAttributes_TEE_TYPE_AES_success_attribute_
1236 * TEE_ATTR_SECRET_VALUE_correct_size (9d-9a-91)
1237 */
1238 static const uint8_t attr_meta[] = {
12390xc0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,
12400x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12410x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
12420x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
1243 };
1244 static const uint8_t attr_data[] = {
12450x60,0x3d,0xeb,0x10,0x15,0xca,0x71,0xbe,0x2b,0x73,0xae,0xf0,0x85,0x7d,0x77,
12460x81,0x1f,0x35,0x2c,0x07,0x3b,0x61,0x08,0xd7,0x2d,0x98,0x10,0xa3,0x09,0x14,
12470xdf,0xf4,
1248 };
1249
1250 if (!ADBG_EXPECT_TEEC_SUCCESS(
1251 c, xtest_teec_open_session(
1252 &sess, &gp_tta_ds_uuid, NULL, &orig)))
1253 return;
1254
1255 if (!ADBG_EXPECT_TEEC_SUCCESS(c, ds_init_object_and_attributes(&sess,
1256 0xa0000010, 0x100, attr_meta, sizeof(attr_meta), attr_data,
1257 sizeof(attr_data), 0)))
1258 goto exit;
1259
1260exit:
1261 TEEC_CloseSession(&sess);
1262}
1263#endif
1264
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001265static void xtest_tee_test_6012_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brandeb84c442016-04-19 17:49:49 +02001266{
1267 TEEC_Session sess;
1268 uint32_t orig;
1269 uint32_t obj;
1270
1271 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1272 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
1273 return;
1274
1275 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001276 fs_create_overwrite(&sess, file_04, sizeof(file_04), storage_id)))
Pascal Brandeb84c442016-04-19 17:49:49 +02001277 goto exit;
1278
1279 TEEC_CloseSession(&sess);
1280
1281 /* re-create the same */
1282 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1283 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
1284 return;
1285
1286 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001287 fs_create_overwrite(&sess, file_04, sizeof(file_04),
1288 storage_id)))
Pascal Brandeb84c442016-04-19 17:49:49 +02001289 goto exit;
1290
1291 /*
1292 * recreate it with an object, and remove it so that xtest 6009
1293 * can be replayed
1294 */
1295 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1296 fs_create(&sess, file_04, sizeof(file_04),
1297 TEE_DATA_FLAG_ACCESS_WRITE |
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001298 TEE_DATA_FLAG_ACCESS_WRITE_META |
1299 TEE_DATA_FLAG_OVERWRITE, 0, NULL, 0, &obj,
1300 storage_id)))
Pascal Brandeb84c442016-04-19 17:49:49 +02001301 goto exit;
1302
1303 /* clean */
1304 if (!ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj)))
1305 goto exit;
1306
1307exit:
1308 TEEC_CloseSession(&sess);
1309}
1310
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001311DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6012)
1312
1313static void xtest_tee_test_6013_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brand90f23352016-05-19 15:15:47 +02001314{
1315 TEEC_Session sess;
1316 uint32_t orig;
1317 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
1318
1319 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1320 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
1321 return;
1322
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001323 op.params[0].value.a = storage_id;
1324 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
Pascal Brand90f23352016-05-19 15:15:47 +02001325 TEEC_NONE, TEEC_NONE);
1326
1327 ADBG_EXPECT_TEEC_SUCCESS(c,
1328 TEEC_InvokeCommand(&sess, TA_STORAGE_CMD_KEY_IN_PERSISTENT,
1329 &op, &orig));
1330
1331 TEEC_CloseSession(&sess);
1332}
1333
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001334DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6013)
1335
1336static void xtest_tee_test_6014_single(ADBG_Case_t *c, uint32_t storage_id)
Pascal Brand29ee18f2016-05-23 14:13:56 +02001337{
1338 TEEC_Session sess;
1339 uint32_t orig;
1340 TEEC_Operation op = TEEC_OPERATION_INITIALIZER;
1341
1342 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1343 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
1344 return;
1345
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001346 op.params[0].value.a = storage_id;
1347 op.paramTypes = TEEC_PARAM_TYPES(TEEC_VALUE_INPUT, TEEC_NONE,
Pascal Brand29ee18f2016-05-23 14:13:56 +02001348 TEEC_NONE, TEEC_NONE);
1349
1350 ADBG_EXPECT_TEEC_SUCCESS(c,
1351 TEEC_InvokeCommand(&sess, TA_STORAGE_CMD_LOOP, &op, &orig));
1352
1353 TEEC_CloseSession(&sess);
1354}
1355
Jerome Forissier0e99d6a2016-07-25 14:21:43 +02001356DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6014)
1357
Jerome Forissiere3854162016-08-12 12:40:12 +02001358static int get_ta_storage_path(TEEC_UUID *p_uuid, char *buffer, uint32_t len)
1359{
1360 int s;
1361
1362 if (!p_uuid || !buffer)
1363 return -1;
1364
1365 s = snprintf(buffer, len, "/data/tee/");
1366 if (s < 0 || s >= (int)len)
1367 return -1;
1368
1369 len -= s;
1370 buffer += s;
1371
1372 s = ree_fs_get_ta_dirname(p_uuid, buffer, len);
1373 return s;
1374}
1375
1376static int rename_data_dir(TEEC_UUID *old, TEEC_UUID *nw)
1377{
1378 char opath[150];
1379 char npath[150];
1380 int s;
1381
1382 s = get_ta_storage_path(old, opath, sizeof(opath));
1383 if (s < 0 || s >= (int)sizeof(opath)) {
1384 s = -1;
1385 goto exit;
1386 }
1387 s = get_ta_storage_path(nw, npath, sizeof(npath));
1388 if (s < 0 || s >= (int)sizeof(opath)) {
1389 s = -1;
1390 goto exit;
1391 }
1392 s = rename(opath, npath);
1393exit:
1394 if (s < 0)
1395 fprintf(stderr, "Warning: could not rename %s -> %s\n", opath,
1396 npath);
1397 return s;
1398}
1399
1400static void xtest_tee_test_6015_single(ADBG_Case_t *c, uint32_t storage_id)
1401{
1402 TEEC_Session sess;
1403 TEEC_Session sess2;
1404 uint32_t orig;
1405 uint32_t obj;
1406 uint32_t obj2;
1407 TEEC_UUID uuid = TA_STORAGE_UUID;
1408 TEEC_UUID uuid2 = TA_STORAGE2_UUID;
1409
1410 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1411 xtest_teec_open_session(&sess, &storage_ta_uuid, NULL, &orig)))
1412 return;
1413
1414 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1415 xtest_teec_open_session(&sess2, &storage2_ta_uuid, NULL,
1416 &orig)))
1417 goto exit2;
1418
1419 /* TA #1 creates a persistent object */
1420 if (!ADBG_EXPECT_TEEC_SUCCESS(c,
1421 fs_create(&sess, file_01, sizeof(file_01),
1422 TEE_DATA_FLAG_ACCESS_WRITE |
1423 TEE_DATA_FLAG_ACCESS_READ |
1424 TEE_DATA_FLAG_ACCESS_WRITE_META, 0, data_00,
1425 sizeof(data_00), &obj, storage_id)))
1426 goto exit;
1427
1428 /* TA #2 tries to open the object created by TA #1 */
1429 if (!ADBG_EXPECT_TEEC_RESULT(c, TEEC_ERROR_ITEM_NOT_FOUND,
1430 fs_open(&sess2, file_01, sizeof(file_01),
1431 TEE_DATA_FLAG_ACCESS_READ, &obj2, storage_id)))
1432 goto clean;
1433
1434 if (storage_id == TEE_STORAGE_PRIVATE_REE) {
1435 /*
1436 * When the storage backend is the REE filesystem, we can
1437 * simulate a hack attempt by renaming the TA storage. Should
1438 * be detected by the TEE.
1439 */
1440 if (rename_data_dir(&uuid, &uuid2) < 0)
1441 goto clean;
1442
1443 /* TA #2 tries to open the object created by TA #1 */
1444 ADBG_EXPECT_TEEC_RESULT(c, TEE_ERROR_CORRUPT_OBJECT,
1445 fs_open(&sess2, file_01, sizeof(file_01),
1446 TEE_DATA_FLAG_ACCESS_READ, &obj2, storage_id));
1447 /*
1448 * At this point, the TEE is expected to have removed the
1449 * corrupt object, so there is no need to try and restore the
1450 * directory name.
1451 */
1452 goto exit;
1453 }
1454
1455clean:
1456 ADBG_EXPECT_TEEC_SUCCESS(c, fs_unlink(&sess, obj));
1457exit:
1458 TEEC_CloseSession(&sess2);
1459exit2:
1460 TEEC_CloseSession(&sess);
1461}
1462
1463DEFINE_TEST_MULTIPLE_STORAGE_IDS(xtest_tee_test_6015)
1464
Pascal Brandc639ac82015-07-02 08:53:34 +02001465ADBG_CASE_DEFINE(
1466 XTEST_TEE_6001, xtest_tee_test_6001,
1467 /* Title */
1468 "Test TEE_CreatePersistentObject",
1469 /* Short description */
1470 "Short description ...",
1471 /* Requirement IDs */
1472 "TEE-??",
1473 /* How to implement */
1474 "Description of how to implement ..."
1475 );
1476
1477ADBG_CASE_DEFINE(
1478 XTEST_TEE_6002, xtest_tee_test_6002,
1479 /* Title */
1480 "Test TEE_OpenPersistentObject",
1481 /* Short description */
1482 "Short description ...",
1483 /* Requirement IDs */
1484 "TEE-??",
1485 /* How to implement */
1486 "Description of how to implement ..."
1487 );
1488
1489ADBG_CASE_DEFINE(
1490 XTEST_TEE_6003, xtest_tee_test_6003,
1491 /* Title */
1492 "Test TEE_ReadObjectData",
1493 /* Short description */
1494 "Short description ...",
1495 /* Requirement IDs */
1496 "TEE-??",
1497 /* How to implement */
1498 "Description of how to implement ..."
1499 );
1500
1501ADBG_CASE_DEFINE(
1502 XTEST_TEE_6004, xtest_tee_test_6004,
1503 /* Title */
1504 "Test TEE_WriteObjectData",
1505 /* Short description */
1506 "Short description ...",
1507 /* Requirement IDs */
1508 "TEE-??",
1509 /* How to implement */
1510 "Description of how to implement ..."
1511 );
1512
1513ADBG_CASE_DEFINE(
1514 XTEST_TEE_6005, xtest_tee_test_6005,
1515 /* Title */
1516 "Test TEE_SeekObjectData",
1517 /* Short description */
1518 "Short description ...",
1519 /* Requirement IDs */
1520 "TEE-??",
1521 /* How to implement */
1522 "Description of how to implement ..."
1523 );
1524
1525ADBG_CASE_DEFINE(
1526 XTEST_TEE_6006, xtest_tee_test_6006,
1527 /* Title */
1528 "Test TEE_CloseAndDeletePersistentObject",
1529 /* Short description */
1530 "Short description ...",
1531 /* Requirement IDs */
1532 "TEE-??",
1533 /* How to implement */
1534 "Description of how to implement ..."
1535 );
1536
1537ADBG_CASE_DEFINE(
1538 XTEST_TEE_6007, xtest_tee_test_6007,
1539 /* Title */
1540 "Test TEE_TruncateObjectData",
1541 /* Short description */
1542 "Short description ...",
1543 /* Requirement IDs */
1544 "TEE-??",
1545 /* How to implement */
1546 "Description of how to implement ..."
1547 );
1548
1549ADBG_CASE_DEFINE(
1550 XTEST_TEE_6008, xtest_tee_test_6008,
1551 /* Title */
1552 "Test TEE_RenamePersistentObject",
1553 /* Short description */
1554 "Short description ...",
1555 /* Requirement IDs */
1556 "TEE-??",
1557 /* How to implement */
1558 "Description of how to implement ..."
1559 );
1560
1561ADBG_CASE_DEFINE(
1562 XTEST_TEE_6009, xtest_tee_test_6009,
1563 /* Title */
1564 "Test TEE Internal API Persistent Object Enumeration Functions",
1565 /* Short description */
1566 "Short description ...",
1567 /* Requirement IDs */
1568 "TEE-??",
1569 /* How to implement */
1570 "Description of how to implement ..."
1571 );
Pascal Brand8a74e362015-09-10 12:41:52 +02001572
Jerome Forissiere3688342015-09-24 10:45:17 -07001573#ifdef WITH_GP_TESTS
Pascal Brand8a74e362015-09-10 12:41:52 +02001574ADBG_CASE_DEFINE(
1575 XTEST_TEE_6010, xtest_tee_test_6010,
1576 /* Title */
1577 "Test TEE GP TTA DS storage",
1578 /* Short description */
1579 "Short description ...",
1580 /* Requirement IDs */
1581 "TEE-??",
1582 /* How to implement */
1583 "Description of how to implement ..."
1584);
1585
1586ADBG_CASE_DEFINE(
1587 XTEST_TEE_6011, xtest_tee_test_6011,
1588 /* Title */
1589 "Test TEE GP TTA DS init objects",
1590 /* Short description */
1591 "Short description ...",
1592 /* Requirement IDs */
1593 "TEE-??",
1594 /* How to implement */
1595 "Description of how to implement ..."
1596);
1597#endif
Pascal Brandeb84c442016-04-19 17:49:49 +02001598
1599ADBG_CASE_DEFINE(
1600 XTEST_TEE_6012, xtest_tee_test_6012,
1601 /* Title */
1602 "Test TEE GP TTA DS init objects",
1603 /* Short description */
1604 "Short description ...",
1605 /* Requirement IDs */
1606 "TEE-??",
1607 /* How to implement */
1608 "Description of how to implement ..."
1609);
Pascal Brand90f23352016-05-19 15:15:47 +02001610
1611ADBG_CASE_DEFINE(
1612 XTEST_TEE_6013, xtest_tee_test_6013,
1613 /* Title */
1614 "Key usage in Persistent objects",
1615 /* Short description */
1616 "Short description ...",
1617 /* Requirement IDs */
1618 "TEE-??",
1619 /* How to implement */
1620 "Description of how to implement ..."
1621);
Pascal Brand29ee18f2016-05-23 14:13:56 +02001622
1623ADBG_CASE_DEFINE(
1624 XTEST_TEE_6014, xtest_tee_test_6014,
1625 /* Title */
1626 "Loop on Persistent objects",
1627 /* Short description */
1628 "Short description ...",
1629 /* Requirement IDs */
1630 "TEE-??",
1631 /* How to implement */
1632 "Description of how to implement ..."
1633);
Jerome Forissiere3854162016-08-12 12:40:12 +02001634
1635ADBG_CASE_DEFINE(
1636 XTEST_TEE_6015, xtest_tee_test_6015,
1637 /* Title */
1638 "Storage isolation",
1639 /* Short description */
1640 "TA #2 tries to open object created by TA #1, should fail",
1641 /* Requirement IDs */
1642 "",
1643 /* How to implement */
1644 ""
1645);