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 d25b231 utee: export define_property_key and update set_key_2
d25b231 is described below
commit d25b231adf4b677eba46379e5db9ff62a8614023
Author: Matthew Shyu <[email protected]>
AuthorDate: Wed Jun 3 10:41:00 2026 +0800
utee: export define_property_key and update set_key_2
* export define_property_key to support getting TA defined properties
* set_key_2 is also needed on derive key, move the implementation to
OperationHandle
---
crates/optee-utee/src/crypto_op.rs | 29 +++++++++++++++++++++++------
crates/optee-utee/src/property.rs | 1 +
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/crates/optee-utee/src/crypto_op.rs
b/crates/optee-utee/src/crypto_op.rs
index 5276c08..7784196 100644
--- a/crates/optee-utee/src/crypto_op.rs
+++ b/crates/optee-utee/src/crypto_op.rs
@@ -223,6 +223,19 @@ impl OperationHandle {
}
}
+ fn set_key_2<T: GenericObject, D: GenericObject>(
+ &self,
+ object1: &T,
+ object2: &D,
+ ) -> Result<()> {
+ match unsafe {
+ raw::TEE_SetOperationKey2(self.handle(), *object1.as_raw_ref(),
*object2.as_raw_ref())
+ } {
+ raw::TEE_SUCCESS => Ok(()),
+ code => Err(Error::from_raw_error(code)),
+ }
+ }
+
fn copy<T: OpHandle>(&mut self, src: &T) {
unsafe {
raw::TEE_CopyOperation(self.handle(), src.handle());
@@ -748,12 +761,7 @@ impl Cipher {
object1: &T,
object2: &D,
) -> Result<()> {
- match unsafe {
- raw::TEE_SetOperationKey2(self.handle(), *object1.as_raw_ref(),
*object2.as_raw_ref())
- } {
- raw::TEE_SUCCESS => Ok(()),
- code => Err(Error::from_raw_error(code)),
- }
+ self.0.set_key_2(object1, object2)
}
/// Function usage is similar to [Digest::copy](Digest::copy).
@@ -1618,6 +1626,15 @@ impl DeriveKey {
self.0.set_key(object)
}
+ /// Function usage is similar to [Cipher::set_key_2](Cipher::set_key_2).
+ pub fn set_key_2<T: GenericObject, D: GenericObject>(
+ &self,
+ object1: &T,
+ object2: &D,
+ ) -> Result<()> {
+ self.0.set_key_2(object1, object2)
+ }
+
/// Function usage is similar to [Digest::copy](Digest::copy).
pub fn copy<T: OpHandle>(&mut self, src: &T) {
self.0.copy(src)
diff --git a/crates/optee-utee/src/property.rs
b/crates/optee-utee/src/property.rs
index f5b99bf..49153bd 100644
--- a/crates/optee-utee/src/property.rs
+++ b/crates/optee-utee/src/property.rs
@@ -252,6 +252,7 @@ pub trait PropertyKey {
/// Macro to define a property key.
/// This macro generates a struct that implements the
/// PropertyKey trait.
+#[macro_export]
macro_rules! define_property_key {
(
$name:ident,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]