Dec 142011
 

encfs-comboEncFS fornisce un filesystem criptato in user-space. Funziona senza permessi speciali e utilizza le libreria FUSE ed il modulo del kernel di Linux per fornire l’interfaccia al filesystem. Encfs è un software open source, rilasciato sotto licenza GPL.

Come la maggior parte dei filesystem criptati, EncFS ha lo scopo di garantire la sicurezza contro gli attacchi off-line, cioè quando il vostro notebook o backup cade nelle mani sbagliate, ecc Il modo in cui EncFS opera è diverso da quello del supporto “loopback” per i filesystem criptati, integrato nel kernel di Linux perché funziona su un file alla volta, non un dispositivo di blocco intero. Questo è un grande vantaggio per alcuni versi, ma non arriva senza un costo.


filesystem Pass-through vs encrypted block device

Il progetto dei filesystem pass-through non è una novità per i filesystem criptati. EncFS è modellato su CFS – il Filesystem originale cigrato di Matt Blaze, pubblicato nel 1993. Nel corso degli anni, altri filesystem hanno esteso le idee alla base di CFS in modi diversi (come TCFS nel 1996). Come parte di questa famiglia di filesystem, EncFS condivide la stessa forza di base e le debolezze rispetto ai dispositivi di cifratura a blocchi:

Pro

  • Dimensioni: un file system vuoto encfs è composto da qualche dozzina di byte e può crescere a qualsiasi dimensione senza bisogno di essere riformattato. Con un dispositivi di cifratura a blocchi, si alloca un filesystem in anticipo con le dimensioni desiderate.
  • Backup automatici: un filesystem EncFS può essere salvato con una politica per file. Un programma di backup è in grado di rilevare quali file sono cambiati, anche se non sarà in grado di decifrarli.
  • Stratificazione/Separazione di fiducia: encfs può essere messo in cima ad altri filesystem al fine di aggiungere la crittografia a file system non cifrati.

Contro:

Meta-dati: meta-dati rimangono visibili a chiunque abbia accesso ai file crittografati. Così può conoscere alcune informazioni su di loro:

  • Il numero di file che sono criptati
  • I permessi dei file (leggibile, scrivibile, eseguibile)
  • La dimensione di ogni file
  • La dimensione approssimativa di ogni nome di file

Per maggiori informazioni guardare l’Introduzione nella pagina ufficiale di EncFS

INstallazione

Questi sono i requisiti di encfs:

  1. FUSE: 2.6 o più recente per le ultime versioni di encfs
  2. rlog: una libreria C++, per i log
  3. OpenSSL – versioni 0.9.6 fino a 0.9.8 sono state testate
  4. boost: libreria C++ di utilità 1.34 o successiva

Ho testato EncFS su Ubuntu 11.10, in questa distribuzione il software è disponibile come pacchetto, quindi per installarlo ho usato da terminale il comando aptitude install encfs che ha installato anche tutte le dipendenze corrette:

root@xubuntu-home:~# aptitude install encfs
 
The following NEW packages will be installed:
  encfs libboost-filesystem1.46.1{a} libboost-serialization1.46.1{a} libboost-system1.46.1{a} librlog5{a} 
0 packages upgraded, 5 newly installed, 0 to remove and 9 not upgraded.
Need to get 659 kB of archives. After unpacking 3,109 kB will be used.

Basic Usage

1. create una directory. Nel filesystem che si desidera utilizzare creare una directory dove i file criptati saranno memorizzati
In questo esempio ho messo la mia dir nella mia home, ma si può mettere dove si vuole.

mkdir ~/encrypted

2. Create un mountpoint
Questa è la directory dove si monterà la directory criptata. Attraverso questo percorso è possibile accedere ai file cifrati.

mkdir ~/temp_encr

3. Create il sistema cifrato e montatelo
La prima volta che si tenta di montare la directory, encfs creerà il file system cifrato, chiedendo alcune informazioni ed una password. Ho scelto l’opzione standard con una riga vuota.
Funziona come un mount regolare:

