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