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

loopback encryption - reliability

1 view
Skip to first unread message

Nomen Nescio

unread,
Oct 11, 2002, 6:30:08 AM10/11/02
to

Anyone using loopback encryption?, I just started using it
but wonder about it's reliability. I'm using it on two
partitions at the moment, docs found seem very much out
of date with limited info/data, some seems just to apply
to other linux's. If you have a fault develop ie power
goes down how does one check the filesystem? you dont
seem to be able to use fsck, so if anyone has any
experience of using loopback any info and experience
would be useful.

Thanks.


--


Simon

unread,
Oct 11, 2002, 2:02:15 PM10/11/02
to
* Nomen Nescio <nob...@dizum.com> wrote:

At first I thought this may be the second coming of 'He Whose Name
Must Not Be Mentioned", but then I saw the post actually showed a bit
of intelligence. Sorry Bozo[tm]s.

> Anyone using loopback encryption?,

Not at the moment, but I intend to one day.

> I just started using it
> but wonder about it's reliability. I'm using it on two
> partitions at the moment, docs found seem very much out
> of date with limited info/data, some seems just to apply
> to other linux's.

Most things like this are generic and, although filenames and tools
mentioned in tutorials may relate to other distributions, it should
also be possible in any distribution.

> If you have a fault develop ie power
> goes down how does one check the filesystem? you dont
> seem to be able to use fsck, so if anyone has any
> experience of using loopback any info and experience
> would be useful.

I just tried fscking a loopback mounted filesystem (initrd.img from
the Slackware CD-ROM, to be precise) and you can fsck it by
specifying /dev/loop?. The only trouble is that it appears you need
to have the filesystem mounted to be able to fsck it.


--
Simon <si...@no-dns-yet.org.uk> **** PGP: 099977D0
"We demand rigidly defined areas of doubt and uncertainty."
- Douglas Adams

/dev/rob0

unread,
Oct 12, 2002, 1:09:36 AM10/12/02
to
In article <7n37oa...@no-dns-yet.org.uk>, Simon wrote:
> * Nomen Nescio <nob...@dizum.com> wrote:
>
> At first I thought this may be the second coming of 'He Whose Name
> Must Not Be Mentioned", but then I saw the post actually showed a bit
> of intelligence. Sorry Bozo[tm]s.

N.N. is an equal opportunity Messiah. Anyone can be Him. :)

>> Anyone using loopback encryption?,

There are 3 main variants: LoopAES, CryptoAPI (a/k/a international
kernel patch), and of course the simple XOR used by the unpatched
losetup of util-linux.

> Not at the moment, but I intend to one day.

I use it somewhat, but not for any permanently-mounted filesystems. My
swap partitions are used as encrypted loop devices. (I use CryptoAPI and
the Twofish algorithm.)

>> I just started using it
>> but wonder about it's reliability. I'm using it on two
>> partitions at the moment, docs found seem very much out

This question sometimes comes up on the Linux-Crypto mailing list. You
can find the archives in a Google search. Personally, I'd hesitate to
use it if there was much chance of unclean shutdowns. If you use it in
such an environment, make regular automated backups!

My own use of encrypted swap is immune to such problems because I have
it regenerate a new random passphrase every time. My swap is secure. I
myself have no way of recovering the passphrases.

>> If you have a fault develop ie power
>> goes down how does one check the filesystem? you dont
>> seem to be able to use fsck, so if anyone has any
>

> I just tried fscking a loopback mounted filesystem (initrd.img from
> the Slackware CD-ROM, to be precise) and you can fsck it by
> specifying /dev/loop?. The only trouble is that it appears you need
> to have the filesystem mounted to be able to fsck it.

No, here is where losetup does the job. You use losetup to link the file
with the loop device, and then fsck the loop device.

If you'd like I can post my swap encryption scripts. those will
illustrate the use of losetup.

--
/dev/rob0 - preferred_email=i$((28*28+28))@softhome.net
or put "not-spam" or "/dev/rob0" in Subject header to reply

Markus Stoeger

unread,
Oct 12, 2002, 3:52:42 AM10/12/02
to
In article <slrnaqfbk...@linuxbox.stpaultel.com>, /dev/rob0 wrote:
> If you'd like I can post my swap encryption scripts. those will
> illustrate the use of losetup.

I'd be interested in them too, please post or mail them.

