radumarias / rencfs

An encrypted file system written in Rust that is mounted with FUSE on Linux. It can be used to create encrypted directories
Apache License 2.0
102 stars 21 forks source link

Generate unique inode #144

Open radumarias opened 2 months ago

radumarias commented 2 months ago

To ensure unique inode between instances we will have this flow:

This reduces the number of inodes to 288,230,376,151,711,743, which is more than enough for us.

A possible problem:

Consider this example: one uses your program, creates a backup of the data, keeps using the program. If they restore the backup, then they will restart from an earlier counter, and reuse the same inode.

To mitigate this we could keep the inode_seq in keyring also and use max(keyring, app_data).

An alternative to counters is to have some logic to assign unique IDs to blocks, and use that ID to derive a nonce. You may get some inspiration on how to do that from https://en.wikipedia.org/wiki/Disk_encryption_theory, in particular the ESSIV section.

If you're concerned about nonce reuse, you might want to look into XChaCha20-Poly1305, which allows longer nonces.

Some popular constructs often used for disk encryption are AES-XTS and HBSH. You'll find it useful to research why they're used specifically for disk encryption.

[!WARNING]
Update readme