From 96c67125d318645ef903d3af5d725bd6e1485eba Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Sat, 21 Feb 2026 13:58:37 +0000 Subject: [PATCH 1/2] optee-teec: remove unused optee-teec-macros dependency The optee-teec-macros crate provides plugin_init and plugin_invoke procedural macros that are not used by the optee-teec library itself. These macros were re-exported but serve no purpose in the core TEEC client API implementation. This change: - Removes the optee-teec-macros dependency from Cargo.toml - Removes the re-export of plugin_init and plugin_invoke macros from lib.rs This simplifies the dependency tree and reduces build time for users who only need the TEEC client API without the plugin macros. Signed-off-by: Georges Savoundararadj --- optee-teec/Cargo.toml | 1 - optee-teec/src/lib.rs | 1 - 2 files changed, 2 deletions(-) diff --git a/optee-teec/Cargo.toml b/optee-teec/Cargo.toml index 7b10587a..13e9aae7 100644 --- a/optee-teec/Cargo.toml +++ b/optee-teec/Cargo.toml @@ -26,7 +26,6 @@ edition = "2018" [dependencies] optee-teec-sys = { version = "0.8.0", path = "optee-teec-sys" } -optee-teec-macros = { version = "0.8.0", path = "macros" } uuid = "0.7" hex = "0.3" num_enum = { version = "0.7.3", default-features = false } diff --git a/optee-teec/src/lib.rs b/optee-teec/src/lib.rs index 5220ce15..501b1578 100644 --- a/optee-teec/src/lib.rs +++ b/optee-teec/src/lib.rs @@ -22,7 +22,6 @@ pub use self::operation::Operation; pub use self::parameter::{Param, ParamNone, ParamTmpRef, ParamType, ParamTypes, ParamValue}; pub use self::session::{ConnectionMethods, Session}; pub use self::uuid::Uuid; -pub use optee_teec_macros::{plugin_init, plugin_invoke}; // Re-export optee_teec_sys so developers don't have to add it to their cargo // dependencies. pub use optee_teec_sys as raw; From 7f69d303d49602141c4b37dff1f6fdc6c20fecb4 Mon Sep 17 00:00:00 2001 From: Georges Savoundararadj Date: Sat, 21 Feb 2026 13:58:51 +0000 Subject: [PATCH 2/2] optee-teec: add bidirectional memory reference support Add ParamTmpRef::new_inout() constructor to create temporary memory references with bidirectional data flow (input/output). The existing API only provided: - new_input(): for read-only memory references (TA can only read) - new_output(): for write-only memory references (TA can only write) This change adds: - new_inout(): for read-write memory references (TA can both read and write) This is useful for operations where the TA needs to read initial data from the buffer, process it, and write the results back to the same buffer. The new method sets the ParamType to MemrefTempInout, which corresponds to TEEC_MEMREF_TEMP_INOUT in the GlobalPlatform TEE Client API specification. Example use case: Encryption/decryption operations where plaintext is passed in and ciphertext is returned in the same buffer. Signed-off-by: Georges Savoundararadj --- optee-teec/src/parameter.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/optee-teec/src/parameter.rs b/optee-teec/src/parameter.rs index 18bdd498..963fc84f 100644 --- a/optee-teec/src/parameter.rs +++ b/optee-teec/src/parameter.rs @@ -127,6 +127,26 @@ impl<'a> ParamTmpRef<'a> { } } + /// Creates a temporary input/output memory reference. + /// + /// `buffer` is a region of memory which needs to be temporarily + /// registered for the duration of the `Operation` and can be both + /// read and written by the Trusted Application (TA). + /// + /// This is useful when you need to pass data to a TA that will + /// modify it and return the modified data in the same buffer. + pub fn new_inout(buffer: &'a mut [u8]) -> Self { + let raw = raw::TEEC_TempMemoryReference { + buffer: buffer.as_ptr() as _, + size: buffer.len(), + }; + Self { + raw, + param_type: ParamType::MemrefTempInout, + _marker: marker::PhantomData, + } + } + pub fn updated_size(&self) -> usize { self.raw.size }