Commit Graph

188 Commits (master)

Author SHA1 Message Date
Mark Pariente 3ea8d871a7 Add a test case for recursive directory copying 2012-04-25 23:42:09 -07:00
Mark Pariente 9d38e6188f EncFSVolume.copyOrMovePath() fix for dir copies
When copying a directory recursively we should manually
perform the recursion since EncFSFileProvider.copy()
interface doesn't allow recursive copies.

Also, we should update dstPath with the newly created
directory to copy/move stuff from srcPath into it.
2012-04-25 23:41:58 -07:00
Mark Pariente 117d181cf4 EncFSVolumeTest improvements
Create many different types of volumes and run the file operations
test on each volume. The following volume configurations are now
being tested:

* Default volume
* No Unique IV
* No Chained name IV
* No Unique IV or Chained IV
* No zero block passthrough
* 256-bit volume key
* 128-bit volume key
* 4096 byte block size
* Stream name algorithm
* 8 byte block MAC header
* 8 byte block MAC header + 8 random bytes

Also, I've split off the core testing logic into EncFSVolumeTestCommon,
and created two separate tests, one using CommonVFSFileProvider and one
using EncFSLocalFileProvider.

Misc cleanups:

* Split off createTempDir() to be under EncFSVolumeTestCommon
* Sort file lists in testFileOperations to deal with arbitrary ordering
  from EncFSFileProvider's
2012-03-07 23:31:32 -08:00
Mark Pariente ab016fef4c Fix CommonVFSFileProvider.copy()
For some reason FileObject.copyFrom() was failing to copy files, so
instead use FileUtil.copyContents().
2012-03-07 23:31:32 -08:00
Mark Pariente dba45202f8 Don't produce // as parentPath in EncFSLocalFileProvider 2012-03-07 23:31:32 -08:00
Mark Pariente ff3a20305f Turn on allowHoles in the default EncFSConfig 2012-03-07 01:15:11 -08:00
Mark Pariente f12f98a2a1 Make EncFSVolume.recursiveDelete private 2012-03-07 00:47:17 -08:00
Mark Pariente 00636eaaa1 EncFSVolume.deletePath() can remove non-empty dirs
Implemented recursive directory deletion support controlled by a
boolean option in EncFSVolume.deletePath(). Extended the EncFSShell
'rm' command to make use of this functionality and added a test
case to EncFSVolumeTest to exercise recursive deletion of a
non-empty directory path.
2012-03-07 00:42:27 -08:00
Mark Pariente 6e814aba75 Implement cp command for EncFSShell 2012-03-04 02:00:35 -08:00
Mark Pariente d38dd6015d Improve recursive copy support
Make EncFSVolume.copyPath() more robust by making it able to
recursively copy directories even with the ChainedNameIV config
option.
2012-03-04 01:59:52 -08:00
Mark Pariente e92b409abd Add missing continue in 'mv' error path 2012-03-04 00:06:38 -08:00
Mark Pariente f46201577d Fix style 2012-03-04 00:06:26 -08:00
Mark Pariente 87ca7a109f Fix EncFSVolume.movePath() for ChainedNameIV
There was a bug in EncFSVolume.movePath() that caused recursive moves
in the case of ChainedNameIV configurations to fail. Also improved
rollback handling in the case of an error during the recursive move
by trying to delete the newly created directories.

Added a FileNotFoundException to EncFSLocalFileProvider.move()
implementation as well.
2012-03-03 23:54:29 -08:00
Mark Pariente 8b49d66127 Absolute/relative path handling in EncFSShell
This commit cleans up EncFSShell path handling to allow absolute paths
as well as relative paths with multiple path elements. For example:

/ > ls
testdir1/
/ > ls testdir1/testdir2
testdir-with-really-really-long-name/
testfile2.txt
/ > cd testdir1/testdir3/testdir4
/testdir1/testdir3/testdir4 > cat /testdir1/testfile.txt
file contents!
file contents!
...

All existing commands were improved to use the new path handling
capabilities. Cleaned up error messages in the process as well.
2012-03-03 18:50:09 -08:00
Mark Pariente 216a33901a Throw exception from EncFSLocalFileProvider.mkdir()
Made EncFSLocalFileProvider.mkdir() throw a FileNotFoundException
if one or more path elements aren't found. Also modified
EncFSVolume.makeDir to filter this exception to print the
unencrypted path in the exception message.
2012-03-03 17:33:30 -08:00
Mark Pariente e1027c3b87 Implement EncFSUtil.copyWholeStream()
Noticed we're doing full InputStream->OutputStream copies quite a bit
around the code, so this commit adds a utility function for that and
calls it from everywhere.
2012-02-29 23:59:49 -08:00
Mark Pariente 024b19dc2e Show '/' at the end of directory names 2012-02-29 23:02:34 -08:00
Mark Pariente 5f4c44ed7c Add test for zero-block passthrough 2012-02-29 21:47:30 -08:00
Mark Pariente ba773dfdb9 Implement zero-block passthrough 2012-02-29 21:22:26 -08:00
Mark Pariente f5daf6d52a Code style, formatting and API name cleanups
This is a massive commit serving a few purposes:

 * Unify code formatting and style to conform to Eclipse formatting. We
   will use this formatting from now on for all new code to have a
   uniform codebase.

 * Clean up API naming and remove redundancies. I've renamed a lot of
   API functions to promote coherence across the codebase. I've also
   removed some redundant API's to promote best practices.

 * Improve JavaDoc coverage. This commit documents all public methods
   within the library itself.

 * Fix JavaDoc warnings.
