2

On a lot of tutorials on luks encryption, people say to override the partition with random data, so that data is not recoverable after encryption. I don't understand that. Will the random data be appended to the free space? Otherwise data would be lost, wouldn't it?

I've an unencrypted root partition and swap partition, in order to encrypt with luks i need an unecrypted paritition where boot is mounted in order to load initrd and decrypt the rest of the system /

I'm using an Ubuntu Distro by the way

3
  • Please ask only one question per question. I've edited out your other question, which is off-topic here. I suggest you ask it on Unix & Linux, but give more information: at least state your distribution and your current partitioning scheme. Jan 5, 2012 at 19:29
  • 1
    Are you talking about creating a new encrypted volume, or converting an existing unencrypted volume? Please link to at least one of these tutorials, so we know where you're at. Jan 5, 2012 at 19:31
  • Related: Pre-encryption wipe, why? on Unix & Linux
    – user
    Aug 21, 2017 at 11:21

3 Answers 3

1

I only do a speculation here what I think might be possible:

If you leave your harddrive "blank" that means in a "factory blank"-way or in a "there were readable files on it before"-way, an attacker can see things like partition layout, usage patterns and things alike due comparison of encrypted and unencrpyted areas. In a very extreme way he might be able to guess on certain information that is written to a specific part of the drive (like a partition header) and maybe obtain the key off that.

This will get harder and harder after some usage after most parts of the drive are overwritten at least once.

edit: (source)

If you are concerned with leaking the size your encrypted partitions relative to the physical disk volume you will need to randomize the disks.

1
  • LUKS doesn't randomize the location of data, so an almost empty disk isn't going to help the attacker perform a known-plaintext attack. Randomizing the location would not have a significant benefit anyway. Jan 6, 2012 at 9:34
1

I'm going to address the question of why one would want to fill a partition with random data before storing encrypted data on it. I don't know what conversion process you've been looking at, so I can't be more precise.

First, if there already was data on the partition that you are making encrypted, and you intend that data to be confidential, you must be sure to overwrite this data. It doesn't matter whether you overwrite with random data or with zeroes, but you might as well go with random (it may or may not be slower depending on the relative speeds of your disk and your CPU). This argument doesn't apply if you didn't have any confidential data on the partition, for example because it's on a newly purchased disk.

Now fast-forward in time to when the partition contains encrypted data. If you do not take any precaution, then an attacker who gets hold of the raw partition can see which parts are not used. This reveals some information: the attacker will know how much data you've stored (to some extent: the attacker won't be able to distinguish between live encrypted data and deleted-but-not-overwritten encrypted data). This is not always a concern, but when you're writing a security tutorial it's better to be safe than sorry. If the unused space is filled with random data, the attacker has no way to distinguish the unused space from the used space (an informal definition of successfully encrypted data is that it's indistinguishable from random data to someone who doesn't have the key).

If the attacker can snoop on the encrypted data several times (sneaking in to read, as opposed to stealing the disk outright), then the attacker can see how the amount and location of used space evolves over time. This too technically reveals information (but not exploitable information in most use cases). Of course, in this situation, the attacker can find out the approximate rate of change in the encrypted data anyway.

The cryptsetup luksFormat command only stores the necessary metadata, it does not overwrite the whole partition. This is considerably faster, but slightly insecure in some use cases; hence the common recommendation to first overwrite the whole partition.

The standard method to encrypt a partition with LUKS is to back up the data, create the encrypted container and restore from the backup. Thus in the normal LUKS volume creation process, you would overwrite the whole partition, not just the free space (overwriting the free space would not meet the primary objective of erasing the old data, as the new volume may not store the data in the same locations inside the partition). There are projects to make tools to convert a volume to LUKS in place; I don't know how mature they are. In such a tool, you would only overwrite whatever space is not used up by encrypted data at the end of the encryption process.

1
  • Incidentally; I do it the other way. I fill the encrypted image with zeros (which randomizes the blocks just the same).
    – Joshua
    Aug 20, 2021 at 18:10
0

I think if you place random data on your hard drive it is difficult for someone else to distinguish real encrypted data from random garbage. That helps to fight against blackmailers.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .