Commit Graph

190 Commits (dev)

Author SHA1 Message Date
Lars Gohlke 3c971a0476 inlined some var declaration 2013-02-17 12:58:52 +01:00
Lars Gohlke 662cf9652a used methods from jdk to create byte arrays from int and long 2013-02-17 12:58:16 +01:00
Mark Pariente 50c4ca3b3f Fix bad input handling in EncFSBase64.decodeEncfs()
Since java treats the byte type as signed when used as an array index it
is possible for values >= 128 to cause ArrayIndexOutOfBoundsException.
Fix handling in EncFSBase64.decodeEncfs() to not crash with such bad
input.
2013-01-30 23:23:16 -08:00
Joscha Feth 2baa3380d1 fix c&p typo 2013-01-20 02:49:58 +01:00
Mark Pariente 09c7dcebc4 Fix crash in EncFSLocalFileProvider.listFiles()
Handle the case where the given path is not a directory by throwing an
IOException. Previously this would result in a NullPointerException.
2012-12-27 15:14:45 -05:00
Mark Pariente f02bca7e9e Custom PBKDF2 provider implementation 2012-11-19 01:10:52 -08:00
Mark Pariente 3c91144609 Move test classes into their own namespace 2012-10-14 22:10:50 -07:00
Mark Pariente 1400864304 Add volume integration test for externalIvChaining 2012-10-14 17:17:35 -07:00
Mark Pariente ac206ef549 Validate config dependencies for externalChainIv
UniqueIV and ChainedNameIV are required for externalChainIV.
2012-10-14 17:17:35 -07:00
Mark Pariente 9077078751 Add copy/move support using externalIvChaining 2012-10-14 17:17:35 -07:00
Mark Pariente 7ca1633809 Add support for externalIvChaining in EncFS{Input|Output}Stream
This commit implements support for externalIvChaining in
EncFSInputStream and EncFSOutputStream which causes a file's volume path
to change the initialization vector (IV) which is used for encrypting
and decrypting the file contents.
2012-10-14 16:59:32 -07:00
Mark Pariente e007337167 Remove stale comment in EncFSConfigWriter 2012-10-08 23:36:06 -07:00
Mark Pariente 6616b322b7 Volume creation support in EncFSShell 2012-10-08 23:28:41 -07:00
Mark Pariente b18c762bcb Recursively delete directories in EncFSLocalFileProvider
EncFSLocalFileProvider.delete() was only deleting a directory if it was
completely empty. It is more functional to just recursively delete
everything under a directory if its not empty.
2012-09-16 19:41:23 -07:00
Mark Pariente 6181b6ebdb Forgot to remove debugging logs 2012-08-26 03:22:54 -07:00
Mark Pariente dd91907833 Implement versioning support 2012-08-26 03:13:25 -07:00
Mark Pariente ffeb63e733 Fix return types for input/output stream functions 2012-08-26 00:32:44 -07:00
Mark Pariente 08dfe3d7ad Fix return types for EncFSFile.open{Input|Output}Stream
These methods were returning InputStream/OutputStream instead of the
more specific EncFSInputStream and EncFSOutputStream.
2012-08-26 00:08:54 -07:00
Mark Pariente dbda446205 Fix warning and add attribution in EncFSBase64 2012-08-23 00:06:23 -07:00
Mark Pariente b8a8f3dc6f Use Filter{Input|Output}Stream in stream classes
* EncFSFileInputStream now extends FilterInputStream
* EncFSFileOutputStream now extends FilterOutputStream
* EncFSInputStream now extends FilterInputStream

EncFSOutputStream was already using FilterOutputStream.
2012-08-22 23:53:19 -07:00
Mark Pariente e80d4abac3 Catch EncFSException in EncFSShell 2012-08-22 23:31:41 -07:00
Mark Pariente c645cc1897 Create EncFSException and subclass exceptions to it 2012-08-22 23:23:02 -07:00
Mark Pariente 808eb37c91 Fail to create volume if externalIVChaining=1 2012-08-22 23:13:27 -07:00
Mark Pariente 83cf5d0d2d Fix CRLF usage
Unfortunate to have to do this, but with the new version of git diff
explicitly showing CRLF as ^M this was starting to get annoying. We
shall use Unix newline style in encfs-java going forward.
2012-08-22 23:08:00 -07:00
Mark Pariente cdcd5923e8 Implement unencrypted filename support (nameio/null)
BoxCryptor uses an unencrypted name algorithm to encrypt file contents
without encrypting filenames. This change implements this algorithm
and adds a unit test. Thanks 1jr for requesting this and providing
test cases.