encfs "folder to mount" "mount point"

Quindi per questo esempio:

encfs /home//encrypted /home//temp_encr
 
Creating new encrypted volume.
Please choose from one of the following options:
 enter "x" for expert configuration mode,
 enter "p" for pre-configured paranoia mode,
 anything else, or an empty line will select standard mode.
?> 
 
Standard configuration selected.
 
Configuration finished.  The filesystem to be created has
the following properties:
Filesystem cipher: "ssl/aes", version 3:0:2
Filename encoding: "nameio/block", version 3:0:1
Key Size: 192 bits
Block Size: 1024 bytes
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File holes passed through to ciphertext.
 
Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism.  However, the password can be changed
later using encfsctl.
 
New Encfs Password: 
Verify Encfs Password:

Notare che encfs vuole percorsi assoluti, i.e.che iniziano con /


4. Cifrate i vostri file Ora si può mettere i file nella directory ~/temp_encr e guardare nella cartella ~/encrypted: in questa seconda cartella mostrerà i file cifrati.

Tutto funziona come sempre nella directory ~/temp_encr

linuxaria@xubuntu-home:~$ echo "this is my EncFS test" > temp_encr/test.txt
 
linuxaria@xubuntu-home:~$ ls -l ~/temp_encr/test.txt
-rw-rw-r-- 1 linuxaria linuxaria 22 2011-12-14 00:08 /home/linuxaria/temp_encr/test.txt
 
linuxaria@xubuntu-home:~$ cat ~/temp_encr/test.txt
this is my EncFS test

Ma se smontate il filesystem con il comando:

fusermount -u /home/linuxaria/temp_encr

Avrete ora solo la directory ~/encrypted che, come previsto, contiene tutte le informazioni cifrate, ed i metadati.

linuxaria@xubuntu-home:~$ ls -la encrypted/
total 16
drwxrwxr-x   2 linuxaria linuxaria 4096 2011-12-14 00:08 .
drwx------ 109 linuxaria linuxaria 4096 2011-12-13 23:55 ..
-rw-rw-r--   1 linuxaria linuxaria 1076 2011-12-13 23:56 .encfs6.xml
-rw-rw-r--   1 linuxaria linuxaria   30 2011-12-14 00:08 NOQUHJDpKw4XkS,THEb5OF,8
linuxaria@xubuntu-home:~$ cat encrypted/.encfs6.xml 
< ?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
< !DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="9">
<cfg class_id="0" tracking_level="0" version="20">
	<version>20100713</version>
	<creator>EncFS 1.7.4</creator>
	<cipheralg class_id="1" tracking_level="0" version="0">
		<name>ssl/aes</name>
		<major>3</major>
		<minor>0</minor>
	</cipheralg>
	<namealg>
		<name>nameio/block</name>
		<major>3</major>
		<minor>0</minor>
	</namealg>
	<keysize>192</keysize>
	<blocksize>1024</blocksize>
	<uniqueiv>1</uniqueiv>
	<chainednameiv>1</chainednameiv>
	<externalivchaining>0</externalivchaining>
	<blockmacbytes>0</blockmacbytes>
	<blockmacrandbytes>0</blockmacrandbytes>
	<allowholes>1</allowholes>
	<encodedkeysize>44</encodedkeysize>
	<encodedkeydata>
qmJ1Qryid2K0X0TDptjghpoXE+tWJS2Lpq3SImu9onGr5ilNznj7SSaNMlg=
	</encodedkeydata>
	<saltlen>20</saltlen>
	<saltdata>
FxULrGb/Zx9mqOOh/QzaEz6JNV8=
	</saltdata>
	<kdfiterations>39114</kdfiterations>
	<desiredkdfduration>500</desiredkdfduration>
</cfg>
</boost_serialization>
 
