amebazii::types::fst

Struct FST

Source
pub struct FST {
    pub enc_algo: Option<EncryptionAlgo>,
    pub hash_algo: Option<HashAlgo>,
    pub partition_size: u32,
    /* private fields */
}
Expand description

§Firmware Security Table (FST)

The FST struct represents the firmware security table (FST) of a sub-image within a firmware image. This table holds information about the encryption algorithm, hash algorithm, security keys, and other configuration for firmware partitions.

§Layout

         +-------+-------+--------+-------+-----------+---------------+---+---+---+---+----+----+----+----+----+----+
         | 0     | 1     | 2      | 3     | 4         | 5             | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |
+========+=======+=======+========+=======+===========+===============+===+===+===+===+====+====+====+====+====+====+
| 0x00   | enc_algo: u16 | hash_algo: u16 |          part_size: u32           |          valipat: bytes[8]          |
+--------+--------------------------------+-----------+---------------+---------------------------------------------+
| 0x10   |                                | flags: u8 | key_flags: u8 |                                             |
+--------+--------------------------------+-----------+---------------+---------------------------------------------+
| 0x20   |                                          cipher_key: bytes[32]                                           |
+--------+----------------------------------------------------------------------------------------------------------+
| 0x40   |                                           cipher_iv: bytes[16]                                           |
+--------+----------------------------------------------------------------------------------------------------------+
| 0x50   |                                                                                                          |
+--------+----------------------------------------------------------------------------------------------------------+
  • Size = 0x60 = 96 bytes

Note: Encryption and cipher-related fields are placeholders, as encryption is not currently supported. These fields are implemented as Option<T> to allow future extension if encryption support is added later.

§Example:

let mut fst = FST::default();

// set hash algorithm
fst.hash_algo = Some(HashAlgo::Sha256);

// clear encryption algorithm
fst.enc_algo = None;

Fields§

§enc_algo: Option<EncryptionAlgo>

encryption algorithm (not supported)

§hash_algo: Option<HashAlgo>

The hash algorithm used for hashing. Default is Sha256.

§partition_size: u32

Implementations§

Source§

impl FST

Source

pub fn is_cipher_key_iv_valid(&self) -> bool

Checks if the cipher key and IV are valid.

§Returns:
  • true: If both the cipher key and IV are valid.
  • false: If either the cipher key or IV is not set or invalid.
Source

pub fn get_pattern(&self) -> &[u8; 8]

Returns a reference to the validation pattern used for the FST structure.

§Returns:

A reference to the 8-byte validation pattern.

Source

pub fn get_cipher_key(&self) -> DataRefType<'_, 32>

Returns a reference to the cipher key if it is set.

§Returns:

An Option containing a reference to the 32-byte cipher key.

let fst = FST::default();
if let Some(cipher_key) = fst.get_cipher_key() {
    // Handle valid cipher key
}
Source

pub fn get_cipher_iv(&self) -> DataRefType<'_, 16>

Returns a reference to the cipher IV if it is set.

§Returns:

An Option containing a reference to the 16-byte cipher IV.

Source

pub fn set_cipher_iv(&mut self, iv: DataType<16>)

Source

pub fn set_cipher_key(&mut self, key: DataType<32>)

Source

pub fn set_valid_pattern(&mut self, pattern: [u8; 8])

Trait Implementations§

Source§

impl BinarySize for FST

Source§

fn binary_size() -> usize

Returns the binary size of the FST structure in bytes.

§Returns:

The size of the FST struct in bytes, which is 0x60 (96 bytes).

Source§

impl Debug for FST

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FST

Source§

fn default() -> FST

Returns the “default value” for a type. Read more
Source§

impl FromStream for FST

Source§

fn read_from<R>(&mut self, reader: &mut R) -> Result<(), Error>
where R: Read + Seek,

Reads the FST structure from a stream and parses its data.

§Parameters:
  • reader: A mutable reference to a reader that implements std::io::Read and std::io::Seek traits. This could be a file, buffer, or network stream.
§Returns:
  • On failure, an Error is returned.
Source§

impl ToStream for FST

Source§

fn write_to<W>(&self, writer: &mut W) -> Result<(), Error>
where W: Write,

Writes the FST structure to a stream

§Parameters:
  • writer: A mutable reference to a writer that implements the std::io::Write trait. This could be a file, buffer, or network stream where the FST will be written.

Auto Trait Implementations§

§

impl Freeze for FST

§

impl RefUnwindSafe for FST

§

impl Send for FST

§

impl Sync for FST

§

impl Unpin for FST

§

impl UnwindSafe for FST

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.