blob: 691fa16aea76c6e88a54bc8857e7a5bf3bf45568 [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
47/*
48 * Helpers for commands towards the crypt TA
49 */
50TEEC_Result ta_crypt_cmd_allocate_operation(ADBG_Case_t *c,
51 TEEC_Session *s,
52 TEE_OperationHandle *oph,
53 uint32_t algo,
54 uint32_t mode,
55 uint32_t max_key_size);
56
57TEEC_Result ta_crypt_cmd_allocate_transient_object(ADBG_Case_t *c,
58 TEEC_Session *s,
59 TEE_ObjectType obj_type, uint32_t max_obj_size,
60 TEE_ObjectHandle *o);
61
62TEEC_Result ta_crypt_cmd_populate_transient_object(ADBG_Case_t *c,
63 TEEC_Session *s,
64 TEE_ObjectHandle o,
65 const TEE_Attribute *attrs,
66 uint32_t attr_count);
67
68TEE_Result ta_crypt_cmd_set_operation_key(ADBG_Case_t *c,
69 TEEC_Session *s,
70 TEE_OperationHandle oph,
71 TEE_ObjectHandle key);
72
73TEEC_Result ta_crypt_cmd_free_transient_object(ADBG_Case_t *c,
74 TEEC_Session *s,
75 TEE_ObjectHandle o);
76
77TEEC_Result ta_crypt_cmd_derive_key(ADBG_Case_t *c,
78 TEEC_Session *s,
79 TEE_OperationHandle oph,
80 TEE_ObjectHandle o,
81 const TEE_Attribute *params,
82 uint32_t paramCount);
83
84TEEC_Result ta_crypt_cmd_get_object_buffer_attribute(ADBG_Case_t *c,
85 TEEC_Session *s,
86 TEE_ObjectHandle o,
87 uint32_t attr_id,
88 void *buf,
89 size_t *blen);
90
91TEEC_Result ta_crypt_cmd_free_operation(ADBG_Case_t *c,
92 TEEC_Session *s,
93 TEE_OperationHandle oph);
94
95void xtest_add_attr(size_t *attr_count, TEE_Attribute *attrs,
96 uint32_t attr_id, const void *buf, size_t len);
Pascal Brande61133f2015-07-08 15:38:37 +020097void xtest_add_attr_value(size_t *attr_count, TEE_Attribute *attrs,
98 uint32_t attr_id, uint32_t value_a, uint32_t value_b);
Pascal Brandc639ac82015-07-02 08:53:34 +020099
100TEE_Result pack_attrs(const TEE_Attribute *attrs, uint32_t attr_count,
101 uint8_t **buf, size_t *blen);
102
103#endif /*XTEST_HELPERS_H*/