I'm trying to implement an encrypted file-system.
The file-system consists of 512-byte sectors. I encrypt/decrypt the contents of a sector as follows:
Compute the SHA256 sum of the user password. This results in a 32-byte User Key.
Compute the ESSIV for a sector by computing the SHA256 sum of User Key and the Sector Number. This results in a 32-byte Sector Key.
XOR Sector Key with the plain sector data to get the cipher data as follows:
sector = sector ^ key sector = sector ^ key ... sector = sector ^ key sector = sector ^ key sector = sector ^ key ... sector = sector ^ key ... sector = sector ^ key
When reading the sector back later, I XOR the Sector Key with the cipher data to get my plain sector data back.
Now, the ESSIV approach is supposed to prevent watermarking attacks. However, when I examine the ciphered sectors corresponding to a very large file (>> 512-bytes) full of only zeroes (
- I see that no two ciphered sectors of this large file are identical, which is great!
- I see repeating patterns (each pattern 32-bytes long) within the same sector, which is not so great! These are obviously coming from by XOR step above.
My question is 2-fold:
Can an adversary break open the above file-system encryption by copying carefully constructed files to this file-system? Or, is the above scheme good enough?
When I copy the above file to a TrueCrypt volume, I see no repeating patterns. (I used AES and RIPEMD-160 as the encryption and hashing algorithms, respectively.) So, other than using AES, what can I do to achieve a TrueCrypt-like result via some simple and lightweight XOR-like operation?