Giter VIP home page Giter VIP logo

ext4-crypt's Introduction

ext4-crypt

Linux kernel 4.1 introduced native encryption for the ext4 filesystem.

This is a userspace tool to manage encrypted ext4 directories.

Warning: this kernel feature is very unstable and experimental at the moment. I managed to crash my kernel (4.1.2) a few times very easily just by playing with it.

Usage

Encrypting a new directory

The target directory must be empty.

$ mkdir vault
$ ext4-crypt create vault
Enter passphrase:
Confirm passphrase:
vault: Encryption policy is now set.

$ ext4-crypt status vault
Policy version:   0
Filename cipher:  aes-256-cts
Contents cipher:  aes-256-xts
Filename padding: 4
Key descriptor:   qC6PCZsF
Key serial:       351198062

Unlocking an encrypted directory

$ ls vault
FTRsD7y2dUyXl6e8omKYbB  IdLqPffZBKSebTeh6hZI7C  tReYAc2tKyIOHSIcaSV2DB

$ ext4-crypt attach vault
Enter passphrase: 

$ ls vault
fstab  passwd  services

Install

cmake .
make
sudo make install

Distribution packages could be provided later if deemed useful.

Requirements

Linux kernel 4.1+ with support for CONFIG_EXT4_ENCRYPTION.

Limitations

There is no key verification !

So basically, any passphrase you provide will be accepted, but you'll get junk if you provide the wrong key. This is currently a limitation of the kernel implementation.

Cannot choose cipher

Cipher is hardcoded to be AES-256-XTS for data and AES-256-CTS for filenames. More ciphers will probably be available in future kernel versions.

You cannot permanently decrypt a directory

The encryption policy is stored at the inode level and cannot be removed from userspace. You'll need to provide the right key and copy the data to another directory if you want to remove the encryption.

Plaintext filenames still appear after detaching the key

That is a kernel issue. The dentries cache is not invalidated when you remove the key and still contains the plaintext filenames.

You must remount the device or force a filesystem cache flush with:

# echo 2 > /proc/sys/vm/drop_caches

Dependencies

ext4-crypt's People

Contributors

neuhaus avatar weary 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ext4-crypt's Issues

"This filesystem does not support encryption"?

Hello,

Firstly, it is unclear whether the directory passed to "ext4-crypt create" needs to already exist. The expectation from a function named "create" is that it does not have to (and will be created by the tool), but apparently not so?

Secondly, it does not work at all even if I create the directory manually.

# ext4-crypt create test
Cannot get filesystem information for test: No such file or directory
Error: test does not belong to an ext4 filesystem.

# mkdir test

# ext4-crypt create test
This filesystem does not support encryption.
Please ensure your kernel has support for CONFIG_EXT4_ENCRYPTION.

# uname -a
Linux hostname 4.9.39-rm1+ #16 SMP Fri Jul 21 15:24:03 +05 2017 x86_64 GNU/Linux

# grep CONFIG_EXT4 /boot/config-4.9.39-rm1+ 
CONFIG_EXT4_FS=m
CONFIG_EXT4_USE_FOR_EXT2=y
CONFIG_EXT4_FS_POSIX_ACL=y
CONFIG_EXT4_FS_SECURITY=y
CONFIG_EXT4_ENCRYPTION=y
CONFIG_EXT4_FS_ENCRYPTION=y
# CONFIG_EXT4_DEBUG is not set

Kernel 4.4 cannot create inode in directory

root@:/project/ext4-crypt# mkdir vault
root@:/project/ext4-crypt# ./ext4-crypt create vault
Enter passphrase:
Confirm passphrase:
Cannot create inode in directory: Operation not permitted

f2fs support

f2fs supports the same ioctl() for encryption as ext4, so please add support for this filesystem too. Actual code change is simple:

EXT4_KEY_DESC_PREFIX should be changed from "ext4:" to "f2fs:"

But you also need some user interface change to allow select filesystem.

compile error

/usr/lib/gcc/arm-linux-gnueabihf/4.9/../../../libscrypt.so: undefined reference to `log'
collect2: error: ld returned 1 exit status
CMakeFiles/ext4-crypt.dir/build.make:146: recipe for target 'ext4-crypt' failed
make[2]: *** [ext4-crypt] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/ext4-crypt.dir/all' failed
make[1]: *** [CMakeFiles/ext4-crypt.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

REQ: built the drop_caches into the tool

After most operations, I need to do echo 2 >/proc/sys/vm/drop_caches otherwise filesystem operations are misleading/incorrect. Can't this operation just be built in? I can't think why people would not want to do this when they're using this (except debugging perhaps?)

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.