#encryption-decryption #img4 #aes-key #im4p #im4r #im4m #image-compression

app image4-util

Pure Rust tool for handling Image4 files (aka IMG4, IM4P, IM4M, IM4R)

9 releases (4 breaking)

0.5.2 Aug 6, 2023
0.5.1 Jul 7, 2023
0.5.0 Jun 15, 2023
0.4.2 Jun 1, 2023
0.1.0 May 9, 2023

#801 in Encoding

Download history

85 downloads per month

MIT/Apache

225KB
5K SLoC

image4-util

Crate

Pure Rust tool for handling Image4 files (aka IMG4, IM4P, IM4M, IM4R).

Features

  • Extract payload contents from either Image4 containers (IMG4) or Image4 payload files (IM4P).
  • Create either full Image4 containers or Image4 payload files.
  • Decrypt encrypted images using known AES key and IV.
  • Decompress images compressed using LZSS and LZFSE (LZVN is not supported yet).
  • Parse, create and sign Image4 manifests. Both signed and unsigned manifests are supported.
  • Create certificates for signing Image4 manifests.

Installation

cargo install image4-util

Logging

The logging implementation is based on the env_logger crate. There are 3 log levels: info, warn and error (non-release builds support the debug log level). By default, only warning and error levels are enabled. You can set a different minimum log level using the IMAGE4_LOG environment variable (set to off to turn off the logging completely).

Example:

By default image4-util isn't verbose:

$ image4-util extract --iv xxx --key xxx -v llb.im4p
[?] File at llb.bin exists. Do you want to replace it? yes
$

It's quite verbose, however, if you enable the info log level.

$ IMAGE4_LOG=info image4-util extract --iv xxx --key xxx llb.im4p
[*] Extracting file at 'llb.im4p' to 'llb.bin'.
[*] 4CC tag: illb
[*] Builder string: iBoot-7429.41.5
[?] File at llb.bin exists. Do you want to replace it? yes
[*] Decompressed 606278 bytes into 1319704 bytes.
[*] Success.
$

Here instead of xxx will be your actual key and IV.

Minimum Supported Rust Version

This crate requires at least Rust 1.65. An MSRV change will be accompanied by a minor version bump

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~15–24MB
~356K SLoC