2012-02-27 23:03:14 -08:00
Mark Pariente 95183d30b1 Account for block headers in getDecodedFileInfo()
EncFSFileInfo.getDecodedFileInfo() needs to account for block headers
when calculating the size of the decoded file contents.
2012-02-26 19:26:16 -08:00
Mark Pariente 3e825f410a Merge remote-tracking branch 'aefo/master' into master
Conflicts:
	src/main/java/org/mrpdaemon/sec/encfs/EncFSConfigWriter.java
	src/main/java/org/mrpdaemon/sec/encfs/EncFSVolume.java
	src/test/java/org/mrpdaemon/sec/encfs/EncFSVolumeTest.java
2012-02-22 21:08:52 -08:00
aefo 9625039638 Added further tests for EncFSVolume 2012-02-22 19:28:42 +00:00
Mark Pariente 2ed6748688 Get rid of the extra copies in input/output streams
The extra copy in EncFSInputStream wasn't necessary. Unfortunately the
copy in EncFSOutputStream can't be averted, but this commit moves it to
be in streamEncode() itself.
2012-02-20 22:52:24 -08:00
Mark Pariente a85ddabccb Add a version of EncFSCrypto.mac64 without length 2012-02-20 22:17:06 -08:00
Mark Pariente a4346a0263 Remove stale comment 2012-02-20 12:11:38 -08:00
Mark Pariente 7461211c01 Add support for per-block MAC headers
This commit implements the blockMACBytes and blockMACRandBytes options
that cause a header to be inserted in front of every file block
containing a MAC of the block (and optionally some random data).

Added support to EncFSConfig, EncFSConfigParser and EncFSConfigWriter
to recognize these options. Implemented the MAC computation,
verification and insertion in EncFSInputStream and EncFSOutputStream.
Added a new test volume configured with 8 bytes of MAC and 8 bytes of
random bytes as 'testvol-blockmac', and extended EncFSVolumeTest to
include a long file test that verifies the MAC computations.
2012-02-20 12:08:18 -08:00
Mark Pariente 41cae65321 Add long file tests that verify decrypted content
Added two 6000 byte files to the default and no unique IV test volumes
and added tests that verify decrypted content. These tests are useful
for testing block encryption.
2012-02-19 15:47:42 -08:00
Mark Pariente 4bb80ed120 Convert getDefaultConfig() to EncFSConfig() constructor 2012-02-19 12:40:42 -08:00
Mark Pariente e80add4f0e Don't use a random iteration count in encodeVolumeKey 2012-02-19 12:29:08 -08:00
Mark Pariente e47c694c0e createVolume() no longer instantiates EncFSVolume
Separated the step of instantiating an EncFSVolume from the
createVolume() function. This allows batch volume creation support
without having to do the associated crypto that comes with creating
an EncFSVolume object to actually use the created volume.
2012-02-19 12:13:22 -08:00
Mark Pariente 87eea27c1d Use SecureRandom instead of Random 2012-02-12 19:04:50 -08:00
Mark Pariente f2be09a789 Get rid of the unused File field in EncFSFile 2012-02-12 19:02:28 -08:00
Mark Pariente b4d230dac7 Volume creation support
This commit adds initial support for volume creation. A new class was
added for writing an EncFSConfig to a file (EncFSConfigWriter). Provided
utility methods for getting a default EncFSConfig and creating a new
volume with a given password and EncFSConfig.

Added a basic volume creation test which creates a temporary directory
and creates a volume within, making sure that encfs-java is able to
instantiate an EncFSVolume on it afterwards. I also made sure that the
upstream encfs implementation can read the volume created by this test
also.
2012-02-11 19:52:25 -08:00
Mark Pariente f1cb71fc4e Get rid of deprecated EncFSFile constructor
We shouldn't use the EncFSFile constructor that takes in a File any
more since we have EncFSLocalFileProvider now. This change removes
that constructor and all the EncFSVolume special casing for it.
2012-02-10 00:15:16 -08:00
Mark Pariente 1bd78ad629 EncFSCrypto code refactoring + comments
Shuffled around some methods, changed public/private attributes,
refactored some common code and added JavaDoc comments for all public
methods.
2012-02-09 23:51:32 -08:00
Mark Pariente e69353840d EncFSVolume constructor refactoring
Removed all File based constructors for EncFSVolume. Only kept the
following constructors:

