libgocryptfs/README.md

134 lines
4.7 KiB
Markdown
Raw Normal View History

2015-09-06 12:12:14 +02:00
GoCryptFS
=========
2015-10-06 00:31:53 +02:00
An encrypted overlay filesystem focused on security and correctness.
2015-09-06 12:12:14 +02:00
2015-10-06 00:31:53 +02:00
gocryptfs is built on top the excellent
[go-fuse](https://github.com/hanwen/go-fuse) FUSE library and its
LoopbackFileSystem API.
2015-09-06 12:12:14 +02:00
2015-10-06 00:31:53 +02:00
This project was inspired by [EncFS](https://github.com/vgough/encfs)
and strives to fix its security issues (see EncFS tickets 9, 13, 14, 16).
2015-10-06 23:08:04 +02:00
Current Status
--------------
* First public release
* Feature-Complete
* Passes the xfstests "generic" tests
Install
-------
go get github.com/rfjakob/gocryptfs
Security
--------
2015-10-06 00:31:53 +02:00
"Security" can be split into "Confidentiality" and "Integrity". The
security level gocryptfs provides for each is discussed in the next
sections.
2015-10-06 00:31:53 +02:00
Confidentiality
---------------
Confidentiality means that information cannot be extracted from the
encrypted data unless you know the key.
### File Contents
2015-10-06 23:08:04 +02:00
* All file contents (even the last bytes) are encrypted using AES-256-GCM
* This is unbreakable in the foreseeable future. Attacks will focus on
cracking the password instead (see section "Master Key Storage").
2015-10-06 00:31:53 +02:00
* Files are segmented into 4096 byte blocks
* Each block gets a fresh random 96 bit IV (none) each time it is written.
* This means that identical blocks can not be identified
### File Names
2015-10-06 23:08:04 +02:00
* File names are encrypted using AES-256-CBC because it is robust even
2015-10-06 00:31:53 +02:00
without using an IV
* The file names are padded to multiples of 16 bytes
* This means that the exact length of the name is hidden, only length
ranges (1-16 bytes, 17-32 bytes etc.) can be determined from the encrypted
files
* For technical reasons, no IV is used
* This means that files with the same name within one gocryptfs filesystem
always get the same encrypted name
2015-10-06 23:08:04 +02:00
### Metadata
* The size of the file is not hidden. The exact file size can be calculated
from the size of the encrypted file.
* File owner, file permissions and timestamps are not hidden either
2015-10-06 00:31:53 +02:00
Integrity
---------
Integrity means that the data cannot be modified in a meaningful way
unless you have the key. The opposite of integrity is *malleability*.
### File Contents
2015-10-06 23:08:04 +02:00
* The used encryption, AES-256-GCM, is a variant of
2015-10-06 00:31:53 +02:00
*authenticated encryption*. Each block gets a 128 bit authentication
tag (GMAC) appended.
* This means that any modification inside block will be detected when reading
the block and decryption will be aborted. The failure is logged and an
I/O error is returned to the user.
2015-10-06 23:08:04 +02:00
* Each block uses its block number as GCM *authentication data*
* This means the position of the blocks is protected as well. The blocks
can not be reordered without causing an decryption error.
* However, proper affiliation of a block to the file is not checked.
* This means that blocks can be copied between different files provided
that they stay at the same position.
* For technical reasons (sparse files), the special "all-zero" block is
2015-10-06 00:31:53 +02:00
seen as a valid block that decrypts to an all-zero block.
2015-10-06 23:08:04 +02:00
### File Names
2015-09-06 12:12:14 +02:00
2015-10-06 23:08:04 +02:00
* File names are only weakly protected against modifications.
* Changing a single byte causes a decode error in at least 255 of 256
cases. The failure is logged and the file is no longer visible in the
directory.
* If no decode error is triggered, at least 16 bytes of the filename will
be corrupted (randomized).
* However, file names can always be truncated to multiples of 16 bytes.
2015-09-06 12:12:14 +02:00
2015-10-06 23:08:04 +02:00
### Metadata
2015-09-06 12:16:34 +02:00
2015-10-06 23:08:04 +02:00
* The file size is not protected against modifications
* However, the block integrity protection limits modifications to block
size granularity.
* This means that files can be truncated to multiples of 4096 bytes.
* Ownership, timestamp and permissions are not protected and can be changed
Master Key Storage
------------------
The *master key* is used to perform file decryption and encryption.
It is stored in `gocryptfs.conf` encrypted with AES-256-GCM using the
*unlock key*.
The unlock key is generated from a user password using `scrypt`.
A sucessful decryption of the master key means that the authentication
passed and the password is correct. The master key is then used to
mount the filesystem.
Performance
-----------
* 28 bytes of storage overhead per block (16 bytes auth tag, 12 byte nonce)
* uses openssl through [spacemonkeygo/openssl](https://github.com/spacemonkeygo/openssl)
for a 3x speedup compared to `crypto/cipher` (see [go-vs-openssl.md](https://github.com/rfjakob/gocryptfs/blob/master/openssl_benchmark/go-vs-openssl.md)) for details
2015-09-06 12:16:34 +02:00
2015-10-06 00:31:53 +02:00
Run `./benchmark.bash` to run the test suite and the streaming read/write
2015-09-06 12:12:14 +02:00
benchmark.
The output should look like this:
2015-10-06 00:31:53 +02:00
$ ./benchmark.bash
[...]
BenchmarkStreamWrite 100 11816665 ns/op 88.74 MB/s
BenchmarkStreamRead 200 7848155 ns/op 133.61 MB/s
ok github.com/rfjakob/gocryptfs 9.407s