[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[partman-crypto] Trying to understand crypto_do_wipe ( )



Dear all,

I was looking at the code that writes random data to disk as part of
setting up an encrypted partition. The main reason I was interested is
that it seems to be quite a lot faster than something like "dd
if=/dev/urandom of=/dev/sdx", and so I wanted to know how it works.
However, as far as I understand the code now, it seems to be writing
zeroes rather than random data (!).

I'm a very inexperienced user and programmer, so please forgive if I
should be completely off base here. Can I ask your help checking on my
understanding?

Reading the current svn trunk of partman-crypto, I'm looking at
lib/crypto-base.sh, starting in crypto_wipe_device ( ). This seems to
ask for some confirmations that you really want to wipe the disk, then
calls crypto_do_wipe ( ). Now the relevant line there I think is

/bin/blockdev-wipe -s 65536 $dev > $fifo &

the code for which is in blockdev-wipe/blockdev-wipe.c. In main ( ), I
think this tries to read the option "-f" which would specify a source
to read from (and note that this is absent from the call quoted
above). In it's absence, do_wipe ( ) is then called with source=0. I
think with source=0, the char-array buf[] will only be written to once
(memset zeroes), and is then used to write to disk from.

Is that right? Thanks for your time,
Best wishes,

Yung-Chin Oei


Reply to: