Close

More detail on how it works

A project log for Orthrus

SD card secure RAID USB storage

nick-sayerNick Sayer 04/03/2017 at 03:340 Comments

During initialization time, the first block of each SD card gets an initialization structure written to block 0.

This structure has the following:

When the device is initialized, the code will verify that the magic bytes on both cards is correct, that the two 32 byte volume IDs match, and that one of the flag bytes indicates "A" and the other "B". If any of these checks fail, then the LED will turn RED and the device won't start.

If the LED is RED and the button is pushed, then the two cards will have this initialization block written and the system will reinitialize.

If the checks above pass, then the volume key is derived by taking the two key seed values, "A" first and "B" second and performing an AES CMAC with an all-zero key. The result is used as a key to perform a CMAC on the volume identifier. The result of that is the volume key.

To report the size of the volume of the host, we take the smaller of the two card block sizes, subtract 1 and then multiply by 2.

After initialization, we simply wait for and respond to USB block requests. For a read request, we take the bottom bit of the block number and use that as an A or B selector. The rest of the block number is right-shifted (divided by 2) and 1 is added. That block of the indicated card (A or B) is read. It then creates a nonce from the opposite card's nonce value and the original block number. It then does a CTR mode encrypt operation on the data. The result of that is returned to the host. A write operation is exactly the same except that the data for the CTR encrypt came from the USB operation and is then written to the appropriate block on the card.

If at any moment either of the SD cards is removed, we immediately scrub the key material and mark the device offline and wait for both cards to indicate present before attempting to reinitialize.

Discussions