blob: 5fce344dd215e18ab9cff7361d06f870e6effd14 [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
21/* Global context to use if any context is needed as input to a function */
22extern TEEC_Context xtest_teec_ctx;
23
24/*
25 * Initializes the context above, should be called before the ADBG test
26 * cases are run.
27 */
28TEEC_Result xtest_teec_ctx_init(void);
29void xtest_teec_ctx_deinit(void);
30
31/* Opens a session */
32TEEC_Result xtest_teec_open_session(TEEC_Session *session,
33 const TEEC_UUID *uuid, TEEC_Operation *op,
34 uint32_t *ret_orig);
35
36TEEC_Result xtest_teec_open_static_session(TEEC_Session *session,
37 TEEC_Operation *op,
38 uint32_t *ret_orig);
39
40#define TEEC_OPERATION_INITIALIZER { 0, 0, { { { 0 } } } }
41
42/* IO access macro */
43#define IO(addr) (*((volatile unsigned long *)(addr)))
44
45/*
46 * Helpers for commands towards the crypt TA
47 */
48TEEC_Result ta_crypt_cmd_allocate_operation(ADBG_Case_t *c,
49 TEEC_Session *s,
50 TEE_OperationHandle *oph,
51 uint32_t algo,
52 uint32_t mode,
53 uint32_t max_key_size);
54
55TEEC_Result ta_crypt_cmd_allocate_transient_object(ADBG_Case_t *c,
56 TEEC_Session *s,
57 TEE_ObjectType obj_type, uint32_t max_obj_size,
58 TEE_ObjectHandle *o);
59
60TEEC_Result ta_crypt_cmd_populate_transient_object(ADBG_Case_t *c,
61 TEEC_Session *s,
62 TEE_ObjectHandle o,
63 const TEE_Attribute *attrs,
64 uint32_t attr_count);
65
66TEE_Result ta_crypt_cmd_set_operation_key(ADBG_Case_t *c,
67 TEEC_Session *s,
68 TEE_OperationHandle oph,
69 TEE_ObjectHandle key);
70
71TEEC_Result ta_crypt_cmd_free_transient_object(ADBG_Case_t *c,
72 TEEC_Session *s,
73 TEE_ObjectHandle o);
74
75TEEC_Result ta_crypt_cmd_derive_key(ADBG_Case_t *c,
76 TEEC_Session *s,
77 TEE_OperationHandle oph,
78 TEE_ObjectHandle o,
79 const TEE_Attribute *params,
80 uint32_t paramCount);
81
82TEEC_Result ta_crypt_cmd_get_object_buffer_attribute(ADBG_Case_t *c,
83 TEEC_Session *s,
84 TEE_ObjectHandle o,
85 uint32_t attr_id,
86 void *buf,
87 size_t *blen);
88
89TEEC_Result ta_crypt_cmd_free_operation(ADBG_Case_t *c,
90 TEEC_Session *s,
91 TEE_OperationHandle oph);
92
93void xtest_add_attr(size_t *attr_count, TEE_Attribute *attrs,
94 uint32_t attr_id, const void *buf, size_t len);
Pascal Brande61133f2015-07-08 15:38:37 +020095void xtest_add_attr_value(size_t *attr_count, TEE_Attribute *attrs,
96 uint32_t attr_id, uint32_t value_a, uint32_t value_b);
Pascal Brandc639ac82015-07-02 08:53:34 +020097
98TEE_Result pack_attrs(const TEE_Attribute *attrs, uint32_t attr_count,
99 uint8_t **buf, size_t *blen);
100
101#endif /*XTEST_HELPERS_H*/