Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Loopback Encrypted Filesystems Mini-HOWTO

0 views
Skip to first unread message

Ed Blackman

unread,
Apr 10, 2003, 5:45:16 PM4/10/03
to
With the inclusion of the CryptoAPI support in recent distribution
kernels, creating encrypted filesystems is much simpler than it has been
in the past, but still requires a few patches to userspace tools, and
some additional setup. I created this document as a personal "howto",
but was encouraged to post it publically by some friends I shared it
with.

Please note:
- This document assumes you're capable of system admin tasks, and
basic development tasks, like patching and compiling.
- The commands listed below assume you're creating an EXT3 filesystem
with AES encryption (256 bit key, SHA512 digest) on /dev/sdc1, to be
mounted on /crypted. If that's not exactly what you want to do,
you'll need to change some of the commands as appropriate. Cutting
and pasting the commands without understanding what they do and
changing them as necessary to fit your system can lead to data loss.
You have been warned.
- If you forget the password to your encrypted filesystem, that's it,
game over, the data on that filesystem is gone. On the other hand,
if it's easy to guess, or you write it down some place easy to get
to, then you might as well avoid all the trouble and just leave your
data unencrypted.
- Encryption only protects your data when the filesystem is *not*
mounted. When it is mounted, if someone can walk up to your desk
and start reading your files, or if someone hacks in, they might not
even notice that you have an encrypted filesystem.

Instructions:

- Ensure kernel supports crypto
- Redhat 8.0 and 9 includes this support out of the box, and recent RH7.3
(and possibily 7.2 and earlier) errata kernels have added it
- TODO: add info for other distributions
- RH only comes with AES, presumably because of US export restrictions.
- TODO: add info for other distributions
- "modprobe cryptoloop; modprobe cipher-aes"
- If you get a message that a module couldn't be loaded, your
current kernel doesn't have cryptoapi support. Otherwise, run
"lsmod" to ensure they're loaded.


- Add other ciphers (optional)
- If you're paranoid and think that the only reason the US government
is OK with AES is because they secretly know how break it, you may
want to compile another cipher and use it instead.
- TODO: create compile/install instructions for other ciphers
- http://tinyurl.com/7c4l

- Add crypto support to mount and losetup
- Download RH9 util-linux SRPM
http://tinyurl.com/998z/util-linux-2.11y-9.src.rpm
- Install SRPM (you'll need to be root if you don't have a non-root
RPM build configuration already in place)
- follow instructions here:
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=81574#c6
- Upgrade to the util-linux, mount, and losetup RPMs produced
- Hopefully my patches for the RedHat util-linux will be accepted, and
this won't be necessary in the future. If you'd like to see this
done, you should add yourself to the CC list of the Redhat bug
above, and maybe add a comment that my patch worked for you
(requires having a Redhat Bugzilla account).
- TODO: add info for other distributions

- Fill target device (eg, /dev/sdc1) with random bits
- Not strictly necessary, but strongly recommended. What this does is
write random bits to the device, so that when we later write
random-looking bits on top (the encrypted filesystem and the files
in it), an attacker won't be able to get any information just by
looking at the raw data on the device. Look at the third and fourth
figures at http://www.kerneli.org/howto/node3.php for an
illustration.
- "dd if=/dev/urandom of=/dev/sdc1 bs=1M"

- Create filesystem
- "losetup -e aes -k 256 -P sha512 /dev/loop0 /dev/sdc1"
- "-e aes" means use AES as the cipher. "-e xxx" requires the
module "cipher-xxx" to be loaded.
- "-k 256" means use a 256 bit key. Omit this parameter to be
prompted for a valid keysize, which varies for different ciphers.
- "-P sha512" means use the sha512 hash function. "man losetup" for
other options. Omitting this parameter causes the rmd160old
hash function to be used.
- You will be prompted for password: password should be at least 10
characters and contain upper and lower case letters, numbers, and
special characters
- "mkfs.ext3 /dev/loop0"
- "losetup -d /dev/loop0"

- Create mount point
- "mkdir /crypted"

- Set up fstab
- "/dev/sdc1 /crypted ext3 defaults,noauto,encryption=aes,keybits=256,phash=sha512 0 0"
- encryption, keybits, and phash must match the values you provided
to losetup for -e, -k, and -P, respectively, above. If you used the
default rmd160old phash above, you can omit the phash parameter
- noauto is *strongly* suggested, since otherwise the system will try
to mount it on boot, and the boot process will come to a stop as it
waits for you to enter the password

- Mount the encrypted filesystem
- "mount /crypted"
- you will be prompted for password

- Make sure that the crypto modules will be loaded on the next boot
- As root:
"echo 'modprobe cryptoloop; modprobe cipher-aes' >> /etc/rc.local"

- Now that your evil plans are secure from prying eyes, laugh
maniacally as you contemplate your next step toward world
domination!

Revision History:
- EBB 20030410 - Updated for RH9
- EBB 20030403 - Cleaned up for public distribution, added TODO
sections for RH9
- EBB 20030312 - Cleaned up for distribution to friends
- EBB 20030305 - Created as personal howto

0 new messages