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
impl FST
Sourcepub fn is_cipher_key_iv_valid(&self) -> bool
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.
Sourcepub fn get_pattern(&self) -> &[u8; 8]
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.
Sourcepub fn get_cipher_key(&self) -> DataRefType<'_, 32>
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
}
Sourcepub fn get_cipher_iv(&self) -> DataRefType<'_, 16>
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.
pub fn set_cipher_iv(&mut self, iv: DataType<16>)
pub fn set_cipher_key(&mut self, key: DataType<32>)
pub fn set_valid_pattern(&mut self, pattern: [u8; 8])
Trait Implementations§
Source§impl BinarySize for FST
impl BinarySize for FST
Source§fn binary_size() -> usize
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).