Giter VIP home page Giter VIP logo

knoxcrypt's Introduction

KnoxCrypt (formerly TeaSafe): An encrypted filesystem

What is it?
  • A tool for creating and browsing encrypted 'boxes' of data; similar to Truecrypt.
  • Supports lots of ciphers including AES-256.
  • Utilizes a million iterations of PBKDF2 for key derivation. Seems like a big number but probably overkill.
  • Can create sparse containers.
  • Sub-volume capability.
What's with the name?

The name has stuck for historical reasons: a very early version used the XTEA cipher for encryption. I think the project could do with a better name though. Let me know if you have any suggestions. I renamed the project to knoxcrypt.

Caveats

KnoxCrypt is highly developmental and therefore probably buggy. I make no guarentees as to the integrity of stored data. Neither do I guarantee 100% data security. Having said that, if you're happy with the strength of AES-256 in CTR mode and with a key that has been derived using quite a few rounds of PBKDF2, then I think it should be fine. Take that as you will.

Compiling

Note, only tested on Linux and Mac. With a bit of work, will probably build (sans fuse-bits) on windows too.

Requirements:

  • some of the boost headers and libraries to build (see makefile).
  • fuse for the main fuse layer binary (the binary 'knoxcrypt')
  • crypto++ headers and libraries for building and linking
  • cryptostreampp, a small set of headers allowing straight forward implementation of encrypted file streams (see https://github.com/benhj/cryptostreampp). This is now a submodule and is automatically grabbed when cloning knoxcrypt recursively.

First grab the source by cloning recursively:

git clone --recursive https://github.com/benhj/knoxcrypt

If you don't have fuse installed, you'll probably want to only build the main knoxcrypt library (libknoxcrypt.a), the shell (teashell) and makeknoxcrypt, the binary used to make knoxcrypt containers. To build these, respectively:

make lib
make shell
make makeknoxcrypt

Note that building either of the binaries teashell or makeknoxcrypt will automatically build libknoxcrypt.a first.

make or make all will compile everything, i.e., the following binaries:

test           : unit tests various parts of the main api
makeknoxcrypt  : builds knoxcrypt containers
knoxcrypt      : fuse layer used for mounting knoxcrypt containers
teashell       : shell utility used for accessing and modifying knoxcrypt containers

To build a KnoxCrypt container that uses AES256, with 4096 * 128000 bytes, use the makeknoxcrypt binary:

./makeknoxcrypt ./test.bfs 128000

For alternative ciphers, use the --cipher flag, e.g.:

./makeknoxcrypt ./test.bfs 128000 --cipher twofish

The available cipher options are aes, serpent, cast256, rc6, twofish, mars, camellia, rc5, shacal2 and null. Update 30/5/15: There are quite a few more than that these days. Have a look at the cryptostream headers if you're so inclined.

Note that null disables encryption and thus provides no security. The default is aes.

Sparse containers can also be created, growing in size as more data are written to them. Just use the --sparse flag during creation, i.e.:

./makeknoxcrypt ./test.bfs 128000 --sparse 1

Now to mount it to /testMount via fuse, use the knoxcrypt binary:

./knoxcrypt ./test.bfs /testMount

Runs the interactive shell on it using the teashell binary:

./teashell ./test.bfs

Licensing

KnoxCrypt follows the BSD 3-Clause licence.

knoxcrypt's People

Contributors

benhj avatar hasufell avatar petrm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

knoxcrypt's Issues

Move to using one TeasafeImageStream

Currently, whenever the underlying image needs to be accessed, it creates a local image stream. Consequently, it needs to seek to the correct position each time. When reading from and writing to files, this amounts to one hulluva amount of seeking

CLI to allow accessing image without requiring FUSE

Currently, to access an image and inspect its contents, addition and removal of content etc. all require using FUSE. However, it is also feasibly possible to treat the teasafe image like any container format (zip, rar etc.). A simple CLI application could be easily implemented to do just that. It might feature a simple menu to

(i) list contents
(ii) copy file
(iii) remove file
(iv) create folder

etc...

GUI

In a similar way to having a CLI to inspect the image's content, attempt to implement a GUI (similar to what any Zip management application (e.g. WinZip) typically does).

Use a better IV

Consider using a mersenne twister PRNG for generating the IV; should be a relatively straight forward addition. Support in both C++11 and boost

Faster bit map lookup

E.g. this allocator code:

int64_t bmp_alloc(uint64_t *bmp, int64_t slots){
  // search for the first 0 bit, set it to 1,
  // then return the slot
  // return -1 if nothing found
  slots /= 64; // checking 64 slots at a time
  for (int64_t loop = 0; loop < slots; loop++){
    if (*bmp == 0xFFFFFFFFFFFFFFFFLL){
      // this area is full, go to the next area
      bmp++;
      continue;
    }
    // we're guaranteed at least one bit is 0
    int pos = ffsll(~*bmp) - 1;
    *bmp |= 1LL << pos; // set the bit at pos
    return loop * 64 + pos;
  }
  return -1;
}

From http://syntheti.cc/article/kongs-garbage-collector/

Could be similarly used to do far quicker bitmap lookup. Presently, I'm checking bit by bit

Teasafe will not compile on Linux.

There are some issues with the source code that mainly involve cstring or string.h not being included for the definition of functions like memcpy() and strlen(). I was able to resolve the compilation issues by including the needed header. Also the flags in the makefile needed a slight adjustment for fuse. I have made a patch that resolves the problem. How may I send it to you?

CLI to add additional sub-volumes

Currently, adding a sub-volume to a teasafe image is only possible at the time of image creation. It is feasibly possible however to take a pre-existing image and add a new sub-volume to it.

Add multiple partition capability

Since the root of the filesystem is determined by the root folder, we can potentially mount any folder inside of the bfs image as the root folder. This opens up the possibility of having multiple partitions within the same image and allowing the user to choose the partition when mounting the fs image.

Prefer XTS mode over CTR

Unless I switch from using crypto++ to something different, this will have to wait until crypto++ supports it.

Some security concerns

It's great that you are interested in cryptography, but please do some reading before you actually implement a program which does encryption.

"is this key-gen secure? probably not...use at own risk"
Nope, state of the art software uses special key derivation algorithms to prevent brute force attacks via specialized hardware.
So use something like scrypt or bcrypt to prevent a potentially powerful attacker from simply brute forcing the key.

I didn't look too closely, but it seems that your XTEA implementation is potentially vulnerable to a timing side channel attack.
Please use a library like nacl to avoid implementation based attacks.

Could you please provide some more documentation on how the data is stored on disc? There have been attacks where a vulnerable cipher mode was used to inject a backdoor.
It looks like you are using CTR, which isn't vulnerable to this attack, however the layout of your file system is nevertheless critical in regards to meta data leakage.

Problem after recursively deleting content and then trying to add new content

Strange behaviour; steps to reproduce --

(i) recursively copy content to a newly created image
(ii) recursively delete it,
(iii) create a new sub folder
(iv) cd into the new sub folder.
(v) attempt to recursively copy content in to the newly created sub folder

Step (v) results in a freeze; subsequently killing the teasafe process and re-mounting the image then appears to be impossible. Suggests that there is a problem with how entries are deleted and subsequently cleared after deleting (inc. metadata) all of which appears to secondarily corrupt the image

Move operation not working properly

Entries can be moved from one folder to another but not inside of the same folder. Not sure why. An entry metadata retrieval runtime error is thrown when attempting to do so

creating folder in root dir broken

If a root folder is created before anything else, it self-references itself in a very weird recursive manner.

If something else is created first, then every other folder seems to be fine

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.