linuxaria@xubuntu-home:~$ cat encrypted/NOQUHJDpKw4XkS,THEb5OF,8 
�͒���< ��_B|"?��G��-./t+�

Mentre è montato è anche possibile vedere questo nuovo “file system” con un comando df :

linuxaria@xubuntu-home:~$ df -h /home/linuxaria/temp_encr
Filesystem            Size  Used Avail Use% Mounted on
encfs                 8.9G  7.8G  656M  93% /home/linuxaria/temp_encr

Conclusioni

Questa soluzione può essere molto utile per cifrare solo una o alcune directory del filesystem.
Una buona idea potrebbe essere utilizzare questa soluzione con le directory in “cloud” come Ubuntu One o Dropbox, così avrete le informazioni salvate in rete .. ma criptate.

Popular Posts:

Flattr this!

  8 Responses to “Introduzione a EncFS Encrypted Filesystem”

  1. I see no advantages over the standard LVM+LUKS/dm-crypt care to tell us why one would want to use EncFS under any circumstance?

    • To just Encrypt one directory in a filesystem ?

    • For me, EncFs works fantastically with sync programs like DropBox or even lsyncd compared to encrypted volumes; I love it in combination with “cryptkeeper”.

      • hmm I wonder how well dm-crypt would work with DropBox in comparison;

        dd if=/dev/zero of=/media/dropbox/cryptfile bs=1024 count=2097152
        losetup /dev/loopdropbox /media/dropbox/cryptfile
        raw /dev/raw/rawdropbox /dev/loopdropbox
        cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/loopdropbox
        cryptsetup luksOpen /dev/loopdropbox crypt_dropbox
        mkfs.ext4 /dev/mapper/crypt_dropbox
        tune2fs -m 0 /dev/mapper/crypt_dropbox
        mount /dev/mapper/crypt_dropbox /media/cryptbox

        maybe someone who uses DropBox will know

        • Whoops, meant to reply to this comment with my last post, but here ya go:

          Your biggest difference is when you open the encrypted data from more than one location at the same time (mount on my laptop at home and at work)…. encfs still treats the files as separate individuals so you don’t bump into “merge conflicts” like you would on an encrypted volume because only the single files would be modified, not the entire volume (from the POV) for every change which would cause some nasty problems with Dropbox..
          Basically when Dropbox detects a change from both sides on a single file, it creates a new set of duplicate files so you can handle the merge manually later, with an encrypted volume, that would SUCK 🙂 .

  2. Your biggest difference is when you open the encrypted data from more than one location at the same time (mount on my laptop at home and at work)…. encfs still treats the files as separate individuals so you don’t bump into “merge conflicts” like you would on an encrypted volume because only the single files would be modified, not the entire volume (from the POV) for every change which would cause some nasty problems with Dropbox..
    Basically when Dropbox detects a change from both sides on a single file, it creates a new set of duplicate files so you can handle the merge manually later, with an encrypted volume, that would SUCK :).

    • Thanks for your article. I too have been curious about the difference between this and LUKS. I’ve seen a lot of FIPS standard encryption requests coming down the pipe, not enabled on Linux by default. I’ve been enabling FIPS and using LUKS for my devices. Will this work in the same way?
      e.g. when using LUKS

      [root@centos64]# cryptsetup –verbose –verify-passphrase luksFormat /dev/vgtest/testlv

      WARNING!
      ========
      This will overwrite data on /dev/vgtest/testlv irrevocably.

      Are you sure? (Type uppercase yes): YES <– type in "YES"
      Enter LUKS passphrase:
      Verify passphrase:
      Running in FIPS mode.
      Command successful.
      [root@centos64]#

      That "running in FIPS mode" will appear if I have FIPS enabled, otherwise not. It's a nice confirmation for customers that what we are doing with our encryption is following their request.

      Thoughts?

Leave a Reply to Jimmy Cancel reply

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

(required)

(required)

*