Checksum field and method for computation #11
Description
In the specs, it would be extremely useful to provide a checksum
field early into the file. The checksum should be computed for the subsequent data (i.e. metadata excluded). Moreover, a function shall be provided to recompute this checksum.
The purpose of this checksum is to allow for rapid verification of the integrity of the data, it shall not be used for signing the data. As such, the CRC32 hashing function is proposed (specifically the cdc32fast crate).
Proposed signatures
This is only valid in an Anise context, i.e. with a loaded Anise file.
impl Anise {
/// Returns the rotation quaternion and the body rate vector
pub fn verify_checksum(&self) -> Result<(), AniseError>;
}
The following AniseError enum variant is proposed:
pub enum AniseError {
// ...
/// Error returned if the checksum in the Anise file does not match the one computed by reading the file
InvalidChecksum {expected: u32, computed: u32}
}
Proposed usage
This can be used onboard in a guidance loop to ensure that the data is valid at each new guidance loop iteration, and if it isn't, a backup file can be loaded from another disk for example.