I remember to have read something in the loop encryption howto about
deadlocks that can happen when you encrypt your swap partition. It went
something like -> system running out of memory -> requesting swap space ->
encryption requiring even more memory -> requesting more swap space ->
and the loop starts over again, causing a deadlock.
Have you noticed/experienced anything like that when you hit memory
limits?

Max

Nomen Nescio

unread,
Oct 12, 2002, 4:20:43 AM10/12/02
to

Simon <use...@no-dns-yet.org.uk> writes:

> * Nomen Nescio <nob...@dizum.com> wrote:
>
> At first I thought this may be the second coming of 'He Whose Name
> Must Not Be Mentioned", but then I saw the post actually showed a bit
> of intelligence. Sorry Bozo[tm]s.

Oh dear here we go, still the same old newsgroup, wont bother reading
anymore, see ya all in another few months, gee bozo's what do you do
with them?.

>
> > Anyone using loopback encryption?,
>
> Not at the moment, but I intend to one day.
>
> > I just started using it
> > but wonder about it's reliability. I'm using it on two
> > partitions at the moment, docs found seem very much out
> > of date with limited info/data, some seems just to apply
> > to other linux's.
>
> Most things like this are generic and, although filenames and tools
> mentioned in tutorials may relate to other distributions, it should
> also be possible in any distribution.
>
> > If you have a fault develop ie power
> > goes down how does one check the filesystem? you dont
> > seem to be able to use fsck, so if anyone has any
> > experience of using loopback any info and experience
> > would be useful.
>
> I just tried fscking a loopback mounted filesystem (initrd.img from
> the Slackware CD-ROM, to be precise) and you can fsck it by
> specifying /dev/loop?. The only trouble is that it appears you need
> to have the filesystem mounted to be able to fsck it.
>
>
> --
> Simon <si...@no-dns-yet.org.uk> **** PGP: 099977D0
> "We demand rigidly defined areas of doubt and uncertainty."
> - Douglas Adams

--


Richard James

unread,
Oct 12, 2002, 5:35:00 AM10/12/02
to
Nomen Nescio wrote:

>
> Simon <use...@no-dns-yet.org.uk> writes:
>
>> * Nomen Nescio <nob...@dizum.com> wrote:
>>
>> At first I thought this may be the second coming of 'He Whose Name
>> Must Not Be Mentioned", but then I saw the post actually showed a bit
>> of intelligence. Sorry Bozo[tm]s.
>
> Oh dear here we go, still the same old newsgroup, wont bother reading
> anymore, see ya all in another few months, gee bozo's what do you do
> with them?.

OMG another visitation are you excited?

Richard :)

--
Again they chanted RTFM, RTFM, then one of the bozos who I was later to find
out was a Archbozo, he grabbed a large manual off the wall and beganeth to
club me unto death with it. -- Book Of the Newbie Chapter 1 --

William Hunt

unread,
Oct 12, 2002, 9:52:57 AM10/12/02
to
/dev/rob0 wrote:
> In article <7n37oa...@no-dns-yet.org.uk>, Simon wrote:
>> * Nomen Nescio <nob...@dizum.com> wrote:

i wonder if Nomen has purged his Bozo-killfile yet,
or will he be ignoring more good help from the Bozos
and Hated Regulars? and hardly even an RTFM in it!
anyway:

[...]


>>> If you have a fault develop ie power
>>> goes down how does one check the filesystem? you dont
>>> seem to be able to use fsck, so if anyone has any
>>
>> I just tried fscking a loopback mounted filesystem (initrd.img from
>> the Slackware CD-ROM, to be precise) and you can fsck it by
>> specifying /dev/loop?. The only trouble is that it appears you need
>> to have the filesystem mounted to be able to fsck it.
>
> No, here is where losetup does the job. You use losetup to link the file
> with the loop device, and then fsck the loop device.

or, it seems that one can simply fsck any unmounted filesystem image
by applying the "-f" 'force check' arg. man page only says this is
to force check of clean drive, but this also seems to override
requirement that the target be a block device. so,

e2fsck -f /cdrom/isolinux/initrd.img


> If you'd like I can post my swap encryption scripts. those will
> illustrate the use of losetup.

oooooooooo- donuts!

--
William Hunt, Portland Oregon USA

/dev/rob0

unread,
Oct 12, 2002, 3:34:55 PM10/12/02
to
In article <haq8oa...@server.techdrive.foo>, Richard James wrote:
> OMG another visitation are you excited?

