blob: 2339db2a9f50a33543909dcdad4f96496f55e20b [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#ifndef XTEST_HELPERS_H
15#define XTEST_HELPERS_H
16
17#include <tee_client_api.h>
18#include <tee_api_types.h>
19#include <adbg.h>
20
Cedric Chaumontc3b6c282015-09-25 03:05:18 +020021extern unsigned int level;
22
Pascal Brandc639ac82015-07-02 08:53:34 +020023/* Global context to use if any context is needed as input to a function */
24extern TEEC_Context xtest_teec_ctx;
25
26/*
27 * Initializes the context above, should be called before the ADBG test
28 * cases are run.
29 */
30TEEC_Result xtest_teec_ctx_init(void);
31void xtest_teec_ctx_deinit(void);
32
33/* Opens a session */
34TEEC_Result xtest_teec_open_session(TEEC_Session *session,
35 const TEEC_UUID *uuid, TEEC_Operation *op,
36 uint32_t *ret_orig);
37
38TEEC_Result xtest_teec_open_static_session(TEEC_Session *session,
39 TEEC_Operation *op,
40 uint32_t *ret_orig);
41
Aijun Sun9dbed272015-10-15 15:44:19 +080042#define TEEC_OPERATION_INITIALIZER { 0 }
Pascal Brandc639ac82015-07-02 08:53:34 +020043
44/* IO access macro */
45#define IO(addr) (*((volatile unsigned long *)(addr)))
46
Igor Opaniuk136644a2016-09-13 13:40:56 +030047#define UNUSED(x) (void)(x)
Pascal Brandc639ac82015-07-02 08:53:34 +020048/*
49 * Helpers for commands towards the crypt TA
50 */
51TEEC_Result ta_crypt_cmd_allocate_operation(ADBG_Case_t *c,
52 TEEC_Session *s,
53 TEE_OperationHandle *oph,
54 uint32_t algo,
55 uint32_t mode,
56 uint32_t max_key_size);
57
58TEEC_Result ta_crypt_cmd_allocate_transient_object(ADBG_Case_t *c,
59 TEEC_Session *s,
60 TEE_ObjectType obj_type, uint32_t max_obj_size,
61 TEE_ObjectHandle *o);
62
63TEEC_Result ta_crypt_cmd_populate_transient_object(ADBG_Case_t *c,
64 TEEC_Session *s,
65 TEE_ObjectHandle o,
66 const TEE_Attribute *attrs,
67 uint32_t attr_count);
68
69TEE_Result ta_crypt_cmd_set_operation_key(ADBG_Case_t *c,
70 TEEC_Session *s,
71 TEE_OperationHandle oph,
72 TEE_ObjectHandle key);
73
74TEEC_Result ta_crypt_cmd_free_transient_object(ADBG_Case_t *c,
75 TEEC_Session *s,
76 TEE_ObjectHandle o);
77
78TEEC_Result ta_crypt_cmd_derive_key(ADBG_Case_t *c,
79 TEEC_Session *s,
80 TEE_OperationHandle oph,
81 TEE_ObjectHandle o,
82 const TEE_Attribute *params,
83 uint32_t paramCount);
84
85TEEC_Result ta_crypt_cmd_get_object_buffer_attribute(ADBG_Case_t *c,
86 TEEC_Session *s,
87 TEE_ObjectHandle o,
88 uint32_t attr_id,
89 void *buf,
90 size_t *blen);
91
92TEEC_Result ta_crypt_cmd_free_operation(ADBG_Case_t *c,
93 TEEC_Session *s,
94 TEE_OperationHandle oph);
95
96void xtest_add_attr(size_t *attr_count, TEE_Attribute *attrs,
97 uint32_t attr_id, const void *buf, size_t len);
Pascal Brande61133f2015-07-08 15:38:37 +020098void xtest_add_attr_value(size_t *attr_count, TEE_Attribute *attrs,
99 uint32_t attr_id, uint32_t value_a, uint32_t value_b);
Pascal Brandc639ac82015-07-02 08:53:34 +0200100
101TEE_Result pack_attrs(const TEE_Attribute *attrs, uint32_t attr_count,
102 uint8_t **buf, size_t *blen);
103
Jerome Forissiere3854162016-08-12 12:40:12 +0200104int ree_fs_get_ta_dirname(TEEC_UUID *p_uuid, char *buffer, uint32_t len);
105
Pascal Brandc639ac82015-07-02 08:53:34 +0200106#endif /*XTEST_HELPERS_H*/