Also added a volume integration test for this algorithm.
2012-08-14 00:46:32 -07:00
Mark Pariente dc7d4836f3 Don't treat uniqueIV differently in EncFSFile.copy
uniqueIV just generates a bunch of random bytes in the file header so
we can use fileProvider.copy() which is more efficient for most file
providers rather than doing a full stream read/write copy.
2012-08-03 02:01:10 -07:00
Mark Pariente cd75f18bb4 EncFSVolumeIntegrationTest shouldn't depend on file ordering 2012-07-22 19:06:07 -07:00
Mark Pariente e8bf978fb4 Switch file ordering for volume integration test 2012-07-14 15:52:21 -07:00
Mark Pariente 3214ebc711 Eclipse formatting (whitespace fixes) 2012-06-25 22:28:17 -07:00
Zdenek Farana 4e84fe6ad8 Polymorphic isEncFSVolume methods for File and EncFSFileProvider 2012-06-25 23:52:39 +02:00
Zdenek Farana ce6b9c4417 Simple method for checking if the provided path contains EncFS volume by detecting EncFS config file 2012-06-25 23:34:06 +02:00
Mark Pariente 4a08de9e25 Fix test failures in EncFSVolumeIntegrationTest 2012-06-13 02:16:30 -07:00
Mark Pariente 03c1814aa9 Handle partial reads in EncFSInputStream.readBlock()
With network based file providers it is possible for the input stream's
read() function to return before reading a full block. The current code
treated such partial reads incorrectly by using stream decoding to
decode them. Fix is to keep reading until we either read a full block
or we hit the end of the input stream.
2012-06-01 01:23:53 -07:00
Mark Pariente 84b8726b8c Fix whitespace formatting 2012-05-29 19:56:39 -07:00
michael1 869038b179 EncFSShell now supports files / path with spaces, if they are quoted.
Example: cat "this is a test file with quotoes"
2012-05-29 22:15:19 +03:00
Mark Pariente d1dcd79036 Add a test for file length calculations
Testing for EncFSVolume.getEncryptedFileLength() and
EncFSVolume.getDecryptedFileLength()
2012-05-24 20:21:40 -07:00
Mark Pariente 7a370eb704 Make EncFSFileOutputStream take a length parameter
Unfortunately some network storage systems such as Dropbox require
length of the file before opening an upload request so we need to
plumb file length all throughout the OutputStream creation. It is
optional for EncFSLocalFileProvider, but it is good practice to
supply this parameter whenever possible.
2012-05-24 20:21:31 -07:00
Mark Pariente 412d62e2e9 Remove stale code from EncFSLocalFileProvider
This code was causing double leading slashes in front of directories
and did not have any noticable benefits, tests pass without it.
2012-05-21 02:12:02 -07:00
Mark Pariente 80ffa6a78e Add EncFSProgressListener to monitor operation progress
copyPath() movePath() and deletePath() now take an optional
EncFSProgressListener in order to post progress events. This is useful
for displaying progress of long running operations.
2012-05-19 04:11:38 -07:00
Mark Pariente 18cdf3b477 Fix stream name decoding with chained name IV
Stream name decoding with chained name IV was broken because chained
name IV computation was unconditionally padding each path element
whereas that should only be done for block name I/O algorithm. Fix
uses each path element as is for chained IV computation with stream
name algorithm.

Also added an integration test case containing a volume created with
encfs 1.7.4 that uses stream name algorithm and chained name IV
with a directory and a test file in that directory to exercise the
path that fails without this commit.
2012-04-29 01:49:34 -07:00
Mark Pariente afea85bf68 Implement EncFSFileProvider.getRootPath() 2012-04-28 01:49:21 -07:00
Mark Pariente c50de9fdd3 Implement separator interface for EncFSFileProvider 2012-04-28 01:39:33 -07:00
Mark Pariente 6849feb613 Use constants instead of "/" for volume paths 2012-04-27 23:37:46 -07:00
Mark Pariente 59b860cf92 Rename EncFSVolume constants to shorter versions 2012-04-27 23:31:21 -07:00
Mark Pariente 9a6cfa4ec4 Use combinePath() and ENCFS_VOLUME_PATH_SEPARATOR 2012-04-27 23:24:24 -07:00
Mark Pariente e21c9b8538 Add EncFSFile.combinePath() methods to combine paths 2012-04-27 22:41:51 -07:00
Mark Pariente 8c56794273 copyPath() and movePath() prevents overwriting existing files 2012-04-26 00:20:51 -07:00
Mark Pariente f9308bff4b EncFSVolume.copyOrMovePath() fails for srcPath == dstPath 2012-04-25 23:47:15 -07:00
Mark Pariente 3b5510aab8 Fix '/' path handling in EncFSShell.getPath() 2012-04-25 23:42:09 -07:00
Mark Pariente afa7b1e884 EncFSShell allows moving files/dirs into an existing dir 2012-04-25 23:42:09 -07:00
Mark Pariente f9a97aafe5 EncFSVolume.movePath() allows moving into existing dirs
Previous implementation didn't work if dstPath was an existing
directory, fix the implementation to move srcPath under dstPath
if dstPath exists and is a directory.
2012-04-25 23:42:09 -07:00
Mark Pariente 5fa007932e Avoid duplicate leading "//" in EncFSShell copy 2012-04-25 23:42:09 -07:00
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