5

I encrypted a 1GB folder using Cryfs and the encrypted folder appeared to be 6 times larger than the original folder? I know encrypted files are always larger than the original files, but 6 times?!?

Is it a bug causing this or is it normal for CryFs as it does a lot than encfs or any other encrypting apps?

Pablo Bianchi
  • 14,308
  • 4
  • 74
  • 117
alien250
  • 125
  • 1
  • 8

2 Answers2

3

The goal of CryFS is not only to keep file contents, but also file sizes, metadata and directory structure confidential.

To hide file sizes, CryFS splits the content of a file into same-size blocks and encrypts these blocks individually. A tree structure is used to remember how the blocks belong together to form a file. This tree structure has very little overhead and itself is also stored using encrypted same-size blocks. To hide file metadata and directory structure, they are also represented using encrypted same-size blocks.

Source:

https://www.cryfs.org/howitworks

Elder Geek
  • 35,476
  • 25
  • 95
  • 181
2

Following is directly from the developer, Sebastian M. : (hope this helps somebody who has the same question)

tldr;> This can happen due to how CryFS works, but should be much better in the upcoming 0.10 release series. You can also improve it when using a 0.9.x version by changing the block size of your file system.

Background: CryFS 0.9.x allocates all data in blocks of 32kb by default. Even if you have very small files, each file needs at least one block and will need at least these 32kb of space. This is done, because CryFS uses this to hide the file size. You can read more on why this is important in the second paragraph here: https://www.cryfs.org/comparison#encfs There is a security proof in the CryFS paper that attackers cannot find out your directory structure or how large your files are from seeing the encrypted file system.

But unfortunately, this means that in scenarios where you store a huge number of tiny files, the bloat can be quite a lot. In 0.10.x, the default was changed to using 16kb blocks, so the bloat should be much smaller. However, you don't need to wait for that. When creating a file system, you can choose the block size. Choosing a smaller block size will reduce the binary bloat (you can try going down to 4kb), but might make the file system a bit slower when accessing large files.

alien250
  • 125
  • 1
  • 8
  • Wow. I have already been waiting for over 24 hours to rsync between two drives that can sustain >50MB/s when doing a drive to drive rsync and I'm barely getting 2MB/s due to small file size; it's driving me out of my mind!!! And I'm supposed to think the solution is SMALLER files? Why not just pack multiple files into one block??? – Michael Aug 02 '20 at 18:15
  • @Michael: Or pack multiple blocks into one file. Like, allocate all data in blocks of 4kb, then put 64 of them into one file. – Honza Dec 30 '21 at 08:26