Skip to content

Commit f113615

Browse files
committed
implement check of checksums and signatures
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent 3a48341 commit f113615

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

src/main.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ enum MeCommand {
5656
/// Extract ME region to a file if given a full image
5757
#[clap(long, short = 'M')]
5858
extract_me: Option<String>,
59+
/// Perform basic integrity checks
60+
#[clap(long, short)]
61+
check: bool,
5962
/// File to read
6063
file_name: String,
6164
},
@@ -135,6 +138,7 @@ fn main() {
135138
output,
136139
extract_descriptor,
137140
extract_me,
141+
check,
138142
} => {
139143
debug!("Configuration:");
140144
debug!(" Adjust flash descriptor: {descriptor}");
@@ -154,6 +158,7 @@ fn main() {
154158
if let Some(blocklist) = &blacklist {
155159
debug!("Blocklist: {blocklist:?}");
156160
}
161+
debug!(" Check: {check}");
157162
debug!("");
158163
if let Some(descriptor_file) = &extract_descriptor {
159164
info!("Dump flash descriptor to {descriptor_file}");
@@ -176,6 +181,23 @@ fn main() {
176181
let Ok(me) = me_res else {
177182
return;
178183
};
184+
if check {
185+
let fpt = &me.fpt_area.fpt;
186+
let cs = fpt.header_checksum();
187+
if cs == fpt.header.checksum {
188+
println!("FPT checksum is correct");
189+
} else {
190+
println!(
191+
"FPT checksum error: is {:02x}, should be {cs:08x}",
192+
fpt.header.checksum
193+
);
194+
}
195+
match &me.fpt_area.check_ftpr_sig() {
196+
Ok(()) => println!("FTPR signature is valid"),
197+
Err(e) => println!("FTPR signature error: {e:}"),
198+
}
199+
return;
200+
}
179201
let opts = clean::Options {
180202
keep_modules,
181203
relocate,

0 commit comments

Comments
 (0)