Commit Graph

90 Commits

Author SHA1 Message Date
Jakob Unterwurzacher adcfbd79a8 Rename DirIVCacheEnc to just DirIVCache
...and unexport dirIVCache
2016-02-06 12:27:55 +01:00
Jakob Unterwurzacher 6454db68d9 Add new "-wpanic" option and enable it for the automated tests 2016-01-31 18:09:39 +01:00
Jakob Unterwurzacher 4c9e249e3a Convert fdLock to an RWMutex and protect the whole transaction
...against concurrent closes.

The testcase

	(set -e; while true; do truncate -s $RANDOM b; done) &
	(set -e; while true; do truncate -s $RANDOM b; done) &

uncovered lots of unnecessary RMW failures that were the result
of concurrent closes.

With this patch, the only remaining error is "Truncate on forgotten file"
that is probably caused by a problem in the go-fuse lib
( https://github.com/hanwen/go-fuse/issues/95 )
2016-01-25 00:51:28 +01:00
Jakob Unterwurzacher 8fb32aab68 Downgrade "gocryptfs.diriv not found" warning if the directory was deleted
The directory may have been concurrently deleted or moved. Failure to
read the diriv is not an error in that case.

Downgrading the message to debug.
2016-01-24 19:40:53 +01:00
Jakob Unterwurzacher 2e419e635f Remove last SetOutput from generic code 2016-01-22 21:49:56 +01:00
Jakob Unterwurzacher 9f9cf882ad Add missing import for Go 1.4 2016-01-22 21:42:58 +01:00
Jakob Unterwurzacher df41183e9b Disable syslog in Go 1.4 and lower (method SetOutput does not exist) 2016-01-22 21:41:34 +01:00
Jakob Unterwurzacher 505fef5a3c renamed: cryptfs/gcm_go14.go -> cryptfs/gcm_go1.4.go
renamed:    cryptfs/gcm_go15.go -> cryptfs/gcm_go1.5.go
2016-01-22 21:39:16 +01:00
Jakob Unterwurzacher d163169655 Wrap Logger to make disabling output more efficient
Instead of using SetOutput(ioutil.Discard), which means
that Printf is still called for every debug message,
use a simple and fast boolean check.

Streaming write performance improves from 86 to 93 MB/s.
2016-01-21 22:59:11 +01:00
Jakob Unterwurzacher 17f0eb1339 Convert logging to standard Go log.Logger
This is in preparation of logging to syslog.
2016-01-20 20:57:00 +01:00
Jakob Unterwurzacher 8c7e31329d Use NewGCMWithNonceSize only through goGCMWrapper to support Go 1.4 2015-12-19 15:19:31 +01:00
Jakob Unterwurzacher 1caa925868 Increase GCM IV size from 96 to 128 bits
This pushes back the birthday bound for collisions to make it virtually
irrelevant.
2015-12-19 15:02:29 +01:00
Jakob Unterwurzacher 00a712b4d1 go fmt
...and minimal comment changes.
2015-12-13 20:24:13 +01:00
Jakob Unterwurzacher e99e841713 Rmdir: handle creating and removing unreadable directories
This patch also splits off Mkdir and Rmdir into its own file.

Fixes issue #8, thanks to @diseq for the bug report.
2015-12-11 20:02:12 +01:00
Jakob Unterwurzacher 78cd97c5e9 Wrap NewGCMWithNonceSize() to enable compilation on Go 1.4 2015-12-10 20:55:09 +01:00
Jakob Unterwurzacher b4b9072cc2 Simplify CreateConfFile: do not allow specification of EMENames 2015-12-10 19:38:02 +01:00
Jakob Unterwurzacher c6dacd6f91 Add EME filename encryption & enable it by default 2015-12-08 16:17:04 +01:00
Jakob Unterwurzacher f4ae0304af opensslGCM: preallocate buffer space, improves performance by 11%
Results of cryptfs/openssl_benchmark.bash :

Before:
  BenchmarkEnc_OpenSSL_4k_AES256_nonce96-2 	   50000	     31802 ns/op	 127.28 MB/s
  BenchmarkEnc_OpenSSL_4k_AES256_nonce128-2	   50000	     32110 ns/op	 126.06 MB/s

After:
  BenchmarkEnc_OpenSSL_4k_AES256_nonce96-2 	   50000	     28612 ns/op	 141.47 MB/s
  BenchmarkEnc_OpenSSL_4k_AES256_nonce128-2	   50000	     28613 ns/op	 141.47 MB/s
2015-12-08 13:22:57 +01:00
Jakob Unterwurzacher c6a6641b58 tests: add encryption benchmarks to cryptfs 2015-12-08 13:19:19 +01:00
Jakob Unterwurzacher 56888d83dd fallocate the space needed for the file header beforehand
This makes sure writing to a file fails early if the underlying
filesystem does not support fallocate. It also prevents partial header
write due to ENOSPC.
2015-12-06 15:05:52 +01:00
Jakob Unterwurzacher 71b94828ed init: create gocryptfs.diriv after creating gocryptfs.conf
Creating the config file can fail easily, for example if the
password is not entered the same twice. This would leave an
orphaned gocryptfs.diriv behind.
2015-12-06 14:24:45 +01:00
Jakob Unterwurzacher ce42a6f23d Run go fmt 2015-11-29 21:55:20 +01:00
Jakob Unterwurzacher 20b058a333 Add single-element cache for DirIV lookup
Another 3x performance boost for applications that walk the
directory tree.

Excerpt from performance.txt:

VERSION         UNTAR    LS     RM
v0.4               48     1.5    5
v0.5-rc1           56     7     19
v0.5-rc1-1         54     4.1    9
v0.5-rc1-2         45     1.7	 3.4  <---- THIS VERSION
2015-11-29 21:41:38 +01:00
Jakob Unterwurzacher 1d0a442405 OpenDir performance: Read DirIV once and reuse it for all names
Formerly, we called decryptPath for every name.
That resulted in a directory walk that reads in all diriv files
on the way.

Massive improvement for RM and LS (check performance.txt for details)

VERSION         UNTAR   RM   LS
v0.4               48    5    1.5
v0.5-rc1           56   19    7
v0.5-rc1-1         54    9    4.1   <---- THIS VERSION
2015-11-29 20:03:37 +01:00
Jakob Unterwurzacher bb116282b7 Add "-scryptn" option that sets the cost parameter for scrypt
Use that option to speed up the automated tests by 7 seconds.

Before:
	ok  	github.com/rfjakob/gocryptfs/integration_tests	26.667s
After:
	ok  	github.com/rfjakob/gocryptfs/integration_tests	19.534s
2015-11-29 18:53:40 +01:00
Jakob Unterwurzacher 71bfa1f0fb tests: add scrypt benchmark
Times the impact of the parameter "N" to scrypt.

Results on a 2.7GHz Pentium G630:

gocryptfs/cryptfs$ go test -bench=.
PASS
BenchmarkScrypt10-2	     300	   6021435 ns/op ... 6ms
BenchmarkScrypt11-2	     100	  11861460 ns/op
BenchmarkScrypt12-2	     100	  23420822 ns/op
BenchmarkScrypt13-2	      30	  47666518 ns/op
BenchmarkScrypt14-2	      20	  92561590 ns/op ... 92ms
BenchmarkScrypt15-2	      10	 183971593 ns/op
BenchmarkScrypt16-2	       3	 368506365 ns/op
BenchmarkScrypt17-2	       2	 755502608 ns/op ... 755ms
ok  	github.com/rfjakob/gocryptfs/cryptfs	18.772s
2015-11-29 14:50:02 +01:00
Jakob Unterwurzacher 3b2143bafc diriv: fix readdir
It decrypted all file names using the root directory iv
2015-11-28 18:39:45 +01:00
Jakob Unterwurzacher fe7355f9ee diriv: use "DirIV" flag to discern and support mounting old filesystems 2015-11-28 18:38:06 +01:00
Jakob Unterwurzacher a04a92cdab Run go fmt 2015-11-27 22:20:01 +01:00
Jakob Unterwurzacher 6acd772cf9 diriv: Define "DirIV" feature flag
(unused so far)
2015-11-27 22:18:36 +01:00
Jakob Unterwurzacher bdd9249a52 diriv: Move WriteDirIV() to cryptfs; add locking to Mkdir, Rmdir 2015-11-27 21:48:58 +01:00
Jakob Unterwurzacher decfc1ab79 diriv: Convert filename encryption users to diriv 2015-11-27 00:03:10 +01:00
Jakob Unterwurzacher 4d466c3412 diriv: Create gocryptfs.diriv in every directory 2015-11-25 20:57:16 +01:00
Jakob Unterwurzacher d8bf6e7836 Tighten file permissions on gocryptfs.conf
This file should only be readable by the owner and never be written to.
2015-11-25 20:57:16 +01:00
Jakob Unterwurzacher 296bdf3af2 CipherSizeToPlainSize: Handle illegal states
A file never gets a cipherSize <= HEADER_LEN in normal operation.
However, this can happen if header write it interrupted or the
underlying filesystem does not support fallocate.

Noticed while trying to store a CIPHERDIR in another gocryptfs mount
(gocryptfs does not support fallocate)
2015-11-15 14:15:21 +01:00
Jakob Unterwurzacher d95fc2333a Add "-extpass" cli option and associated tests 2015-11-15 13:42:04 +01:00
Jakob Unterwurzacher 61aacb5c1b Run go fmt and go vet 2015-11-14 17:16:17 +01:00
Jakob Unterwurzacher 99dfc84992 Add "-q" (quiet) flag 2015-11-09 22:33:42 +01:00
Jakob Unterwurzacher 050005fd7b Centralize path filter decision in CryptFS.IsFiltered() 2015-11-03 22:25:29 +01:00
Jakob Unterwurzacher 988e0a047c tests: add config file and feature flags tests 2015-11-03 21:09:58 +01:00
Jakob Unterwurzacher 3e367b29b0 config: Introduce ext4-style feature flags
// List of feature flags this filesystem has enabled.
// If gocryptfs encounters a feature flag it does not support, it will refuse
// mounting. This mechanism is analogous to the ext4 feature flags that are
// stored in the superblock.
FeatureFlags []string
2015-11-03 21:05:47 +01:00
Jakob Unterwurzacher 28b3af12d1 Fix tests broken by PlaintextNames addition 2015-11-03 18:19:19 +01:00
Jakob Unterwurzacher 1ec0fa388d Update USAGE.txt
Also run go fmt
2015-11-03 00:06:04 +01:00
Jakob Unterwurzacher de56fe9e35 Implement PlainTextNames mode
Also, forbid access to "gocryptfs.conf" in the root dir.
2015-11-03 00:00:13 +01:00
Jakob Unterwurzacher 66db3ad086 Bump on-disk version to 2 2015-11-02 23:10:11 +01:00
Jakob Unterwurzacher 0ec17c3939 Add "--plaintextnames" option
Also, gather all the command line arguments into an anonymous struct
"args".
2015-11-02 23:09:51 +01:00
Jakob Unterwurzacher 902babdf22 Refactor ciphertext <-> plaintext offset translation functions
Move all the intelligence into the new file address_translation.go.
That the calculations were spread out too much became apparent when adding
the file header. This should make the code much easier to modify in the
future.
2015-11-01 12:11:36 +01:00
Jakob Unterwurzacher 76311b60f2 Add file header (on-disk-format change)
Format: [ "Version" uint16 big endian ] [ "Id" 16 random bytes ]

Quoting SECURITY.md:

* Every file has a header that contains a 16-byte random *file id*
* Each block uses the file id and its block number as GCM *authentication data*
 * This means the position of the blocks is protected as well. The blocks
   can not be reordered or copied between different files without
   causing an decryption error.
2015-11-01 01:38:27 +01:00
Jakob Unterwurzacher eac1f54213 Activate block number authentication 2015-11-01 01:36:19 +01:00
Jakob Unterwurzacher d1d444435c main: check directories for existence early
This prevents that the user enters the password only to get an error
later.
2015-10-11 18:33:28 +02:00