optee_utee_sys/
utee_syscalls.rs

1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements.  See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership.  The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License.  You may obtain a copy of the License at
8//
9//   http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied.  See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use super::utee_types::utee_object_info;
19use super::*;
20use crate::size_t;
21use core::ffi::*;
22
23unsafe extern "C" {
24    pub fn _utee_return(ret: c_ulong) -> !;
25    pub fn _utee_log(buf: *const c_void, len: size_t);
26    pub fn _utee_panic(code: c_ulong);
27    pub fn _utee_get_property(
28        prop_set: c_ulong,
29        index: c_ulong,
30        name: *mut c_void,
31        name_len: *mut u32,
32        buf: *mut c_void,
33        blen: *mut u32,
34        prop_type: *mut u32,
35    ) -> TEE_Result;
36    pub fn _utee_get_property_name_to_index(
37        prop_set: c_ulong,
38        name: *const c_void,
39        name_len: c_ulong,
40        index: *mut u32,
41    ) -> TEE_Result;
42    pub fn _utee_open_ta_session(
43        dest: *const TEE_UUID,
44        cancel_req_to: c_ulong,
45        params: *mut utee_params,
46        sess: *mut u32,
47        ret_orig: *mut u32,
48    ) -> TEE_Result;
49    pub fn _utee_close_ta_session(sess: c_ulong) -> TEE_Result;
50    pub fn _utee_invoke_ta_command(
51        sess: c_ulong,
52        cancel_req_to: c_ulong,
53        cmd_id: c_ulong,
54        params: *mut utee_params,
55        ret_orig: *mut u32,
56    ) -> TEE_Result;
57    pub fn _utee_check_access_rights(flags: u32, buf: *const c_void, len: size_t) -> TEE_Result;
58    pub fn _utee_get_cancellation_flag(cancel: *mut u32) -> TEE_Result;
59    pub fn _utee_unmask_cancellation(old_mask: *mut u32) -> TEE_Result;
60    pub fn _utee_mask_cancellation(old_mask: *mut u32) -> TEE_Result;
61    pub fn _utee_wait(timeout: c_ulong) -> TEE_Result;
62    pub fn _utee_get_time(cat: c_ulong, time: *mut TEE_Time) -> TEE_Result;
63    pub fn _utee_set_ta_time(time: *const TEE_Time) -> TEE_Result;
64    pub fn _utee_cryp_state_alloc(
65        algo: c_ulong,
66        op_mode: c_ulong,
67        key1: c_ulong,
68        key2: c_ulong,
69        state: *mut u32,
70    ) -> TEE_Result;
71    pub fn _utee_cryp_state_copy(dst: c_ulong, src: c_ulong) -> TEE_Result;
72    pub fn _utee_cryp_state_free(state: c_ulong) -> TEE_Result;
73    pub fn _utee_hash_init(state: c_ulong, iv: *const c_void, iv_len: size_t) -> TEE_Result;
74    pub fn _utee_hash_update(
75        state: c_ulong,
76        chunk: *const c_void,
77        chunk_size: size_t,
78    ) -> TEE_Result;
79    pub fn _utee_hash_final(
80        state: c_ulong,
81        chunk: *const c_void,
82        chunk_size: size_t,
83        hash: *mut c_void,
84        hash_len: *mut u64,
85    ) -> TEE_Result;
86    pub fn _utee_cipher_init(state: c_ulong, iv: *const c_void, iv_len: size_t) -> TEE_Result;
87    pub fn _utee_cipher_update(
88        state: c_ulong,
89        src: *const c_void,
90        src_len: size_t,
91        dest: *mut c_void,
92        dest_len: *mut u64,
93    ) -> TEE_Result;
94    pub fn _utee_cipher_final(
95        state: c_ulong,
96        src: *const c_void,
97        src_len: size_t,
98        dest: *mut c_void,
99        dest_len: *mut u64,
100    ) -> TEE_Result;
101    pub fn _utee_cryp_obj_get_info(obj: c_ulong, info: *mut utee_object_info) -> TEE_Result;
102    pub fn _utee_cryp_obj_restrict_usage(obj: c_ulong, usage: c_ulong) -> TEE_Result;
103    pub fn _utee_cryp_obj_get_attr(
104        obj: c_ulong,
105        attr_id: c_ulong,
106        buffer: *mut c_void,
107        size: *mut u64,
108    ) -> TEE_Result;
109    pub fn _utee_cryp_obj_alloc(ttype: c_ulong, max_size: c_ulong, obj: *mut u32) -> TEE_Result;
110    pub fn _utee_cryp_obj_close(obj: c_ulong) -> TEE_Result;
111    pub fn _utee_cryp_obj_reset(obj: c_ulong) -> TEE_Result;
112    pub fn _utee_cryp_obj_populate(
113        obj: c_ulong,
114        attrs: *mut utee_attribute,
115        attr_count: c_ulong,
116    ) -> TEE_Result;
117    pub fn _utee_cryp_obj_copy(dst_obj: c_ulong, src_obj: c_ulong) -> TEE_Result;
118    pub fn _utee_cryp_obj_generate_key(
119        obj: c_ulong,
120        key_size: c_ulong,
121        params: *const utee_attribute,
122        param_count: c_ulong,
123    ) -> TEE_Result;
124    pub fn _utee_cryp_derive_key(
125        state: c_ulong,
126        params: *const utee_attribute,
127        param_count: c_ulong,
128        derived_key: c_ulong,
129    ) -> TEE_Result;
130    pub fn _utee_cryp_random_number_generate(buf: *mut c_void, blen: size_t) -> TEE_Result;
131    pub fn _utee_authenc_init(
132        state: c_ulong,
133        nonce: *const c_void,
134        nonce_len: size_t,
135        tag_len: size_t,
136        aad_len: size_t,
137        payload_len: size_t,
138    ) -> TEE_Result;
139    pub fn _utee_authenc_update_aad(
140        state: c_ulong,
141        aad_data: *const c_void,
142        aad_data_len: size_t,
143    ) -> TEE_Result;
144    pub fn _utee_authenc_update_payload(
145        state: c_ulong,
146        src_data: *const c_void,
147        src_len: size_t,
148        dest_data: *mut c_void,
149        dest_len: *mut u64,
150    ) -> TEE_Result;
151    pub fn _utee_authenc_enc_final(
152        state: c_ulong,
153        src_data: *const c_void,
154        src_len: size_t,
155        dest_data: *mut c_void,
156        dest_len: *mut u64,
157        tag: *mut c_void,
158        tag_len: *mut u64,
159    ) -> TEE_Result;
160    pub fn _utee_authenc_dec_final(
161        state: c_ulong,
162        src_data: *const c_void,
163        src_len: size_t,
164        dest_data: *mut c_void,
165        dest_len: *mut u64,
166        tag: *const c_void,
167        tag_len: size_t,
168    ) -> TEE_Result;
169    pub fn _utee_asymm_operate(
170        state: c_ulong,
171        params: *const utee_attribute,
172        num_params: c_ulong,
173        src_data: *const c_void,
174        src_len: size_t,
175        dest_data: *mut c_void,
176        dest_len: *mut u64,
177    ) -> TEE_Result;
178    pub fn _utee_asymm_verify(
179        state: c_ulong,
180        params: *const utee_attribute,
181        num_params: c_ulong,
182        data: *const c_void,
183        data_len: size_t,
184        sig: *const c_void,
185        sig_len: size_t,
186    ) -> TEE_Result;
187    pub fn _utee_storage_obj_open(
188        storage_id: c_ulong,
189        object_id: *const c_void,
190        object_id_len: size_t,
191        flags: c_ulong,
192        obj: *mut u32,
193    ) -> TEE_Result;
194    pub fn _utee_storage_obj_create(
195        storage_id: c_ulong,
196        object_id: *const c_void,
197        object_id_len: size_t,
198        flags: c_ulong,
199        attr: c_ulong,
200        data: *const c_void,
201        len: size_t,
202        obj: *mut u32,
203    ) -> TEE_Result;
204    pub fn _utee_storage_obj_del(obj: c_ulong) -> TEE_Result;
205    pub fn _utee_storage_obj_rename(
206        obj: c_ulong,
207        new_obj_id: *const c_void,
208        new_obj_id_len: size_t,
209    ) -> TEE_Result;
210    pub fn _utee_storage_alloc_enum(obj_enum: *mut u32) -> TEE_Result;
211    pub fn _utee_storage_free_enum(obj_enum: c_ulong) -> TEE_Result;
212    pub fn _utee_storage_reset_enum(obj_enum: c_ulong) -> TEE_Result;
213    pub fn _utee_storage_start_enum(obj_enum: c_ulong, storage_id: c_ulong) -> TEE_Result;
214    pub fn _utee_storage_next_enum(
215        obj_enum: c_ulong,
216        info: *mut utee_object_info,
217        obj_id: *mut c_void,
218        len: *mut u64,
219    ) -> TEE_Result;
220    pub fn _utee_storage_obj_read(
221        obj: c_ulong,
222        data: *mut c_void,
223        len: size_t,
224        count: *mut u64,
225    ) -> TEE_Result;
226    pub fn _utee_storage_obj_write(obj: c_ulong, data: *const c_void, len: size_t) -> TEE_Result;
227    pub fn _utee_storage_obj_trunc(obj: c_ulong, len: size_t) -> TEE_Result;
228    pub fn _utee_storage_obj_seek(obj: c_ulong, offset: i32, whence: c_ulong) -> TEE_Result;
229    pub fn _utee_cache_operation(va: *mut c_void, l: size_t, op: c_ulong) -> TEE_Result;
230    // unimplemented syscall
231    // pub fn utee_gprof_send(buf: *mut c_void, size: size_t, id: *mut u32) -> TEE_Result;
232}