3

You can change the LUKS passphrase without dataloss, but can you also change the actual key?

I reckon you would have to re-encrypt the whole disk, but that would be acceptable to me.

Background

We are considering distributing a live USB with full disk encryption. But that means that even if you change the passphrase, I will still be able to get the secret key if I got a copy of the original live USB.

So the first time you use it, it should re-encrypt the whole disk with a new key (and not just a new passphrase to unlock the key).

1
  • Keep in mind that cheap USB memory sticks tend to not handle large or repeat writes terribly well (this being much more of a problem than on SSDs intended for long-term use). Consider instead treating the memory stick as a dumb read-only storage, and overlaying a ramfs for any additional data. You can have a small(ish) data partition on the memory stick too, on which you run luksFormat on first boot of the media, ideally as late as possible (to allow for early boot entropy collection), which files can be stored on.
    – user
    May 23, 2016 at 14:44

1 Answer 1

5

With the cryptsetup-reencrypt tool, you can change almost all aspects of a luks encrypted device like, the volume key, cipher, or even encrypt a device that is not encrypted. In some distributions, you will have to download the cryptsetup sources and recompile with the --enable-cryptsetup-reencrypt option. If you are using a Red Hat based distribution, you will be interested in this proof-of-concept dracut module at cyptsetup sources.

Running cryptsetup-reencrypt without parameters should be enough to start a new key being generated. But be aware that any power failure or error during the process could let data unacessible forever.

4
  • 1
    It's also worth noting that a full reencryption can take some time. Especially if the system (computer and OS) doesn't support AES-NI (or if you are using some encryption algorithm other than AES) reencrypting a reasonably sized media can take a while.
    – user
    May 23, 2016 at 14:42
  • If the reencrypting is done as the very first task (i.e. before the user saves data on it), then there is no risk of dataloss - only time wasted. Good input.
    – Ole Tange
    May 23, 2016 at 15:02
  • But what about a power failure during the process? Even without data being written to the disk, there is always this risk. And as said by @MichaelKjörling, depending on the disk size and cryptography features of your computer, it could take a reasonable time...
    – user28177
    May 23, 2016 at 16:25
  • Power failure is not a big problem: There will be no dataloss. They will only lose the distributed information which they can get again. The time issue can be mitigated by setting expectations: "The first time you boot this, do it before you go to bed - it will be cooked and ready the next morning".
    – Ole Tange
    May 24, 2016 at 8:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.