Skip to content

Commit f329fdb

Browse files
committed
dir/gen3: implement check_signature() helper for CPDPartition
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent d98e288 commit f329fdb

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/part/gen3.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,20 @@ pub struct CPDPartition {
1919
pub cpd: CodePartitionDirectory,
2020
}
2121

22+
impl CPDPartition {
23+
pub fn check_signature(&self) -> Result<(), String> {
24+
if let Ok((m, mdata)) = &self.cpd.manifest {
25+
if m.verify(&mdata) {
26+
return Ok(());
27+
} else {
28+
return Err("hash mismatch".into());
29+
}
30+
} else {
31+
Err("no manifest found".into())
32+
}
33+
}
34+
}
35+
2236
#[derive(Serialize, Deserialize, Clone, Debug)]
2337
pub struct DataPartition {
2438
pub entry: FPTEntry,

0 commit comments

Comments
 (0)