This is an automated email from the ASF dual-hosted git repository.
ivila pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/teaclave-trustzone-sdk.git
The following commit(s) were added to refs/heads/main by this push:
new b3154cb optee-teec: add bidirectional memory reference support
b3154cb is described below
commit b3154cb8a4490c38fd2b547bf5fdbc960daf3666
Author: Georges Savoundararadj <[email protected]>
AuthorDate: Sat Feb 21 13:58:51 2026 +0000
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 <[email protected]>
---
crates/optee-teec/src/parameter.rs | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/crates/optee-teec/src/parameter.rs
b/crates/optee-teec/src/parameter.rs
index 18bdd49..963fc84 100644
--- a/crates/optee-teec/src/parameter.rs
+++ b/crates/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
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]