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 super::*; 19 use libc::*; 20 21 extern "C" { 22 // Property access functions 23 TEE_GetPropertyAsString( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, valueBuffer: *mut c_char, valueBufferLen: *mut u32, ) -> TEE_Result24 pub fn TEE_GetPropertyAsString( 25 propsetOrEnumerator: TEE_PropSetHandle, 26 name: *const c_char, 27 valueBuffer: *mut c_char, 28 valueBufferLen: *mut u32, 29 ) -> TEE_Result; TEE_GetPropertyAsBool( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, value: *mut bool, ) -> TEE_Result30 pub fn TEE_GetPropertyAsBool( 31 propsetOrEnumerator: TEE_PropSetHandle, 32 name: *const c_char, 33 value: *mut bool, 34 ) -> TEE_Result; TEE_GetPropertyAsU32( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, value: *mut u32, ) -> TEE_Result35 pub fn TEE_GetPropertyAsU32( 36 propsetOrEnumerator: TEE_PropSetHandle, 37 name: *const c_char, 38 value: *mut u32, 39 ) -> TEE_Result; TEE_GetPropertyAsBinaryBlock( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, valueBuffer: *mut c_void, valueBufferLen: *mut u32, ) -> TEE_Result40 pub fn TEE_GetPropertyAsBinaryBlock( 41 propsetOrEnumerator: TEE_PropSetHandle, 42 name: *const c_char, 43 valueBuffer: *mut c_void, 44 valueBufferLen: *mut u32, 45 ) -> TEE_Result; TEE_GetPropertyAsUUID( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, value: *mut TEE_UUID, ) -> TEE_Result46 pub fn TEE_GetPropertyAsUUID( 47 propsetOrEnumerator: TEE_PropSetHandle, 48 name: *const c_char, 49 value: *mut TEE_UUID, 50 ) -> TEE_Result; TEE_GetPropertyAsIdentity( propsetOrEnumerator: TEE_PropSetHandle, name: *const c_char, value: *mut TEE_Identity, ) -> TEE_Result51 pub fn TEE_GetPropertyAsIdentity( 52 propsetOrEnumerator: TEE_PropSetHandle, 53 name: *const c_char, 54 value: *mut TEE_Identity, 55 ) -> TEE_Result; TEE_AllocatePropertyEnumerator(enumerator: *mut TEE_PropSetHandle) -> TEE_Result56 pub fn TEE_AllocatePropertyEnumerator(enumerator: *mut TEE_PropSetHandle) -> TEE_Result; TEE_FreePropertyEnumerator(enumerator: TEE_PropSetHandle)57 pub fn TEE_FreePropertyEnumerator(enumerator: TEE_PropSetHandle); TEE_StartPropertyEnumerator(enumerator: TEE_PropSetHandle, propSet: TEE_PropSetHandle)58 pub fn TEE_StartPropertyEnumerator(enumerator: TEE_PropSetHandle, propSet: TEE_PropSetHandle); TEE_ResetPropertyEnumerator(enumerator: TEE_PropSetHandle)59 pub fn TEE_ResetPropertyEnumerator(enumerator: TEE_PropSetHandle); TEE_GetPropertyName( enumerator: TEE_PropSetHandle, nameBuffer: *mut c_void, nameBufferLen: *mut u32, ) -> TEE_Result60 pub fn TEE_GetPropertyName( 61 enumerator: TEE_PropSetHandle, 62 nameBuffer: *mut c_void, 63 nameBufferLen: *mut u32, 64 ) -> TEE_Result; TEE_GetNextProperty(enumerator: TEE_PropSetHandle) -> TEE_Result65 pub fn TEE_GetNextProperty(enumerator: TEE_PropSetHandle) -> TEE_Result; 66 67 // System API - Misc 68 TEE_Panic(panicCode: TEE_Result)69 pub fn TEE_Panic(panicCode: TEE_Result); 70 71 // System API - Internal Client API 72 TEE_OpenTASession( destination: *const TEE_UUID, cancellationRequestTimeout: u32, paramTypes: u32, params: *mut TEE_Param, session: *mut TEE_TASessionHandle, returnOrigin: *mut u32, ) -> TEE_Result73 pub fn TEE_OpenTASession( 74 destination: *const TEE_UUID, 75 cancellationRequestTimeout: u32, 76 paramTypes: u32, 77 params: *mut TEE_Param, 78 session: *mut TEE_TASessionHandle, 79 returnOrigin: *mut u32, 80 ) -> TEE_Result; TEE_CloseTASession(session: TEE_TASessionHandle)81 pub fn TEE_CloseTASession(session: TEE_TASessionHandle); TEE_InvokeTACommand( session: TEE_TASessionHandle, cancellationRequestTimeout: u32, commandID: u32, paramTypes: u32, params: *mut TEE_Param, returnOrigin: *mut u32, ) -> TEE_Result82 pub fn TEE_InvokeTACommand( 83 session: TEE_TASessionHandle, 84 cancellationRequestTimeout: u32, 85 commandID: u32, 86 paramTypes: u32, 87 params: *mut TEE_Param, 88 returnOrigin: *mut u32, 89 ) -> TEE_Result; 90 91 // System API - Cancellations 92 TEE_GetCancellationFlag() -> bool93 pub fn TEE_GetCancellationFlag() -> bool; TEE_UnmaskCancellation() -> bool94 pub fn TEE_UnmaskCancellation() -> bool; TEE_MaskCancellation() -> bool95 pub fn TEE_MaskCancellation() -> bool; 96 97 // System API - Memory Management 98 TEE_CheckMemoryAccessRights( accessFlags: u32, buffer: *mut c_void, size: u32, ) -> TEE_Result99 pub fn TEE_CheckMemoryAccessRights( 100 accessFlags: u32, 101 buffer: *mut c_void, 102 size: u32, 103 ) -> TEE_Result; TEE_SetInstanceData(instanceData: *const c_void)104 pub fn TEE_SetInstanceData(instanceData: *const c_void); TEE_GetInstanceData() -> *const c_void105 pub fn TEE_GetInstanceData() -> *const c_void; TEE_Malloc(size: u32, hint: u32) -> *mut c_void106 pub fn TEE_Malloc(size: u32, hint: u32) -> *mut c_void; TEE_Realloc(buffer: *mut c_void, newSize: u32) -> *mut c_void107 pub fn TEE_Realloc(buffer: *mut c_void, newSize: u32) -> *mut c_void; TEE_Free(buffer: *mut c_void)108 pub fn TEE_Free(buffer: *mut c_void); TEE_MemMove(dest: *mut c_void, src: *const c_void, size: u32) -> *mut c_void109 pub fn TEE_MemMove(dest: *mut c_void, src: *const c_void, size: u32) -> *mut c_void; TEE_MemCompare( buffer1: *const c_void, buffer2: *const c_void, size: u32, ) -> i32110 pub fn TEE_MemCompare( 111 buffer1: *const c_void, 112 buffer2: *const c_void, 113 size: u32, 114 ) -> i32; TEE_MemFill(buff: *mut c_void, x: u32, size: u32) -> *mut c_void115 pub fn TEE_MemFill(buff: *mut c_void, x: u32, size: u32) -> *mut c_void; 116 117 // Data and Key Storage API - Generic Object Functions 118 TEE_GetObjectInfo(object: TEE_ObjectHandle, objectInfo: *mut TEE_ObjectInfo)119 pub fn TEE_GetObjectInfo(object: TEE_ObjectHandle, objectInfo: *mut TEE_ObjectInfo); TEE_GetObjectInfo1( object: TEE_ObjectHandle, objectInfo: *mut TEE_ObjectInfo, ) -> TEE_Result120 pub fn TEE_GetObjectInfo1( 121 object: TEE_ObjectHandle, 122 objectInfo: *mut TEE_ObjectInfo, 123 ) -> TEE_Result; TEE_RestrictObjectUsage(object: TEE_ObjectHandle, objectUsage: u32)124 pub fn TEE_RestrictObjectUsage(object: TEE_ObjectHandle, objectUsage: u32); TEE_RestrictObjectUsage1(object: TEE_ObjectHandle, objectUsage: u32) -> TEE_Result125 pub fn TEE_RestrictObjectUsage1(object: TEE_ObjectHandle, objectUsage: u32) -> TEE_Result; TEE_GetObjectBufferAttribute( object: TEE_ObjectHandle, attributeID: u32, buffer: *mut c_void, size: *mut u32, ) -> TEE_Result126 pub fn TEE_GetObjectBufferAttribute( 127 object: TEE_ObjectHandle, 128 attributeID: u32, 129 buffer: *mut c_void, 130 size: *mut u32, 131 ) -> TEE_Result; TEE_GetObjectValueAttribute( object: TEE_ObjectHandle, attributeID: u32, a: *mut u32, b: *mut u32, ) -> TEE_Result132 pub fn TEE_GetObjectValueAttribute( 133 object: TEE_ObjectHandle, 134 attributeID: u32, 135 a: *mut u32, 136 b: *mut u32, 137 ) -> TEE_Result; TEE_CloseObject(object: TEE_ObjectHandle)138 pub fn TEE_CloseObject(object: TEE_ObjectHandle); 139 140 /* Data and Key Storage API - Transient Object Functions */ 141 TEE_AllocateTransientObject( objectType: TEE_ObjectType, maxKeySize: u32, object: *mut TEE_ObjectHandle, ) -> TEE_Result142 pub fn TEE_AllocateTransientObject( 143 objectType: TEE_ObjectType, 144 maxKeySize: u32, 145 object: *mut TEE_ObjectHandle, 146 ) -> TEE_Result; TEE_FreeTransientObject(object: TEE_ObjectHandle) -> c_void147 pub fn TEE_FreeTransientObject(object: TEE_ObjectHandle) -> c_void; TEE_ResetTransientObject(object: TEE_ObjectHandle) -> c_void148 pub fn TEE_ResetTransientObject(object: TEE_ObjectHandle) -> c_void; TEE_PopulateTransientObject( object: TEE_ObjectHandle, attrs: *const TEE_Attribute, attrCount: u32, ) -> TEE_Result149 pub fn TEE_PopulateTransientObject( 150 object: TEE_ObjectHandle, 151 attrs: *const TEE_Attribute, 152 attrCount: u32, 153 ) -> TEE_Result; TEE_InitRefAttribute( attr: *mut TEE_Attribute, attributeID: u32, buffer: *const c_void, length: u32, ) -> c_void154 pub fn TEE_InitRefAttribute( 155 attr: *mut TEE_Attribute, 156 attributeID: u32, 157 buffer: *const c_void, 158 length: u32, 159 ) -> c_void; TEE_InitValueAttribute( attr: *mut TEE_Attribute, attributeID: u32, a: u32, b: u32, ) -> c_void160 pub fn TEE_InitValueAttribute( 161 attr: *mut TEE_Attribute, 162 attributeID: u32, 163 a: u32, 164 b: u32, 165 ) -> c_void; TEE_CopyObjectAttributes( destObject: TEE_ObjectHandle, srcObject: TEE_ObjectHandle, ) -> c_void166 pub fn TEE_CopyObjectAttributes( 167 destObject: TEE_ObjectHandle, 168 srcObject: TEE_ObjectHandle, 169 ) -> c_void; TEE_CopyObjectAttributes1( destObject: TEE_ObjectHandle, srcObject: TEE_ObjectHandle, ) -> TEE_Result170 pub fn TEE_CopyObjectAttributes1( 171 destObject: TEE_ObjectHandle, 172 srcObject: TEE_ObjectHandle, 173 ) -> TEE_Result; TEE_GenerateKey( object: TEE_ObjectHandle, keySize: u32, params: *const TEE_Attribute, paramCount: u32, ) -> TEE_Result174 pub fn TEE_GenerateKey( 175 object: TEE_ObjectHandle, 176 keySize: u32, 177 params: *const TEE_Attribute, 178 paramCount: u32, 179 ) -> TEE_Result; 180 181 // Data and Key Storage API - Persistent Object Functions 182 TEE_OpenPersistentObject( storageID: u32, objectID: *const c_void, objectIDLen: u32, flags: u32, object: *mut TEE_ObjectHandle, ) -> TEE_Result183 pub fn TEE_OpenPersistentObject( 184 storageID: u32, 185 objectID: *const c_void, 186 objectIDLen: u32, 187 flags: u32, 188 object: *mut TEE_ObjectHandle, 189 ) -> TEE_Result; TEE_CreatePersistentObject( storageID: u32, objectID: *const c_void, objectIDLen: u32, flags: u32, attributes: TEE_ObjectHandle, initialData: *const c_void, initialDataLen: u32, object: *mut TEE_ObjectHandle, ) -> TEE_Result190 pub fn TEE_CreatePersistentObject( 191 storageID: u32, 192 objectID: *const c_void, 193 objectIDLen: u32, 194 flags: u32, 195 attributes: TEE_ObjectHandle, 196 initialData: *const c_void, 197 initialDataLen: u32, 198 object: *mut TEE_ObjectHandle, 199 ) -> TEE_Result; TEE_CloseAndDeletePersistentObject(object: TEE_ObjectHandle)200 pub fn TEE_CloseAndDeletePersistentObject(object: TEE_ObjectHandle); TEE_CloseAndDeletePersistentObject1(object: TEE_ObjectHandle) -> TEE_Result201 pub fn TEE_CloseAndDeletePersistentObject1(object: TEE_ObjectHandle) -> TEE_Result; TEE_RenamePersistentObject( object: TEE_ObjectHandle, newObjectID: *const c_void, newObjectIDLen: u32, ) -> TEE_Result202 pub fn TEE_RenamePersistentObject( 203 object: TEE_ObjectHandle, 204 newObjectID: *const c_void, 205 newObjectIDLen: u32, 206 ) -> TEE_Result; TEE_AllocatePersistentObjectEnumerator( objectEnumerator: *mut TEE_ObjectEnumHandle, ) -> TEE_Result207 pub fn TEE_AllocatePersistentObjectEnumerator( 208 objectEnumerator: *mut TEE_ObjectEnumHandle, 209 ) -> TEE_Result; TEE_FreePersistentObjectEnumerator(objectEnumerator: TEE_ObjectEnumHandle)210 pub fn TEE_FreePersistentObjectEnumerator(objectEnumerator: TEE_ObjectEnumHandle); TEE_ResetPersistentObjectEnumerator(objectEnumerator: TEE_ObjectEnumHandle)211 pub fn TEE_ResetPersistentObjectEnumerator(objectEnumerator: TEE_ObjectEnumHandle); TEE_StartPersistentObjectEnumerator( objectEnumerator: TEE_ObjectEnumHandle, storageID: u32, ) -> TEE_Result212 pub fn TEE_StartPersistentObjectEnumerator( 213 objectEnumerator: TEE_ObjectEnumHandle, 214 storageID: u32, 215 ) -> TEE_Result; TEE_GetNextPersistentObject( objectEnumerator: TEE_ObjectEnumHandle, objectInfo: *mut TEE_ObjectInfo, objectID: *mut c_void, objectIDLen: *mut u32, ) -> TEE_Result216 pub fn TEE_GetNextPersistentObject( 217 objectEnumerator: TEE_ObjectEnumHandle, 218 objectInfo: *mut TEE_ObjectInfo, 219 objectID: *mut c_void, 220 objectIDLen: *mut u32, 221 ) -> TEE_Result; 222 223 // Data and Key Storage API - Data Stream Access Functions 224 TEE_ReadObjectData( object: TEE_ObjectHandle, buffer: *mut c_void, fsize: u32, count: *mut u32, ) -> TEE_Result225 pub fn TEE_ReadObjectData( 226 object: TEE_ObjectHandle, 227 buffer: *mut c_void, 228 fsize: u32, 229 count: *mut u32, 230 ) -> TEE_Result; TEE_WriteObjectData( object: TEE_ObjectHandle, buffer: *const c_void, fsize: u32, ) -> TEE_Result231 pub fn TEE_WriteObjectData( 232 object: TEE_ObjectHandle, 233 buffer: *const c_void, 234 fsize: u32, 235 ) -> TEE_Result; TEE_TruncateObjectData(object: TEE_ObjectHandle, size: u32) -> TEE_Result236 pub fn TEE_TruncateObjectData(object: TEE_ObjectHandle, size: u32) -> TEE_Result; TEE_SeekObjectData( object: TEE_ObjectHandle, offset: i32, whence: TEE_Whence, ) -> TEE_Result237 pub fn TEE_SeekObjectData( 238 object: TEE_ObjectHandle, 239 offset: i32, 240 whence: TEE_Whence, 241 ) -> TEE_Result; 242 243 // Cryptographic Operations API - Generic Operation Functions 244 TEE_AllocateOperation( operation: *mut TEE_OperationHandle, algorithm: u32, mode: u32, maxKeySize: u32, ) -> TEE_Result245 pub fn TEE_AllocateOperation( 246 operation: *mut TEE_OperationHandle, 247 algorithm: u32, 248 mode: u32, 249 maxKeySize: u32, 250 ) -> TEE_Result; TEE_FreeOperation(operation: TEE_OperationHandle) -> c_void251 pub fn TEE_FreeOperation(operation: TEE_OperationHandle) -> c_void; TEE_GetOperationInfo( operation: TEE_OperationHandle, operationInfo: *mut TEE_OperationInfo, ) -> c_void252 pub fn TEE_GetOperationInfo( 253 operation: TEE_OperationHandle, 254 operationInfo: *mut TEE_OperationInfo, 255 ) -> c_void; TEE_GetOperationInfoMultiple( operation: TEE_OperationHandle, operationInfoMultiple: *mut TEE_OperationInfoMultiple, operationSize: *mut u32, ) -> TEE_Result256 pub fn TEE_GetOperationInfoMultiple( 257 operation: TEE_OperationHandle, 258 operationInfoMultiple: *mut TEE_OperationInfoMultiple, 259 operationSize: *mut u32, 260 ) -> TEE_Result; TEE_ResetOperation(operation: TEE_OperationHandle) -> c_void261 pub fn TEE_ResetOperation(operation: TEE_OperationHandle) -> c_void; TEE_SetOperationKey(operation: TEE_OperationHandle, key: TEE_ObjectHandle) -> TEE_Result262 pub fn TEE_SetOperationKey(operation: TEE_OperationHandle, key: TEE_ObjectHandle) 263 -> TEE_Result; TEE_SetOperationKey2( operation: TEE_OperationHandle, key1: TEE_ObjectHandle, key2: TEE_ObjectHandle, ) -> TEE_Result264 pub fn TEE_SetOperationKey2( 265 operation: TEE_OperationHandle, 266 key1: TEE_ObjectHandle, 267 key2: TEE_ObjectHandle, 268 ) -> TEE_Result; TEE_CopyOperation( dstOperation: TEE_OperationHandle, srcOperation: TEE_OperationHandle, ) -> c_void269 pub fn TEE_CopyOperation( 270 dstOperation: TEE_OperationHandle, 271 srcOperation: TEE_OperationHandle, 272 ) -> c_void; TEE_IsAlgorithmSupported( algId: u32, element: u32, ) -> TEE_Result273 pub fn TEE_IsAlgorithmSupported( 274 algId: u32, 275 element: u32, 276 ) -> TEE_Result; 277 278 // Cryptographic Operations API - Message Digest Functions 279 TEE_DigestUpdate( operation: TEE_OperationHandle, chunk: *const c_void, chunkSize: u32, ) -> c_void280 pub fn TEE_DigestUpdate( 281 operation: TEE_OperationHandle, 282 chunk: *const c_void, 283 chunkSize: u32, 284 ) -> c_void; TEE_DigestDoFinal( operation: TEE_OperationHandle, chunk: *const c_void, chunkLen: u32, hash: *mut c_void, hashLen: *mut u32, ) -> TEE_Result285 pub fn TEE_DigestDoFinal( 286 operation: TEE_OperationHandle, 287 chunk: *const c_void, 288 chunkLen: u32, 289 hash: *mut c_void, 290 hashLen: *mut u32, 291 ) -> TEE_Result; 292 293 // Cryptographic Operations API - Symmetric Cipher Functions 294 TEE_CipherInit( operation: TEE_OperationHandle, IV: *const c_void, IVLen: u32, ) -> c_void295 pub fn TEE_CipherInit( 296 operation: TEE_OperationHandle, 297 IV: *const c_void, 298 IVLen: u32, 299 ) -> c_void; TEE_CipherUpdate( operation: TEE_OperationHandle, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, ) -> TEE_Result300 pub fn TEE_CipherUpdate( 301 operation: TEE_OperationHandle, 302 srcData: *const c_void, 303 srcLen: u32, 304 destData: *mut c_void, 305 destLen: *mut u32, 306 ) -> TEE_Result; TEE_CipherDoFinal( operation: TEE_OperationHandle, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, ) -> TEE_Result307 pub fn TEE_CipherDoFinal( 308 operation: TEE_OperationHandle, 309 srcData: *const c_void, 310 srcLen: u32, 311 destData: *mut c_void, 312 destLen: *mut u32, 313 ) -> TEE_Result; 314 315 // Cryptographic Operations API - MAC Functions 316 TEE_MACInit( operation: TEE_OperationHandle, IV: *const c_void, IVLen: u32, ) -> c_void317 pub fn TEE_MACInit( 318 operation: TEE_OperationHandle, 319 IV: *const c_void, 320 IVLen: u32, 321 ) -> c_void; TEE_MACUpdate( operation: TEE_OperationHandle, chunk: *const c_void, chunkSize: u32, ) -> c_void322 pub fn TEE_MACUpdate( 323 operation: TEE_OperationHandle, 324 chunk: *const c_void, 325 chunkSize: u32, 326 ) -> c_void; TEE_MACComputeFinal( operation: TEE_OperationHandle, message: *const c_void, messageLen: u32, mac: *mut c_void, macLen: *mut u32, ) -> TEE_Result327 pub fn TEE_MACComputeFinal( 328 operation: TEE_OperationHandle, 329 message: *const c_void, 330 messageLen: u32, 331 mac: *mut c_void, 332 macLen: *mut u32, 333 ) -> TEE_Result; TEE_MACCompareFinal( operation: TEE_OperationHandle, message: *const c_void, messageLen: u32, mac: *const c_void, macLen: u32, ) -> TEE_Result334 pub fn TEE_MACCompareFinal( 335 operation: TEE_OperationHandle, 336 message: *const c_void, 337 messageLen: u32, 338 mac: *const c_void, 339 macLen: u32, 340 ) -> TEE_Result; 341 342 // Cryptographic Operations API - Authenticated Encryption Functions 343 TEE_AEInit( operation: TEE_OperationHandle, nonce: *const c_void, nonceLen: u32, tagLen: u32, AADLen: u32, payloadLen: u32, ) -> TEE_Result344 pub fn TEE_AEInit( 345 operation: TEE_OperationHandle, 346 nonce: *const c_void, 347 nonceLen: u32, 348 tagLen: u32, 349 AADLen: u32, 350 payloadLen: u32, 351 ) -> TEE_Result; TEE_AEUpdateAAD( operation: TEE_OperationHandle, AADdata: *const c_void, AADdataLen: u32, ) -> c_void352 pub fn TEE_AEUpdateAAD( 353 operation: TEE_OperationHandle, 354 AADdata: *const c_void, 355 AADdataLen: u32, 356 ) -> c_void; TEE_AEUpdate( operation: TEE_OperationHandle, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, ) -> TEE_Result357 pub fn TEE_AEUpdate( 358 operation: TEE_OperationHandle, 359 srcData: *const c_void, 360 srcLen: u32, 361 destData: *mut c_void, 362 destLen: *mut u32, 363 ) -> TEE_Result; TEE_AEEncryptFinal( operation: TEE_OperationHandle, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, tag: *mut c_void, tagLen: *mut u32, ) -> TEE_Result364 pub fn TEE_AEEncryptFinal( 365 operation: TEE_OperationHandle, 366 srcData: *const c_void, 367 srcLen: u32, 368 destData: *mut c_void, 369 destLen: *mut u32, 370 tag: *mut c_void, 371 tagLen: *mut u32, 372 ) -> TEE_Result; TEE_AEDecryptFinal( operation: TEE_OperationHandle, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, tag: *mut c_void, tagLen: u32, ) -> TEE_Result373 pub fn TEE_AEDecryptFinal( 374 operation: TEE_OperationHandle, 375 srcData: *const c_void, 376 srcLen: u32, 377 destData: *mut c_void, 378 destLen: *mut u32, 379 tag: *mut c_void, 380 tagLen: u32, 381 ) -> TEE_Result; 382 383 // Cryptographic Operations API - Asymmetric Functions 384 TEE_AsymmetricEncrypt( operation: TEE_OperationHandle, params: *const TEE_Attribute, paramCount: u32, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, ) -> TEE_Result385 pub fn TEE_AsymmetricEncrypt( 386 operation: TEE_OperationHandle, 387 params: *const TEE_Attribute, 388 paramCount: u32, 389 srcData: *const c_void, 390 srcLen: u32, 391 destData: *mut c_void, 392 destLen: *mut u32, 393 ) -> TEE_Result; TEE_AsymmetricDecrypt( operation: TEE_OperationHandle, params: *const TEE_Attribute, paramCount: u32, srcData: *const c_void, srcLen: u32, destData: *mut c_void, destLen: *mut u32, ) -> TEE_Result394 pub fn TEE_AsymmetricDecrypt( 395 operation: TEE_OperationHandle, 396 params: *const TEE_Attribute, 397 paramCount: u32, 398 srcData: *const c_void, 399 srcLen: u32, 400 destData: *mut c_void, 401 destLen: *mut u32, 402 ) -> TEE_Result; TEE_AsymmetricSignDigest( operation: TEE_OperationHandle, params: *const TEE_Attribute, paramCount: u32, digest: *const c_void, digestLen: u32, signature: *mut c_void, signatureLen: *mut u32, ) -> TEE_Result403 pub fn TEE_AsymmetricSignDigest( 404 operation: TEE_OperationHandle, 405 params: *const TEE_Attribute, 406 paramCount: u32, 407 digest: *const c_void, 408 digestLen: u32, 409 signature: *mut c_void, 410 signatureLen: *mut u32, 411 ) -> TEE_Result; TEE_AsymmetricVerifyDigest( operation: TEE_OperationHandle, params: *const TEE_Attribute, paramCount: u32, digest: *const c_void, digestLen: u32, signature: *const c_void, signatureLen: u32, ) -> TEE_Result412 pub fn TEE_AsymmetricVerifyDigest( 413 operation: TEE_OperationHandle, 414 params: *const TEE_Attribute, 415 paramCount: u32, 416 digest: *const c_void, 417 digestLen: u32, 418 signature: *const c_void, 419 signatureLen: u32, 420 ) -> TEE_Result; 421 422 // Cryptographic Operations API - Key Derivation Functions 423 TEE_DeriveKey( operation: TEE_OperationHandle, params: *const TEE_Attribute, paramCount: u32, derivedKey: TEE_ObjectHandle, ) -> c_void424 pub fn TEE_DeriveKey( 425 operation: TEE_OperationHandle, 426 params: *const TEE_Attribute, 427 paramCount: u32, 428 derivedKey: TEE_ObjectHandle, 429 ) -> c_void; 430 431 // Cryptographic Operations API - Random Number Generation Functions 432 TEE_GenerateRandom(randomBuffer: *mut c_void, randomBufferLen: u32) -> c_void433 pub fn TEE_GenerateRandom(randomBuffer: *mut c_void, randomBufferLen: u32) -> c_void; 434 435 // Date & Time API 436 TEE_GetSystemTime(time: *mut TEE_Time) -> c_void437 pub fn TEE_GetSystemTime(time: *mut TEE_Time) -> c_void; TEE_Wait(timeout: u32) -> TEE_Result438 pub fn TEE_Wait(timeout: u32) -> TEE_Result; TEE_GetTAPersistentTime(time: *mut TEE_Time) -> TEE_Result439 pub fn TEE_GetTAPersistentTime(time: *mut TEE_Time) -> TEE_Result; TEE_SetTAPersistentTime(time: *const TEE_Time) -> TEE_Result440 pub fn TEE_SetTAPersistentTime(time: *const TEE_Time) -> TEE_Result; TEE_GetREETime(time: *mut TEE_Time) -> c_void441 pub fn TEE_GetREETime(time: *mut TEE_Time) -> c_void; 442 443 // TEE Arithmetical API - Memory allocation and size of objects 444 TEE_BigIntFMMSizeInU32(modulusSizeInBits: u32) -> u32445 pub fn TEE_BigIntFMMSizeInU32(modulusSizeInBits: u32) -> u32; TEE_BigIntFMMContextSizeInU32(modulusSizeInBits: u32) -> u32446 pub fn TEE_BigIntFMMContextSizeInU32(modulusSizeInBits: u32) -> u32; 447 448 // TEE Arithmetical API - Initialization functions 449 TEE_BigIntInit(bigInt: *mut TEE_BigInt, len: u32) -> c_void450 pub fn TEE_BigIntInit(bigInt: *mut TEE_BigInt, len: u32) -> c_void; TEE_BigIntInitFMMContext( context: *mut TEE_BigIntFMMContext, len: u32, modulus: *const TEE_BigInt, ) -> c_void451 pub fn TEE_BigIntInitFMMContext( 452 context: *mut TEE_BigIntFMMContext, 453 len: u32, 454 modulus: *const TEE_BigInt, 455 ) -> c_void; TEE_BigIntInitFMM(bigIntFMM: *mut TEE_BigIntFMM, len: u32) -> c_void456 pub fn TEE_BigIntInitFMM(bigIntFMM: *mut TEE_BigIntFMM, len: u32) -> c_void; 457 458 // TEE Arithmetical API - Converter functions 459 TEE_BigIntConvertFromOctetString( dest: *mut TEE_BigInt, buffer: *const u8, bufferLen: u32, sign: i32, ) -> TEE_Result460 pub fn TEE_BigIntConvertFromOctetString( 461 dest: *mut TEE_BigInt, 462 buffer: *const u8, 463 bufferLen: u32, 464 sign: i32, 465 ) -> TEE_Result; TEE_BigIntConvertToOctetString( buffer: *mut u8, bufferLen: *mut u32, bigInt: *const TEE_BigInt, ) -> TEE_Result466 pub fn TEE_BigIntConvertToOctetString( 467 buffer: *mut u8, 468 bufferLen: *mut u32, 469 bigInt: *const TEE_BigInt, 470 ) -> TEE_Result; TEE_BigIntConvertFromS32(dest: *mut TEE_BigInt, shortVal: i32) -> c_void471 pub fn TEE_BigIntConvertFromS32(dest: *mut TEE_BigInt, shortVal: i32) -> c_void; TEE_BigIntConvertToS32(dest: *mut i32, src: *const TEE_BigInt) -> TEE_Result472 pub fn TEE_BigIntConvertToS32(dest: *mut i32, src: *const TEE_BigInt) -> TEE_Result; 473 474 // TEE Arithmetical API - Logical operations 475 TEE_BigIntCmp(op1: *const TEE_BigInt, op2: *const TEE_BigInt) -> i32476 pub fn TEE_BigIntCmp(op1: *const TEE_BigInt, op2: *const TEE_BigInt) -> i32; TEE_BigIntCmpS32(op: *const TEE_BigInt, shortVal: i32) -> i32477 pub fn TEE_BigIntCmpS32(op: *const TEE_BigInt, shortVal: i32) -> i32; TEE_BigIntShiftRight( dest: *mut TEE_BigInt, op: *const TEE_BigInt, bits: size_t, ) -> c_void478 pub fn TEE_BigIntShiftRight( 479 dest: *mut TEE_BigInt, 480 op: *const TEE_BigInt, 481 bits: size_t, 482 ) -> c_void; TEE_BigIntGetBit(src: *const TEE_BigInt, bitIndex: u32) -> bool483 pub fn TEE_BigIntGetBit(src: *const TEE_BigInt, bitIndex: u32) -> bool; TEE_BigIntGetBitCount(src: *const TEE_BigInt) -> u32484 pub fn TEE_BigIntGetBitCount(src: *const TEE_BigInt) -> u32; TEE_BigIntAdd( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, ) -> c_void485 pub fn TEE_BigIntAdd( 486 dest: *mut TEE_BigInt, 487 op1: *const TEE_BigInt, 488 op2: *const TEE_BigInt, 489 ) -> c_void; TEE_BigIntSub( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, ) -> c_void490 pub fn TEE_BigIntSub( 491 dest: *mut TEE_BigInt, 492 op1: *const TEE_BigInt, 493 op2: *const TEE_BigInt, 494 ) -> c_void; TEE_BigIntNeg(dest: *mut TEE_BigInt, op: *const TEE_BigInt) -> c_void495 pub fn TEE_BigIntNeg(dest: *mut TEE_BigInt, op: *const TEE_BigInt) -> c_void; TEE_BigIntMul( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, ) -> c_void496 pub fn TEE_BigIntMul( 497 dest: *mut TEE_BigInt, 498 op1: *const TEE_BigInt, 499 op2: *const TEE_BigInt, 500 ) -> c_void; TEE_BigIntSquare(dest: *mut TEE_BigInt, op: *const TEE_BigInt) -> c_void501 pub fn TEE_BigIntSquare(dest: *mut TEE_BigInt, op: *const TEE_BigInt) -> c_void; TEE_BigIntDiv( dest_q: *mut TEE_BigInt, dest_r: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, ) -> c_void502 pub fn TEE_BigIntDiv( 503 dest_q: *mut TEE_BigInt, 504 dest_r: *mut TEE_BigInt, 505 op1: *const TEE_BigInt, 506 op2: *const TEE_BigInt, 507 ) -> c_void; 508 509 // TEE Arithmetical API - Modular arithmetic operations 510 TEE_BigIntMod( dest: *mut TEE_BigInt, op: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void511 pub fn TEE_BigIntMod( 512 dest: *mut TEE_BigInt, 513 op: *const TEE_BigInt, 514 n: *const TEE_BigInt, 515 ) -> c_void; TEE_BigIntAddMod( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void516 pub fn TEE_BigIntAddMod( 517 dest: *mut TEE_BigInt, 518 op1: *const TEE_BigInt, 519 op2: *const TEE_BigInt, 520 n: *const TEE_BigInt, 521 ) -> c_void; TEE_BigIntSubMod( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void522 pub fn TEE_BigIntSubMod( 523 dest: *mut TEE_BigInt, 524 op1: *const TEE_BigInt, 525 op2: *const TEE_BigInt, 526 n: *const TEE_BigInt, 527 ) -> c_void; TEE_BigIntMulMod( dest: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void528 pub fn TEE_BigIntMulMod( 529 dest: *mut TEE_BigInt, 530 op1: *const TEE_BigInt, 531 op2: *const TEE_BigInt, 532 n: *const TEE_BigInt, 533 ) -> c_void; TEE_BigIntSquareMod( dest: *mut TEE_BigInt, op: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void534 pub fn TEE_BigIntSquareMod( 535 dest: *mut TEE_BigInt, 536 op: *const TEE_BigInt, 537 n: *const TEE_BigInt, 538 ) -> c_void; TEE_BigIntInvMod( dest: *mut TEE_BigInt, op: *const TEE_BigInt, n: *const TEE_BigInt, ) -> c_void539 pub fn TEE_BigIntInvMod( 540 dest: *mut TEE_BigInt, 541 op: *const TEE_BigInt, 542 n: *const TEE_BigInt, 543 ) -> c_void; 544 545 // TEE Arithmetical API - Other arithmetic operations 546 TEE_BigIntRelativePrime(op1: *const TEE_BigInt, op2: *const TEE_BigInt) -> bool547 pub fn TEE_BigIntRelativePrime(op1: *const TEE_BigInt, op2: *const TEE_BigInt) -> bool; TEE_BigIntComputeExtendedGcd( gcd: *mut TEE_BigInt, u: *mut TEE_BigInt, v: *mut TEE_BigInt, op1: *const TEE_BigInt, op2: *const TEE_BigInt, ) -> c_void548 pub fn TEE_BigIntComputeExtendedGcd( 549 gcd: *mut TEE_BigInt, 550 u: *mut TEE_BigInt, 551 v: *mut TEE_BigInt, 552 op1: *const TEE_BigInt, 553 op2: *const TEE_BigInt, 554 ) -> c_void; TEE_BigIntIsProbablePrime(op: *const TEE_BigInt, confidenceLevel: u32) -> i32555 pub fn TEE_BigIntIsProbablePrime(op: *const TEE_BigInt, confidenceLevel: u32) -> i32; 556 557 // TEE Arithmetical API - Fast modular multiplication operations 558 TEE_BigIntConvertToFMM( dest: *mut TEE_BigIntFMM, src: *const TEE_BigInt, n: *const TEE_BigInt, context: *const TEE_BigIntFMMContext, ) -> c_void559 pub fn TEE_BigIntConvertToFMM( 560 dest: *mut TEE_BigIntFMM, 561 src: *const TEE_BigInt, 562 n: *const TEE_BigInt, 563 context: *const TEE_BigIntFMMContext, 564 ) -> c_void; TEE_BigIntConvertFromFMM( dest: *mut TEE_BigInt, src: *const TEE_BigIntFMM, n: *const TEE_BigInt, context: *const TEE_BigIntFMMContext, ) -> c_void565 pub fn TEE_BigIntConvertFromFMM( 566 dest: *mut TEE_BigInt, 567 src: *const TEE_BigIntFMM, 568 n: *const TEE_BigInt, 569 context: *const TEE_BigIntFMMContext, 570 ) -> c_void; TEE_BigIntFMMConvertToBigInt( dest: *mut TEE_BigInt, src: *const TEE_BigIntFMM, n: *const TEE_BigInt, context: *const TEE_BigIntFMMContext, ) -> c_void571 pub fn TEE_BigIntFMMConvertToBigInt( 572 dest: *mut TEE_BigInt, 573 src: *const TEE_BigIntFMM, 574 n: *const TEE_BigInt, 575 context: *const TEE_BigIntFMMContext, 576 ) -> c_void; TEE_BigIntComputeFMM( dest: *mut TEE_BigIntFMM, op1: *const TEE_BigIntFMM, op2: *const TEE_BigIntFMM, n: *const TEE_BigInt, context: *const TEE_BigIntFMMContext, ) -> c_void577 pub fn TEE_BigIntComputeFMM( 578 dest: *mut TEE_BigIntFMM, 579 op1: *const TEE_BigIntFMM, 580 op2: *const TEE_BigIntFMM, 581 n: *const TEE_BigInt, 582 context: *const TEE_BigIntFMMContext, 583 ) -> c_void; 584 } 585