Implement FPM policy validation algorithm
@mcy is already working on this.
Since Sep 17, 2020.
- Dominant language
- Rust
- Stars
- 17
- Forks
- 11
- PR merge metrics
- No merged PRs in 30d
Description
Pesudocode for the algorithm:
```rust
fn verify_policy(
fpm: Fpm,
flash: &impl Flash,
hash_builder: &impl ha256::Builder
) -> Result {
for fw in fpm.fw_versions {
let version = flash.read(fw.version_addr, fw.version_len);
if version != fw.version {
continue
}
let mut sha = hash_builder.new();
for (ptr, len) in fw.signed_regions {
// Note: this is grossly exaggerated. There is an expectation that
// data will be fed into the hashing engine in small packets (O(1K),
// for example.
sha.write(flash.read(ptr, len));
}
if fw.signed_region_hash != sha.finish() {
return Err("hash mismatch");
}
let unused_regions = regions_except(flash, [fw.signed_regions,
fw.write_regions]);
for (ptr, len) in unused_regions {
for byte in flash.read(ptr, len) {
return Err("bad byte in blank region");
}
}
return fw
}
return Err("failed to find an acceptable version")
}
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.