GenericObject

Trait GenericObject 

Source
pub trait GenericObject {
    // Required method
    unsafe fn as_raw_ref(&self) -> &TEE_ObjectHandle;

    // Provided methods
    fn info(&self) -> Result<ObjectInfo> { ... }
    fn restrict_usage(&mut self, obj_usage: UsageFlag) -> Result<()> { ... }
    fn ref_attribute(&self, id: AttributeId, buffer: &mut [u8]) -> Result<usize> { ... }
    fn value_attribute(&self, id: u32) -> Result<(u32, u32)> { ... }
}
Expand description

A generic trait for an object (transient or persistent).

Required Methods§

Source

unsafe fn as_raw_ref(&self) -> &TEE_ObjectHandle

Returns the raw handle of the object.

This returns a reference to ensure the GenericObject is not dropped, which prevents the raw pointer from being cleaned up and the handle from becoming a dangling pointer.

§Safety

Use of a raw C pointer is inherently unsafe, and the caller might modify the object through this pointer.

Provided Methods§

Source

fn info(&self) -> Result<ObjectInfo>

Return the characteristics of an object.

§Errors

For PersistentObject:

  • CorruptObject: If the persistent object is corrupt. The object handle SHALL behave based on the gpd.ta.doesNotCloseHandleOnCorruptObject property.
  • StorageNotAvailable: If the persistent object is stored in a storage area which is currently inaccessible.
§Panics
  • If object is not a valid opened object handle.
  • If the implementation detects any other error associated with this function that is not explicitly associated with a defined return code for this function.
Source

fn restrict_usage(&mut self, obj_usage: UsageFlag) -> Result<()>

Restrict the object usage flags of an object handle to contain at most the flags passed in the obj_usage parameter.

§Errors

For PersistentObject:

  • CorruptObject: If the persistent object is corrupt. The object handle SHALL behave based on the gpd.ta.doesNotCloseHandleOnCorruptObject property.
  • StorageNotAvailable: If the persistent object is stored in a storage area which is currently inaccessible.
§Panics
  • If object is not a valid opened object handle.
  • If the implementation detects any other error associated with this function that is not explicitly associated with a defined return code for this function.
Source

fn ref_attribute(&self, id: AttributeId, buffer: &mut [u8]) -> Result<usize>

Extract one buffer attribute from an object. The attribute is identified by the argument id.

§Errors

For all:

  • ItemNotFound: If the attribute is not found on this object.
  • SHORT_BUFFER: If buffer is NULL or too small to contain the key part.

For PersistentObject:

  • CorruptObject: If the persistent object is corrupt. The object handle SHALL behave based on the gpd.ta.doesNotCloseHandleOnCorruptObject property.
  • StorageNotAvailable: If the persistent object is stored in a storage area which is currently inaccessible.
§Panics
  • If object is not a valid opened object handle.
  • If the object is not initialized.
  • If Bit [29] of attributeID is not set to 0, so the attribute is not a buffer attribute.
  • If Bit [28] of attributeID is set to 0, denoting a protected attribute, and the object usage does not contain the TEE_USAGE_EXTRACTABLE flag.
  • If the implementation detects any other error associated with this function that is not explicitly associated with a defined return code for this function.
Source

fn value_attribute(&self, id: u32) -> Result<(u32, u32)>

Extract one value attribute from an object. The attribute is identified by the argument id.

§Errors

For all:

  • ItemNotFound: If the attribute is not found on this object.
  • SHORT_BUFFER: If buffer is NULL or too small to contain the key part.

For PersistentObject:

  • CorruptObject: If the persistent object is corrupt. The object handle SHALL behave based on the gpd.ta.doesNotCloseHandleOnCorruptObject property.
  • StorageNotAvailable: If the persistent object is stored in a storage area which is currently inaccessible.
§Panics
  • If object is not a valid opened object handle.
  • If the object is not initialized.
  • If Bit [29] of attributeID is not set to 0, so the attribute is not a buffer attribute.
  • If Bit [28] of attributeID is set to 0, denoting a protected attribute, and the object usage does not contain the TEE_USAGE_EXTRACTABLE flag.
  • If the implementation detects any other error associated with this function that is not explicitly associated with a defined return code for this function.

Implementors§