Skip to content
This repository was archived by the owner on Dec 24, 2023. It is now read-only.

Checksum field and method for computation #11

Open
ChristopherRabotin opened this issue Jan 26, 2022 · 1 comment
Open

Checksum field and method for computation #11

ChristopherRabotin opened this issue Jan 26, 2022 · 1 comment
Labels
proposed A proposed functionality

Comments

@ChristopherRabotin
Copy link
Member

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.

@ChristopherRabotin ChristopherRabotin added the proposed A proposed functionality label Jan 26, 2022
@ChristopherRabotin
Copy link
Member Author

The adopted signature is:

pub fn check_integrity(&self) -> Result<(), AniseError> {
// ...
}

The error is embedded as a more generic IntegrityError as such:

            Err(AniseError::IntegrityError(
                IntegrityErrorKind::ChecksumInvalid {
                    expected: self.data_checksum,
                    computed: computed_chksum,
                },
            ))

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
proposed A proposed functionality
Projects
None yet
Development

No branches or pull requests

1 participant