collapseos icon indicating copy to clipboard operation
collapseos copied to clipboard

Checksums / data integrity

Open keithstellyes opened this issue 4 years ago • 1 comments

There was a bit of discussion on my Random Implementation PR that was cancelled ( https://github.com/hsoft/collapseos/pull/47 , Starting with comment: https://github.com/hsoft/collapseos/pull/47#issuecomment-543379554 ), and it was brought up about potentially using a hashing or checksum algorithm.

Should there be perhaps a library/user-space app for this? Specifically, the use-case that was brought up that I think has a strong case is data integrity. Given that there's been a lot of discussion around EMPs, cobbled-together components, this seems like an error-prone environment. Additionally, I wonder if in the scenarios we talk about CollapseOS being used, bootstrapping could be difficult, and may have to be the tedious way of using a DIP switch or something, and manually writing every single byte by hand. In such a scenario, errors seem a near-guarantee at first.

I personally don't consider crypto to be a concern here, but I personally am open to hearing arguments for it.

If we do think we need something, what algorithm(s) should we use? Modern algorithms in common use, like md5 and sha1 both seem painful to implement on an 8-bit CPU, and expensive.

Fletcher's Checksum seems interesting, simple to implement and seems pretty good; https://en.wikipedia.org/wiki/Fletcher%27s_checksum

Paper on checksums in embedded: https://users.ece.cmu.edu/~koopman/pubs/maxino09_checksums.pdf

keithstellyes avatar Oct 18 '19 17:10 keithstellyes

Yes, it's a good idea to start checking data integrity where it makes sense. I already implemented CRC-16 for the SD card driver: https://github.com/hsoft/collapseos/blob/master/kernel/sdc.asm#L585

Maybe this could be extracted and reused (if it's an adequate algo for the job, of course)

hsoft avatar Oct 18 '19 17:10 hsoft