EncFSVolume(String rootPath, String password)
EncFSVolume(String rootPath, byte[] passwordKey)
EncFSVolume(EncFSFileProvider fileProvider, String password)
EncFSVolume(EncFSFileProvider fileProvider, byte[] passwordKey)
EncFSVolume(EncFSFileProvider fileProvider, EncFSConfig config,
            String password)
EncFSVolume(EncFSFileProvider fileProvider, EncFSConfig config,
            byte[] passwordKey)

The first two constructors are easy to use ones for volumes on the local
filesystem. The next two allow non-local storage to be plugged in using
a custom EncFSFileProvider implementation. The last two allow the config
file to be parsed externally, to support the use case where the config
file is located separately than the volume.
2012-02-01 18:59:49 -08:00
Mark Pariente f1f22e113a Rename file provider classes
EncFSNativeFileSource -> EncFSFileProvider
EncFSLocalFileSystemNativeFileSource -> EncFSLocalFileProvider
2012-02-01 18:13:53 -08:00
aefo e26ae1462e Change throwing of caught exceptions to include the original / inner
one (to make it easier to trace issues / debug the original cause)
2012-01-31 20:03:24 +00:00
Mark Pariente 1097cdc980 Add test for the String constructor of EncFSVolume 2012-01-22 13:02:16 -08:00
Mark Pariente a62084b57c Fix EncFSVolume.listFiles() for the root dir
EncFSVolume.listFiles() would fail when given this.rootDir as a
parameter because it concatanated the rootDir's last path element
with the root path and ended up causing null pointer exception in
EncFSLocalFileSystemNativeFileSource.listFiles().
2012-01-22 12:49:59 -08:00
Mark Pariente fcc46ee700 Fix EncFSFileInfo.convertToFileInfo() for root directory
In case the file parameter was the root directory, this function
attempted to substring into the parent directory using the root
directories length, resulting in out of bounds index access in
substring().
2012-01-22 12:25:31 -08:00
aefo 23e44e1489 Method renames & adding license headers 2012-01-11 21:19:10 +00:00
aefo 8259a2619d Add initial support for copying files unique file IV 2012-01-11 21:10:27 +00:00
aefo 86e4ead7fc Refactor to allow non local file system based volumes 2012-01-08 16:25:23 +00:00
aefo e7c9798c57 Multiple updates
1) Bug fix for EncFSInputStream missing off the last byte of the stream
2) Initial support for EncFSFileOutputStream
3) Additional tests
4) EncFSComparer enhanced to check file read/ re-write
2012-01-01 16:11:28 +00:00
aefo 4d1754de1b Added check that the file names can be re-encoded correctly 2011-12-30 15:27:10 +00:00
aefo 7d83d8c021 Bug fixes for directory renames & file name encoding 2011-12-29 17:22:58 +00:00
aefo 0989d3bcc9 Updates for handling directory renames with chained IV is used 2011-12-29 12:38:09 +00:00
aefo 84d1ccf7a4 Added comment 2011-12-27 11:52:19 +00:00
aefo 47f1a8a74e Added check that not renaming directory when using name chained IV 2011-12-27 11:16:59 +00:00
aefo 6979394153 Add shell opertions like mkdir(s) / mv / rm 2011-12-26 21:35:22 +00:00
aefo 4bb7895043 inital commit of being able to encode file names 2011-12-26 18:43:44 +00:00
aefo 4fed749174 Added code comments 2011-12-26 18:18:00 +00:00
aefo bdee7ef4fa Merge remote-tracking branch 'upstream/master'. Also extracted unit
tests to new files

Conflicts:
	src/main/java/org/mrpdaemon/sec/encfs/EncFSCrypto.java
	src/main/java/org/mrpdaemon/sec/encfs/EncFSFile.java
	src/test/java/org/mrpdaemon/sec/encfs/EncFSComparer.java
	src/test/java/org/mrpdaemon/sec/encfs/EncFSVolumeTest.java
2011-12-21 18:05:11 +00:00
aefo 31a551c0db Initial commit for support of encoding file names (still work in
progress)
2011-12-21 11:24:00 +00:00
Mark Pariente bf71a24594 Add more test volumes
Added test volumes created with encfs 1.7.4:

* Default settings
* No uniqueIV (no per-file IV header)
2011-12-21 00:13:12 -08:00
Mark Pariente 6986e111c7 Don't use BufferedInputStream in EncFSVolumeTest 2011-12-20 23:28:35 -08:00
aefo 8db0057abc Correct compile error 2011-12-20 23:20:11 -08:00
aefo ccceecb4b5 added comment 2011-12-20 23:20:11 -08:00
aefo 5040a34afd Test too to verify / compare directory & file info between encfs-java
decode & mounted encf volume
2011-12-20 23:20:11 -08:00
aefo b4b0d573db Created tests for EncFSUtil 2011-12-20 23:20:11 -08:00
aefo 89d2f4992a Added test using incorrect password against an encfs volume 2011-12-20 23:20:11 -08:00
aefo 893a0f0291 Added toString for the config 2011-12-20 23:20:11 -08:00
aefo 233def6365 Fixes for skipping files in the raw FS that aren't encoded with our volume key 2011-12-20 23:20:11 -08:00
aefo 18655cb8de Addition of unit tests for the encfs samples 2011-12-20 23:20:11 -08:00
aefo e389ca2ee0 Added file size checking 2011-12-18 18:29:43 +00:00
aefo 4ff26d0a85 Added getContentsLength method 2011-12-18 18:29:02 +00:00
aefo e9a62c9a48 Added support for "ls -ltr" to allow sorting & seeing more details in
the listing (so that you can see sizes / modified times)
2011-12-18 18:28:03 +00:00
aefo a66aafa759 Correct compile error 2011-12-18 17:35:10 +00:00
aefo a363b36437 added comment 2011-12-18 17:24:00 +00:00
aefo 612bee5e6b Test too to verify / compare directory & file info between encfs-java
decode & mounted encf volume
2011-12-18 17:22:05 +00:00
aefo bd5a5f1ed8 Created tests for EncFSUtil 2011-12-17 21:31:21 +00:00
aefo b626f36f94 Added test using incorrect password against an encfs volume 2011-12-17 20:59:37 +00:00
aefo 38f77472b8 Added toString for the config 2011-12-17 20:51:47 +00:00
aefo 7a75883ade Fixes for skipping files in the raw FS that aren't encoded with our volume key 2011-12-17 20:47:57 +00:00
aefo f9b021b9f0 Addition of unit tests for the encfs samples 2011-12-17 20:46:56 +00:00
aefo bfb766d1c8 Fix to support read(byte[] output, int offset, int size) method 2011-12-17 20:46:06 +00:00
Mark Pariente 1fb202421f Implemented nameio/stream file name encryption algorithm
This change adds support for nameio/stream mode of filename encryption.
Also as a bonus change it fixes the MAC computation for volumes that
do not use chained name IV.
2011-12-16 01:41:40 -08:00
Mark Pariente 10e86483c6 Add support for uniqueIV = 0
This change adds support for EncFS volume created with a configuration
that doesn't use unique file IV headers.
2011-12-16 00:34:40 -08:00
Mark Pariente 6650a0be3c Support variable size volume keys
Remove hardcoded 32-byte volume key size in EncFSCrypto.decryptVolumeKey
to support volumes with key sizes different than 256 bits. Tested to
work fine with the standard options under encfs 1.7.4 which creates
a volume with a 192-bit key.
2011-12-16 00:29:20 -08:00
Mark Pariente e1bd0bc68d Add EncFSVolume.getConfigFileName()
Added a method to expose the config file name for library users.
2011-12-02 00:02:20 -08:00
Mark Pariente 77031f057a Enable PBKDF2 result caching
Added constructors for EncFSVolume to allow the password-based key
and IV data to be cached, and re-used to create an EncFSVolume for
the same volume at a later time.
2011-11-29 22:37:33 -08:00
Mark Pariente 41ecff532e Un-implement EncFSFileInputStream.read()
On some runtimes the readBlock() implementation ended up recursively
calling into read(byte[]) since the call into super.read(byte[]) gets
reflected back into EncFSFileInputStream resulting into infinite
recursion. As a lame solution, removing read(byte[], int, int) from
EncFSFileInputStream and calling FileInputStream.read(byte[], int, int)
from readBlock().
2011-11-22 22:56:47 -08:00
Mark Pariente 334c6073d7 Remove unused import
Forgot to remove import for javax.xml.bind.DatatypeConverter
from EncFSCrypto.java in the last commit.
2011-11-21 22:32:59 -08:00
Mark Pariente f28612b7a1 Get rid of javax.xml.bind.DatatypeConverter
Bundle Robert Harder's Base64 implementation [1] instead of using
javax.xml.bind.DatatypeConverter to do base64 decoding since
Android doesn't package JAXB.

[1] http://iharder.sourceforge.net/current/index.html
2011-11-19 19:56:02 -08:00
Mark Pariente 2d5b0837d2 Bugfix: use equals() to compare strings 2011-11-19 19:53:09 -08:00
Mark Pariente 91df44286b Initial commit of encfs-java 2011-11-11 00:09:46 -08:00