You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@teaclave.apache.org by "DemesneGH (via GitHub)" <gi...@apache.org> on 2025/05/20 13:05:40 UTC
[PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
DemesneGH opened a new pull request, #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190
This PR introduces support for accessing TEE properties, as specified in the GlobalPlatform TEE Internal Core API Specification v1.3.1 (https://globalplatform.org/wp-content/uploads/2021/03/GPD_TEE_Internal_Core_API_Specification_v1.3.1_PublicRelease_CC.pdf):
- [4.4] Property Access Functions
- [4.5] Trusted Application Configuration Properties
- [4.6] Client Properties
- [4.7] Implementation Properties
Each property defined in Sections 4.5–4.7 of the spec has a corresponding definition in `property.rs`.
These properties enable a variety of use cases. For example, they enable retrieving metadata such as the TA description, allow a TA to determine the caller's origin (whether it was invoked by a CA or another TA), and retrieve the caller's UUID.
Please refer to the `property-rs` example for a demonstration of these use cases.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2099175742
##########
optee-utee/src/uuid.rs:
##########
@@ -79,6 +79,11 @@ impl Uuid {
))
}
+ /// Creates a `Uuid` from a raw `TEE_UUID` object.
+ pub fn from_raw(raw: raw::TEE_UUID) -> Uuid {
Review Comment:
Can we use a From trait instead?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2099174673
##########
examples/property-rs/ta/build.rs:
##########
@@ -0,0 +1,26 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use optee_utee_build::{Error, RustEdition, TaConfig};
+use proto;
+
+fn main() -> Result<(), Error> {
+ let config = TaConfig::new_default_with_cargo_env(proto::UUID)?
+ .ta_data_size(1 * 1024 * 1024)
+ .ta_stack_size(1 * 1024 * 1024);
Review Comment:
Can we remove these? Default settings should be OK?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#issuecomment-2899822182
`Reviewed-by: Zehui Chen <iv...@apache.org>` 😀
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2101475130
##########
optee-utee/src/property.rs:
##########
@@ -0,0 +1,483 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::{Error, ErrorKind, Result};
+use crate::{Identity, Uuid};
+use alloc::{ffi::CString, string::{String, ToString}, vec::Vec};
+use optee_utee_sys as raw;
+
+/// Represents a TEE property set according to the TEE Internal API.
+/// The property set is a collection of properties that can be
+/// queried from the TEE. The property set is identified by a
+/// handle, which is a pointer to a TEE_PropSetHandle structure.
+pub enum PropertySet {
+ TeeImplementation,
+ CurrentClient,
+ CurrentTa,
+}
+
+impl PropertySet {
+ fn as_raw(&self) -> raw::TEE_PropSetHandle {
+ match self {
+ PropertySet::TeeImplementation => raw::TEE_PROPSET_TEE_IMPLEMENTATION,
+ PropertySet::CurrentClient => raw::TEE_PROPSET_CURRENT_CLIENT,
+ PropertySet::CurrentTa => raw::TEE_PROPSET_CURRENT_TA,
+ }
+ }
+}
+
+/// Represents a TEE property value.
+/// The property value can be of different types, such as
+/// string, bool, u32, TEE_UUID, TEE_Identity, etc.
+/// The property value is obtained from the TEE
+/// property set using the TEE_GetPropertyAs* functions.
+pub trait PropertyValue: Sized {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self>;
+}
+
+/// Implements the PropertyValue trait for all return types:
+/// String, Bool, u32, u64, BinaryBlock, UUID, Identity.
+impl PropertyValue for String {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut out_size = 0;
+
+ // The first call is to get the size of the string
+ // So we pass a null pointer and a size of 0
+ let res = unsafe {
+ raw::TEE_GetPropertyAsString(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ core::ptr::null_mut(),
+ &mut out_size,
+ )
+ };
+ match res {
+ raw::TEE_SUCCESS => {
+ if out_size == 0 {
+ // return an empty string
+ return Ok(String::new());
+ }
+ else {
+ return Err(Error::new(ErrorKind::Generic));
+ }
+ }
+ raw::TEE_ERROR_SHORT_BUFFER => {
+ // Resize the string to the actual size
+ let mut out_buffer = vec![0; out_size as usize];
+ let res = unsafe {
+ raw::TEE_GetPropertyAsString(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ out_buffer.as_mut_ptr() as *mut core::ffi::c_char,
+ &mut out_size,
+ )
+ };
+ if res != raw::TEE_SUCCESS {
+ return Err(Error::from_raw_error(res));
+ }
+
+ // For C raw strings, the last byte is a null terminator
+ // So we need to trim it
+ Ok(String::from_utf8_lossy(&out_buffer).trim_end_matches('\0').to_string())
Review Comment:
I would suggest using `core::ffi::CStr` instead of handling the null terminator ourself.
Maybe [CStr::from_bytes_with_nul](https://doc.rust-lang.org/std/ffi/struct.CStr.html#method.from_bytes_with_nul)?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2099841440
##########
optee-utee/src/uuid.rs:
##########
@@ -79,7 +79,12 @@ impl Uuid {
))
}
- /// Crates a raw TEE client uuid object with specified parameters.
+ /// Creates a `Uuid` from a raw `TEE_UUID` object.
+ // pub fn from_raw(raw: raw::TEE_UUID) -> Uuid {
+ // Self { raw }
+ // }
Review Comment:
All above comments are resolved. BTW forgot to delete these lines, will delete in next commit for adding review tags.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "m4sterchain (via GitHub)" <gi...@apache.org>.
m4sterchain commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2099135431
##########
optee-utee/src/property.rs:
##########
@@ -0,0 +1,481 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::{Error, ErrorKind, Result};
+use crate::{Identity, Uuid};
+use alloc::{ffi::CString, string::{String, ToString}, vec::Vec};
+use optee_utee_sys as raw;
+
+/// Represents a TEE property set according to the TEE Internal API.
+/// The property set is a collection of properties that can be
+/// queried from the TEE. The property set is identified by a
+/// handle, which is a pointer to a TEE_PropSetHandle structure.
+pub enum PropertySet {
+ TeeImplementation,
+ CurrentClient,
+ CurrentTa,
+}
+
+impl PropertySet {
+ fn as_raw(&self) -> raw::TEE_PropSetHandle {
+ match self {
+ PropertySet::TeeImplementation => raw::TEE_PROPSET_TEE_IMPLEMENTATION,
+ PropertySet::CurrentClient => raw::TEE_PROPSET_CURRENT_CLIENT,
+ PropertySet::CurrentTa => raw::TEE_PROPSET_CURRENT_TA,
+ }
+ }
+}
+
+/// Represents a TEE property value.
+/// The property value can be of different types, such as
+/// string, bool, u32, TEE_UUID, TEE_Identity, etc.
+/// The property value is obtained from the TEE
+/// property set using the TEE_GetPropertyAs* functions.
+pub trait PropertyValue: Sized {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self>;
+}
+
+/// Implements the PropertyValue trait for all return types:
+/// String, Bool, u32, u64, BinaryBlock, UUID, Identity.
+impl PropertyValue for String {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut out_size = 0;
+
+ // The first call is to get the size of the string
+ // So we pass a null pointer and a size of 0
+ let res = unsafe {
+ raw::TEE_GetPropertyAsString(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ core::ptr::null_mut(),
+ &mut out_size,
+ )
+ };
+ match res {
+ raw::TEE_SUCCESS => {
+ if out_size == 0 {
+ // return an empty string
+ return Ok(String::new());
+ }
+ else {
+ return Err(Error::new(ErrorKind::Generic));
+ }
+ }
+ raw::TEE_ERROR_SHORT_BUFFER => {
+ // Resize the string to the actual size
+ let mut out_buffer = vec![0; out_size as usize];
+ let res = unsafe {
+ raw::TEE_GetPropertyAsString(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ out_buffer.as_mut_ptr() as *mut core::ffi::c_char,
+ &mut out_size,
+ )
+ };
+ if res != raw::TEE_SUCCESS {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(String::from_utf8_lossy(&out_buffer).to_string())
+ }
+ _ => {
+ return Err(Error::from_raw_error(res));
+ }
+ }
+ }
+}
+
+impl PropertyValue for bool {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut b: bool = false;
+
+ let res = unsafe { raw::TEE_GetPropertyAsBool(set, key.as_ptr() as *const core::ffi::c_char, &mut b) };
+ if res != 0 {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(b)
+ }
+}
+
+impl PropertyValue for u32 {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut value = 0;
+
+ let res = unsafe { raw::TEE_GetPropertyAsU32(set, key.as_ptr() as *const core::ffi::c_char, &mut value) };
+ if res != 0 {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(value)
+ }
+}
+
+impl PropertyValue for u64 {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut value = 0;
+
+ let res = unsafe { raw::TEE_GetPropertyAsU64(set, key.as_ptr() as *const core::ffi::c_char, &mut value) };
+ if res != 0 {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(value)
+ }
+}
+
+impl PropertyValue for Vec<u8> {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut out_size = 0;
+
+ // The first call is to get the size of the binary block
+ // So we pass a null pointer and a size of 0
+ let res = unsafe {
+ raw::TEE_GetPropertyAsBinaryBlock(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ core::ptr::null_mut(),
+ &mut out_size,
+ )
+ };
+
+ match res {
+ raw::TEE_SUCCESS => {
+ if out_size == 0 {
+ // return an empty buffer
+ return Ok(vec![]);
+ }
+ else {
+ return Err(Error::new(ErrorKind::Generic));
+ }
+ }
+ raw::TEE_ERROR_SHORT_BUFFER => {
+ let mut buf = vec![0; out_size as usize];
+
+ let res = unsafe {
+ raw::TEE_GetPropertyAsBinaryBlock(
+ set,
+ key.as_ptr() as *const core::ffi::c_char,
+ buf.as_mut_ptr() as *mut core::ffi::c_void,
+ &mut out_size,
+ )
+ };
+ if res != raw::TEE_SUCCESS {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(buf)
+ }
+ _ => {
+ return Err(Error::from_raw_error(res));
+ }
+ }
+ }
+}
+
+impl PropertyValue for Uuid {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ let mut raw_uuid = raw::TEE_UUID {
+ timeLow: 0,
+ timeMid: 0,
+ timeHiAndVersion: 0,
+ clockSeqAndNode: [0; 8],
+ };
+
+ let res =
+ unsafe { raw::TEE_GetPropertyAsUUID(set, key.as_ptr() as *const core::ffi::c_char, &mut raw_uuid) };
+ if res != 0 {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(Uuid::from_raw(raw_uuid))
+ }
+}
+
+impl PropertyValue for Identity {
+ fn from_raw(set: raw::TEE_PropSetHandle, key: CString) -> Result<Self> {
+ // Allocate a buffer for the raw identity
+ let mut raw_id = raw::TEE_Identity {
+ login: 0,
+ uuid: raw::TEE_UUID {
+ timeLow: 0,
+ timeMid: 0,
+ timeHiAndVersion: 0,
+ clockSeqAndNode: [0; 8],
+ },
+ };
+
+ let res = unsafe {
+ raw::TEE_GetPropertyAsIdentity(set, key.as_ptr() as *const core::ffi::c_char, &mut raw_id)
+ };
+ if res != 0 {
+ return Err(Error::from_raw_error(res));
+ }
+
+ Ok(Identity::from_raw(raw_id))
+ }
+}
+
+/// Represents a TEE property key.
+/// The property key is used to identify a specific property
+/// within a property set. The property key is a string that
+/// is used to query the property value from the TEE property
+/// set. The property key is defined in the TEE Internal API,
+/// such as "gpd.client.identity" or "gpd.tee.apiversion".
+pub trait PropertyKey {
+ type Output: PropertyValue;
+ fn key(&self) -> CString;
+ fn set(&self) -> PropertySet;
+
+ fn get(&self) -> Result<Self::Output> {
+ Self::Output::from_raw(self.set().as_raw(), self.key())
+ }
+}
+
+/// Macro to define a property key.
+/// This macro generates a struct that implements the
+/// PropertyKey trait.
+macro_rules! define_property_key {
+ (
+ $name:ident,
+ $set:ident,
+ $key:literal,
+ $output:ty
+ ) => {
+ pub struct $name;
+
+ impl PropertyKey for $name {
+ type Output = $output;
+
+ fn key(&self) -> CString {
+ CString::new($key).unwrap_or_default()
+ }
+
+ fn set(&self) -> PropertySet {
+ PropertySet::$set
+ }
+ }
+ };
+}
+
+// Define all existing property keys for the TEE property set.
+// The format is:
+// `define_property_key!(Name, Set, "key", OutputType);`
+// The `Set` is one of the PropertySet it belongs to.
+// The `key` is the raw property key string.
+// The `OutputType` is the type of the property value.
+//
+// To get the property value, use the `get` method.
+// Example usage:
+//
+// ``` no_run
+// use optee_utee::{PropertyKey, CurrentTaAppId};
+//
+// let my_property = CurrentTaAppId.get()?;
+// ```
+define_property_key!(CurrentTaAppId, CurrentTa, "gpd.ta.appID", Uuid);
Review Comment:
The idea here is to abstract the complexity of fetching properties under Property Sets by introducing dedicated types. The main concern is the naming convention used for these newly introduced types.
The suggested approach is to map type names directly from the corresponding property keys (or their suffixes). For example:
gpd.ta.doesNotCloseHandleOnCorruptObject → TaDoesNotCloseHandleOnCorruptObject
gpd.tee.apiversion → TeeApiVersion
gpd.ta.dataSize → TaDataSize
This naming convention allows developers to intuitively derive the type name from the GlobalPlatform documentation without needing to inspect the implementation details. It significantly improves developer experience and code readability.
##########
examples/property-rs/ta/src/main.rs:
##########
@@ -0,0 +1,91 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#![no_std]
+#![no_main]
+
+use optee_utee::{
+ ta_close_session, ta_create, ta_destroy, ta_invoke_command, ta_open_session, trace_println,
+};
+use optee_utee::{
+ CurrentClientIdentity, CurrentTaDescription, CurrentTaMultiSession, PropertyKey,
+ TeeImplementationInternalCoreVersion,
+};
+use optee_utee::{Error, ErrorKind, Parameters, Result};
+use proto::Command;
+
+#[ta_create]
+fn create() -> Result<()> {
+ trace_println!("[+] TA create");
+ Ok(())
+}
+
+#[ta_open_session]
+fn open_session(_params: &mut Parameters) -> Result<()> {
+ trace_println!("[+] TA open session");
+ Ok(())
+}
+
+#[ta_close_session]
+fn close_session() {
+ trace_println!("[+] TA close session");
+}
+
+#[ta_destroy]
+fn destroy() {
+ trace_println!("[+] TA destroy");
+}
+
+fn get_properties() -> Result<()> {
+ // check caller
+ let client_identity = CurrentClientIdentity.get()?;
+ trace_println!(
+ "[+] TA get caller identity: login: {}, uuid: {}",
+ client_identity.login_type(),
+ client_identity.uuid()
+ );
+
+ // test the other property:
+ let core_version = TeeImplementationInternalCoreVersion.get()?;
Review Comment:
- As this logic serves as test case. Can we add assertion to the return value?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "ivila (via GitHub)" <gi...@apache.org>.
ivila commented on code in PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190#discussion_r2101439876
##########
optee-utee/src/identity.rs:
##########
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::Uuid;
+use core::fmt;
+use optee_utee_sys as raw;
+
+#[derive(Copy, Clone)]
+pub struct Identity {
+ raw: raw::TEE_Identity,
+}
+
+impl Identity {
+ pub fn login_type(&self) -> LoginType {
+ match self.raw.login {
+ raw::TEE_LOGIN_PUBLIC => LoginType::Public,
+ raw::TEE_LOGIN_USER => LoginType::User,
+ raw::TEE_LOGIN_GROUP => LoginType::Group,
+ raw::TEE_LOGIN_APPLICATION => LoginType::Application,
+ raw::TEE_LOGIN_APPLICATION_USER => LoginType::ApplicationUser,
+ raw::TEE_LOGIN_APPLICATION_GROUP => LoginType::ApplicationGroup,
+ raw::TEE_LOGIN_TRUSTED_APP => LoginType::TrustedApp,
+ _ => panic!("Invalid login type"),
+ }
+ }
+
+ pub fn uuid(&self) -> Uuid {
+ Uuid::from(self.raw.uuid)
+ }
+}
+
+impl From<raw::TEE_Identity> for Identity {
+ fn from(raw: raw::TEE_Identity) -> Self {
+ Self { raw }
+ }
+}
+
+#[derive(Copy, Clone, PartialEq, Eq)]
+#[repr(u32)]
+pub enum LoginType {
+ Public = raw::TEE_LOGIN_PUBLIC,
+ User = raw::TEE_LOGIN_USER,
+ Group = raw::TEE_LOGIN_GROUP,
+ Application = raw::TEE_LOGIN_APPLICATION,
+ ApplicationUser = raw::TEE_LOGIN_APPLICATION_USER,
+ ApplicationGroup = raw::TEE_LOGIN_APPLICATION_GROUP,
+ TrustedApp = raw::TEE_LOGIN_TRUSTED_APP,
+}
+
+impl fmt::Display for LoginType {
Review Comment:
Maybe just use `strum` and derive [strum::Display](https://docs.rs/strum/latest/strum/derive.Display.html)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org
Re: [PR] optee-utee: support TEE_GetProperty APIs [incubator-teaclave-trustzone-sdk]
Posted by "DemesneGH (via GitHub)" <gi...@apache.org>.
DemesneGH merged PR #190:
URL: https://github.com/apache/incubator-teaclave-trustzone-sdk/pull/190
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@teaclave.apache.org
For additional commands, e-mail: dev-help@teaclave.apache.org