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