optee_utee_sys/
tee_api_types.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
18// Common Definitions
19
20use crate::size_t;
21use core::ffi::*;
22
23#[allow(non_camel_case_types)]
24pub type TEE_Result = u32;
25
26#[repr(C)]
27#[derive(Copy, Clone)]
28pub struct TEE_UUID {
29    pub timeLow: u32,
30    pub timeMid: u16,
31    pub timeHiAndVersion: u16,
32    pub clockSeqAndNode: [u8; 8],
33}
34
35#[derive(Copy, Clone)]
36#[repr(C)]
37pub struct TEE_Identity {
38    pub login: u32,
39    pub uuid: TEE_UUID,
40}
41
42#[derive(Copy, Clone)]
43#[repr(C)]
44pub struct Memref {
45    pub buffer: *mut c_void,
46    pub size: usize,
47}
48
49#[derive(Copy, Clone)]
50#[repr(C)]
51pub struct Value {
52    pub a: u32,
53    pub b: u32,
54}
55
56#[derive(Copy, Clone)]
57#[repr(C)]
58pub union TEE_Param {
59    pub memref: Memref,
60    pub value: Value,
61}
62
63#[repr(C)]
64pub struct __TEE_TASessionHandle {
65    _unused: [u8; 0],
66}
67#[allow(non_camel_case_types)]
68pub type TEE_TASessionHandle = *mut __TEE_TASessionHandle;
69
70#[repr(C)]
71pub struct __TEE_PropSetHandle {
72    _unused: [u8; 0],
73}
74#[allow(non_camel_case_types)]
75pub type TEE_PropSetHandle = *mut __TEE_PropSetHandle;
76
77#[repr(C)]
78pub struct __TEE_ObjectHandle {
79    _unused: [u8; 0],
80}
81#[allow(non_camel_case_types)]
82pub type TEE_ObjectHandle = *mut __TEE_ObjectHandle;
83
84#[repr(C)]
85pub struct __TEE_ObjectEnumHandle {
86    _unused: [u8; 0],
87}
88#[allow(non_camel_case_types)]
89pub type TEE_ObjectEnumHandle = *mut __TEE_ObjectEnumHandle;
90
91#[repr(C)]
92pub struct __TEE_OperationHandle {
93    _unused: [u8; 0],
94}
95#[allow(non_camel_case_types)]
96pub type TEE_OperationHandle = *mut __TEE_OperationHandle;
97
98// Storage Definitions
99
100#[allow(non_camel_case_types)]
101pub type TEE_ObjectType = u32;
102
103#[repr(C)]
104pub struct TEE_ObjectInfo {
105    pub objectType: u32,
106    pub objectSize: u32,
107    pub maxObjectSize: u32,
108    pub objectUsage: u32,
109    pub dataSize: usize,
110    pub dataPosition: usize,
111    pub handleFlags: u32,
112}
113
114// Reserve the GP 1.1.1 type
115#[repr(C)]
116pub enum TEE_Whence {
117    TEE_DATA_SEEK_SET,
118    TEE_DATA_SEEK_CUR,
119    TEE_DATA_SEEK_END,
120}
121
122#[derive(Copy, Clone)]
123#[repr(C)]
124pub union content {
125    pub memref: Memref,
126    pub value: Value,
127}
128
129#[derive(Copy, Clone)]
130#[repr(C)]
131pub struct TEE_Attribute {
132    pub attributeID: u32,
133    pub content: content,
134}
135
136// Cryptographic Operations API
137
138// Reserve the GP 1.1.1 type
139#[repr(C)]
140pub enum TEE_OperationMode {
141    TEE_MODE_ENCRYPT,
142    TEE_MODE_DECRYPT,
143    TEE_MODE_SIGN,
144    TEE_MODE_VERIFY,
145    TEE_MODE_MAC,
146    TEE_MODE_DIGEST,
147    TEE_MODE_DERIVE,
148}
149
150#[repr(C)]
151pub struct TEE_OperationInfo {
152    pub algorithm: u32,
153    pub operationClass: u32,
154    pub mode: u32,
155    pub digestLength: u32,
156    pub maxKeySize: u32,
157    pub keySize: u32,
158    pub requiredKeyUsage: u32,
159    pub handleState: u32,
160}
161
162#[repr(C)]
163pub struct TEE_OperationInfoKey {
164    pub keySize: u32,
165    pub requiredKeyUsage: u32,
166}
167
168#[repr(C)]
169pub struct TEE_OperationInfoMultiple {
170    pub algorithm: u32,
171    pub operationClass: u32,
172    pub mode: u32,
173    pub digestLength: u32,
174    pub maxKeySize: u32,
175    pub handleState: u32,
176    pub operationState: u32,
177    pub numberOfKeys: u32,
178    pub keyInformation: *mut TEE_OperationInfoKey,
179}
180
181// Time & Date API
182
183#[repr(C)]
184pub struct TEE_Time {
185    pub seconds: u32,
186    pub millis: u32,
187}
188
189// TEE Arithmetical APIs
190
191#[allow(non_camel_case_types)]
192pub type TEE_BigInt = u32;
193#[allow(non_camel_case_types)]
194pub type TEE_BigIntFMM = u32;
195#[allow(non_camel_case_types)]
196pub type TEE_BigIntFMMContext = u32;
197
198// Tee Secure Element APIs
199
200#[repr(C)]
201pub struct __TEE_SEServiceHandle {
202    _unused: [u8; 0],
203}
204#[allow(non_camel_case_types)]
205pub type TEE_SEServiceHandle = *mut __TEE_SEServiceHandle;
206#[repr(C)]
207pub struct __TEE_SEReaderHandle {
208    _unused: [u8; 0],
209}
210#[allow(non_camel_case_types)]
211pub type TEE_SEReaderHandle = *mut __TEE_SEReaderHandle;
212#[repr(C)]
213pub struct __TEE_SESessionHandle {
214    _unused: [u8; 0],
215}
216#[allow(non_camel_case_types)]
217pub type TEE_SESessionHandle = *mut __TEE_SESessionHandle;
218#[repr(C)]
219pub struct __TEE_SEChannelHandle {
220    _unused: [u8; 0],
221}
222#[allow(non_camel_case_types)]
223pub type TEE_SEChannelHandle = *mut __TEE_SEChannelHandle;
224
225#[repr(C)]
226pub struct TEE_SEReaderProperties {
227    pub sePresent: bool,
228    pub teeOnly: bool,
229    pub selectResponseEnable: bool,
230}
231
232#[repr(C)]
233pub struct TEE_SEAID {
234    pub buffer: *mut u8,
235    pub bufferLen: size_t,
236}
237
238// Other definitions
239#[allow(non_camel_case_types)]
240pub type TEE_ErrorOrigin = u32;
241#[allow(non_camel_case_types)]
242pub type TEE_Session = *mut c_void;
243
244pub const TEE_MEM_INPUT: u32 = 0x00000001;
245pub const TEE_MEM_OUTPUT: u32 = 0x00000002;
246pub const TEE_MEMREF_0_USED: u32 = 0x00000001;
247pub const TEE_MEMREF_1_USED: u32 = 0x00000002;
248pub const TEE_MEMREF_2_USED: u32 = 0x00000004;
249pub const TEE_MEMREF_3_USED: u32 = 0x00000008;
250pub const TEE_SE_READER_NAME_MAX: u32 = 20;