amebazii::types::image::boot

Struct BootImage

Source
pub struct BootImage {
    pub keyblock: KeyBlock,
    pub header: ImageHeader,
    pub entry: EntryHeader,
    /* private fields */
}
Expand description

Represents a boot image, including encryption public keys, hash, and segment data.

This struct contains the details of the boot image including the encryption and hash public keys, header, entry, text (payload), and a hash representing the integrity of the image.

Fields§

§keyblock: KeyBlock§header: ImageHeader

The header of the boot image, containing general information about the image.

§entry: EntryHeader

The entry header, typically pointing to the start of the executable code or data.

Implementations§

Source§

impl BootImage

Source

pub fn get_text(&self) -> &[u8]

Retrieves the text (code) content of the boot image.

This method provides access to the text field of the BootImage as a byte slice. It allows reading the raw byte data representing the text within the boot image.

§Example
use amebazii::types::BootImage;

let boot_image = BootImage::default();
let text = boot_image.get_text();
println!("Text data: {:?}", text);
Source

pub fn get_hash(&self) -> &[u8]

Retrieves the hash value associated with the boot image.

This method returns the hash field of the BootImage, which is a byte slice representing the hash (cryptographic hash) of the boot image data.

Source

pub fn set_text(&mut self, text: Vec<u8>)

Sets the text content of the boot image.

This method updates the text field of the BootImage with a new vector of bytes. It allows modifying the raw byte data that represents the boot image’s text.

§Arguments
  • text - A vector of bytes (Vec<u8>) to set as the new text content.
§Example
use amebazii::types::BootImage;

let mut boot_image = BootImage::default();
let new_text = vec![1, 2, 3, 4, 5];
boot_image.set_text(new_text);
assert_eq!(boot_image.get_text(), vec![1, 2, 3, 4, 5]);

Trait Implementations§

Source§

impl AsImage for BootImage

Source§

fn build_segment_size(&self) -> u32

Computes the segment size for the BootImage.

The segment size includes the size of the header, entry, text, and the hash.

§Returns:
  • u32: The computed segment size.
Source§

fn set_segment_size(&mut self, size: u32)

Sets the segment size for the BootImage.

This method sets the segment_size field in the header of the BootImage.

§Arguments:
  • size: The segment size to set.
Source§

fn build_signature(&self, key: Option<&[u8]>) -> Result<Vec<u8>, Error>

Computes the signature for the BootImage.

This method computes the signature (e.g., HMAC or checksum) for the BootImage using the provided key.

§Arguments:
  • key: The key used to compute the signature.
§Returns:
  • Result<Vec<u8>, crate::error::Error>: The computed signature as a vector of bytes.
Source§

fn set_signature(&mut self, signature: &[u8])

Sets the signature for the BootImage.

This method sets the signature field of the BootImage (i.e., the hash field).

§Arguments:
  • signature: The computed signature to set in the BootImage.
Source§

impl Debug for BootImage

Source§

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

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

impl Default for BootImage

Source§

fn default() -> Self

Creates a new BootImage with default values.

The BootImage is initialized with default values:

  • Encryption and hash public keys are set to all 0xFF bytes.
  • The header and entry are initialized with their default values.
  • The text field is an empty vector, and the hash field is set to all 0xFF bytes.
Source§

impl FromStream for BootImage

Source§

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

Reads a BootImage from a binary stream.

§Arguments:
  • reader: The stream from which the data will be read. This must implement std::io::Read and std::io::Seek.
§Returns:
  • Result<(), crate::error::Error>: A Result indicating success or failure. If an error occurs during reading, it returns an error.
Source§

impl ToStream for BootImage

Source§

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

Writes a BootImage to a binary stream.

§Arguments:
  • writer: The stream to which the data will be written. This must implement std::io::Write.
§Returns:
  • Result<(), crate::error::Error>: A Result indicating success or failure. If an error occurs during writing, it returns an error.

Auto Trait Implementations§

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.