No, because I'm not convinced that the N.N. who started the thread is
Our Messiah. But the one who replied to Simon may be ... :)

IAC I'm going to continue in the thread because it's an interesting and
quasi-topical matter.

/dev/rob0

unread,
Oct 12, 2002, 5:05:49 PM10/12/02
to
In article <uqga9rc...@corp.supernews.com>, William Hunt wrote:
>>> specifying /dev/loop?. The only trouble is that it appears you need
>>> to have the filesystem mounted to be able to fsck it.
>>
>> No, here is where losetup does the job. You use losetup to link the file
>> with the loop device, and then fsck the loop device.
>
> or, it seems that one can simply fsck any unmounted filesystem image
> by applying the "-f" 'force check' arg. man page only says this is

With encryption you have to use losetup anyway, else you're dealing with
an encrypted jumble.

>> If you'd like I can post my swap encryption scripts. those will
>> illustrate the use of losetup.
>
> oooooooooo- donuts!

Here's an excerpt from my rc.local:
#v+

### 2001/09/19 - encrypted swap devices

# load the main cryptoapi module
modprobe cryptoloop

# function to create encrypted swap devices
function doSwap() {
dd if=/dev/urandom bs=1 count=32 2> /dev/null | \
uuencode -m - | cut -c8-29 | tail -2 | head -1 | \
losetup -e blowfish -k128 -p0 /dev/loop${DEV[$X]} /dev/hd${PART[$X]}
mkswap /dev/loop${DEV[$X]} ;
}

# swap partitions: hda2 hdb1, loop devices: loop6 loop7
declare -a PART=(b1 a2)
declare -a DEV=(7 6)
for X in 0 1 ;
do echo "/dev/loop${DEV[$X]} is swap device /dev/hd${PART[$X]}"
doSwap
done

# activate swap devices
swapon -a

#v-
I also disabled the "/sbin/swapon -a" in rc.S.

Note that this is not workable for filesystems, because a new passphrase
is generated each time. :) The losetup "-p0" option tells it to read the
passphrase from stdin. The cool thing about it is that there's no way
even I could begin to guess these passphrases, so it's immune to the
traditional form of "brute force" attacks (such as to threaten "brute
force" upon the sysadmin, or more mundane stuff like dictionary attacks
or keyboard loggers.) The only potential weakness would come from the
urandom device.

You might also be interested in this "swap-reinit" script, which I run
at irregular intervals:
#v+

#!/bin/bash
### 2001/09/19-20: reinitialize encrypted swap devices

# This does the job
function go4it() {
swapoff $LO || giveUp
losetup -d $LO || giveUp
dd if=urandom bs=1 count=32 2> null | uuencode -m - | cut -c8-29 \
| tail -2 | head -1 | losetup -e blowfish -k128 -p0 $LO $PT || giveUp
mkswap $LO >& null || giveUp
swapon -p1 $LO || giveUp
sleep 10 ;
}

# failure message
function giveUp() {
/bin/echo "Aborted on $LO $PT" ; exit 65 ;
}

# An abbreviated $PATH will do
PATH=/usr/bin:/sbin:/bin

# all the action is in /dev so let's go there
cd /dev

# take down loop7 first
LOOP=(7 6)
PART=(b1 a2)
for X in 0 1
do LO="loop${LOOP[$X]}"
PT="hd${PART[$X]}"
go4it || giveUp
done

#v-
That script takes down each swap device and then restarts it with a new
passphrase.

Message has been deleted

/dev/rob0

unread,
Oct 13, 2002, 10:14:45 AM10/13/02
to
In article <slrnaqimna...@otaku.freeshell.org>, taviso wrote:
> doesnt piping the random data into uuencode reduce the quality of the
> passphrase, by changing it into only printable characters ?

Yes. But I don't know if losetup can accept non-printable characters.
Time for experimentation, I guess.

> hmmm, that is a lot of "ands" actally :)

Right. It's possible, but not bloody likely. :) Most successful attacks
would come *after* physical control of the machine has been taken from
me, in which case the swap won't reveal anything incriminating about my
plans for world domination, nor my secret recipe for chocolate biscuits.
;)

> i guess this qualifies as a good use for high quality randomness
> from /dev/random, in fact i've just noticed that the manpage mentions
> one-time key generation as a specific use :)

Interesting thought. When testing and deploying those scripts a year ago
I needed them to run quickly, but now that I'm only booting once a month
or so this is something to consider.

0 new messages