~ubuntu-branches/debian/jessie/cryptsetup/jessie

« back to all changes in this revision

Viewing changes to FAQ

  • Committer: Package Import Robot
  • Author(s): Jonas Meurer
  • Date: 2012-02-05 03:17:59 UTC
  • mfrom: (0.2.9)
  • Revision ID: package-import@ubuntu.com-20120205031759-kua3bplwunj0q2zl
Tags: 2:1.4.1-1
* new upstream release (1.4.0 + 1.4.1) (closes: #647851)
  - fixes typo in german translation. (closes: #645528)
  - remove patches, all incorporated upstream.
  - soname bump, rename library package to libcryptsetup4
* check for busybox in initramfs cryptroot hook, and install the sed binary
  in case it's either not installed or not activated. (closes: #591853)
* add checks for 'type $KEYSCRIPT' to initscripts cryptdisks.functions, and
  to cryptroot initramfs script/hook. this adds support for keyscripts inside
  $PATH. thanks to Ian Jackson for the suggestion. (closes: #597583)
* use argument '--sysinit' for vgchange in cryptroot initramfs script. Thanks
  to Christoph Anton Mitterer for the suggestion.
* add option for discard/trim features to crypttab and initramfs scripts.
  Thanks to intrigeri and Peter Colberg for patches. (closes: #648868)
* print $target on error in initramfs hook. Thanks to Daniel Hahler for the
  bugreport. (closes: #648192)
* add a warning about using decrypt_derived keyscript for devices with
  persistent data. Thanks to Arno Wagner for pointing this out.
* remove quotes from resume device candidates at get_resume_devs() in
  initramfs hook script. Thanks to Johannes Rohr. (closes: #634017)
* support custom $TABFILE, thanks to Douglas Huff. (closes: #638317)
* fix get_lvm_deps() in initramfs cryptroot hook to add all physical volumes
  of lvm volume group that contains the rootfs logical volume, even if the
  rootfs is lv is not spread over all physical volumes. Thanks to Christian
  Pernegger for bugreport and patch. (closes: #634109)
* debian/initramfs/cryptroot-script: Move check for maximum number of tries
  behind the while loop, to make the warning appear in case that maximum
  number of tries is reached. Thanks to Chistian Lamparter for bugreport and
  patch. (closes: #646083)
* incorporate changes to package descriptions and debconf templates that
  suggested by debian-l10n-english people. Special thanks go to Justin B Rye.
* acknowledge NMU, thanks a lot to Christian Perrier for his great work on
  the i18n front. (closes: #633105, #641719, #641839, #641947, #642470,
  #640056, #642540, #643633, #643962, #644853)
* add and update debconf translations:
  - italian, thanks to Milo Casagrande, Francesca Ciceri. (closes: #656933)
  - german, thanks to Erik Pfannenstein. (closes: #642147)
  - spanish, thanks to Camaleón. (closes: #658360)
  - russian, thanks to Yuri Kuzlov (closes: #654676)
* set architecture to linux-any, depends on linux kernel anyway. Thanks to
  Christoph Egger. (closes: #638257)
* small updates to the copyright file.
* add targets build-indep and build-arch to debian/rules, thanks to lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
6
6
4. Troubleshooting
7
7
5. Security Aspects
8
8
6. Backup and Data Recovery
9
 
7. Issues with Specific Versions of cryptsetup
 
9
7. Interoperability with other Disk Encryption Tools
 
10
8. Issues with Specific Versions of cryptsetup
10
11
A. Contributors
11
12
 
12
13
 
17
18
 
18
19
  This is the FAQ (Frequently Asked Questions) for cryptsetup. It
19
20
  covers Linux disk encryption with plain dm-crypt (one passphrase,
20
 
  no management, no descriptor on disk) and LUKS (multiple user keys
21
 
  with one master key, anti-forensics, descriptor block at start of
22
 
  device, ...). The latest version should usually be available at
 
21
  no management, no metadata on disk) and LUKS (multiple user keys
 
22
  with one master key, anti-forensic features, metadata block at
 
23
  start of device, ...). The latest version of this FAQ should
 
24
  usually be available at
23
25
  http://code.google.com/p/cryptsetup/wiki/FrequentlyAskedQuestions
24
26
 
 
27
 
 
28
 * WARNINGS
 
29
 
25
30
  ATTENTION: If you are going to read just one thing, make it the
26
31
  section on Backup and Data Recovery. By far the most questions on
27
 
  the cryptsetup mailing list are from people that just managed to
28
 
  somehow format or overwrite the start of their LUKS partitions. In
 
32
  the cryptsetup mailing list are from people that managed to damage
 
33
  the start of their LUKS partitions, i.e. the LUKS header. In
29
34
  most cases, there is nothing that can be done to help these poor
30
35
  souls recover their data. Make sure you understand the problem and
31
 
  limitations imposed by the LUKS security model BEFORE you face such
32
 
  a disaster!
 
36
  limitations imposed by the LUKS security model BEFORE you face
 
37
  such a disaster! In particular, make sure you have a current header
 
38
  backup before doing any potentially dangerous operations.
 
39
 
 
40
  DISTRIBUTION INSTALLERS: Some distribution installers offer to
 
41
  create LUKS containers in a way that can be mistaken as activation
 
42
  of an existing container. Creating a new LUKS container on top of
 
43
  an existing one leads to permanent, complete and irreversible data
 
44
  loss. It is strongly recommended to only use distribution
 
45
  installers after a complete backup of all LUKS containers has been
 
46
  made.
 
47
 
 
48
  LUKS PASSPHRASE IS NOT THE MASTER KEY: The LUKS passphrase is not
 
49
  used in deriving the master key. It is used in decrypting a master
 
50
  key that is randomly selected on header creation. This means that
 
51
  if you create a new LUKS header on top of an old one with
 
52
  exactly the same parameters and exactly the same passphrase as the
 
53
  old one, it will still have a different master key and your data
 
54
  will be permanently lost.
 
55
 
 
56
  PASSPHRASE CHARACTER SET: Some people have had difficulties with
 
57
  this when upgrading distributions. It is highly advisable to only
 
58
  use the 94 printable characters from the first 128 characters of
 
59
  the ASCII table, as they will always have the same binary
 
60
  representation. Other characters may have different encoding
 
61
  depending on system configuration and your passphrase will not
 
62
  work with a different encoding. A table of the standardized first
 
63
  128 ASCII caracters can, e.g. be found on
 
64
  http://en.wikipedia.org/wiki/ASCII
 
65
 
 
66
 
 
67
 * System Specific warnings
 
68
 
 
69
  - Ubuntu as of 4/2011: It seems the installer offers to create
 
70
  LUKS partitions in a way that several people mistook for an offer
 
71
  to activate their existing LUKS partition. The installer gives no
 
72
  or an inadequate warning and will destroy your old LUKS header,
 
73
  causing permanent data loss. See also the section on Backup and
 
74
  Data Recovery.
 
75
 
 
76
  This issue has been acknowledged by the Ubuntu dev team, see here:
 
77
  http://launchpad.net/bugs/420080
33
78
 
34
79
 
35
80
 * Who wrote this?
38
83
  contributors are listed at the end. If you want to contribute, send
39
84
  your article, including a descriptive headline, to the maintainer,
40
85
  or the dm-crypt mailing list with something like "FAQ ..." in the
41
 
  subject. Please note that by contributing to this FAQ, you accept
42
 
  the license described below.
 
86
  subject. You can also send more raw information and have me write
 
87
  the section. Please note that by contributing to this FAQ, you
 
88
  accept the license described below.
43
89
 
44
90
  This work is under the "Attribution-Share Alike 3.0 Unported"
45
91
  license, which means distribution is unlimited, you may create
150
196
 
151
197
 * How do I use LUKS with a loop-device?
152
198
 
153
 
  Just the same as with any block device. If you want, for example,
154
 
  to use a 100MiB file as LUKS container, do something like this:
 
199
  This can be very handy for experiments. Setup is just the same as
 
200
  with any block device. If you want, for example, to use a 100MiB
 
201
  file as LUKS container, do something like this:
155
202
 
156
203
      head -c 100M /dev/zero > luksfile  # create empty file
157
204
      losetup /dev/loop0 luksfile        # map luksfile to /dev/loop0
173
220
  new key-slot.
174
221
 
175
222
 
 
223
 * Encrytion on top of RAID or the other way round?
 
224
 
 
225
  Unless you have special needs, place encryption between RAID and
 
226
  filesystem, i.e. encryption on top of RAID. You can do it the other
 
227
  way round, but you have to be aware that you then need to give the
 
228
  pasphrase for each individual disk and RAID autotetection will not
 
229
  work anymore. Therefore it is better to encrypt the RAID device,
 
230
  e.g. /dev/dm0 .
 
231
 
 
232
 
176
233
 * How do I read a dm-crypt key from file?
177
234
 
178
235
  Note that the file will still be hashed first, just like keyboard
344
401
  However, this operation will not change volume key iteration count
345
402
  (MK iterations in output of "cryptsetup luksDump"). In order to
346
403
  change that, you will have to backup the data in the LUKS
347
 
  container, luksFormat on the slow machine and restore the data.
348
 
  Note that in the original LUKS specification this value was fixed
349
 
  to 10, but it is now derived from the PBKDF2 benchmark as well and
350
 
  set to iterations in 0.125 sec or 1000, whichever is larger.
 
404
  container (i.e. your encrypted data), luksFormat on the slow
 
405
  machine and restore the data. Note that in the original LUKS
 
406
  specification this value was fixed to 10, but it is now derived
 
407
  from the PBKDF2 benchmark as well and set to iterations in 0.125
 
408
  sec or 1000, whichever is larger. Also note that MK iterations
 
409
  are not very security relevant. But as each key-slot already takes
 
410
  1 second, spending the additional 0.125 seconds really does not
 
411
  matter.
351
412
 
352
413
 
353
414
 * "blkid" sees a LUKS UUID and an ext2/swap UUID on the same device.
409
470
  ciphers. With the usual modes in cryptsetup (CBC, ESSIV, XTS), you
410
471
  get up to a completely changed 512 byte block per bit error. A
411
472
  corrupt block causes a lot more havoc than the occasionally
412
 
  flipped single bit and can result various obscure errors.
 
473
  flipped single bit and can result in various obscure errors.
413
474
 
414
 
  Note however that a verify run on copying between encrypted or
415
 
  unencrypted devices can also show you corruption when the copying
416
 
  itself did not report any problems. If you find defect RAM, assume
417
 
  all backups and copied data to be suspect, unless you did a verify.
 
475
  Note, that a verify run on copying between encrypted or
 
476
  unencrypted devices will reliably detect corruption, even when the
 
477
  copying itself did not report any problems. If you find defect
 
478
  RAM, assume all backups and copied data to be suspect, unless you
 
479
  did a verify.
418
480
 
419
481
 
420
482
 * How do I test RAM?
455
517
5. Security Aspects 
456
518
 
457
519
 
 
520
 * Is LUKS insecure? Everybody can see I have encrypted data!
 
521
 
 
522
  In practice it does not really matter. In most civilized countries
 
523
  you can just refuse to hand over the keys, no harm done. In some
 
524
  countries they can force you to hand over the keys, if they suspect
 
525
  encryption. However the suspicion is enough, they do not have to
 
526
  prove anything. This is for practical reasons, as even the presence
 
527
  of a header (like the LUKS header) is not enough to prove that you
 
528
  have any keys. It might have been an experiment, for example. Or it
 
529
  was used as encrypted swap with a key from /dev/random. So they
 
530
  make you prove you do not have encrypted data. Of course that is
 
531
  just as impossible as the other way round.
 
532
 
 
533
  This means that if you have a large set of random-looking data,
 
534
  they can already lock you up. Hidden containers (encryption hidden
 
535
  within encryption), as possible with Truecrypt, do not help
 
536
  either. They will just assume the hidden container is there and
 
537
  unless you hand over the key, you will stay locked up. Don't have
 
538
  a hidden container? Though luck. Anybody could claim that.
 
539
 
 
540
  Still, if you are concerned about the LUKS header, use plain
 
541
  dm-crypt with a good passphrase. See also Section 2, "What is the
 
542
  difference between "plain" and LUKS format?"
 
543
 
 
544
 
458
545
 * Should I initialize (overwrite) a new LUKS/dm-crypt partition?
459
546
 
460
547
  If you just create a filesystem on it, most of the old data will
561
648
  to the last stage ("Acceptance") and think about what to do now.
562
649
  There is one exception that I know of: If your LUKS container is
563
650
  still open, then it may be possible to extract the master key from
564
 
  the running system. Ask on the mailing-list on how to do that and
565
 
  make sure nobody switches off the machine.
 
651
  the running system. See Item "How do I recover the master key from
 
652
  a mapped LUKS container?" in Section "Backup and Data Recovery".
566
653
 
567
654
 
568
655
 * What is a "salt"?
595
682
 
596
683
 * Is LUKS secure with a low-entropy (bad) passphrase?
597
684
 
 
685
  Note: You should only use the 94 printable characters from 7 bit
 
686
  ASCII code to prevent your passphrase from failing when the
 
687
  character encoding changes, e.g. because of a system upgrade, see
 
688
  also the note at the very start of this FAQ under "WARNINGS".
 
689
 
598
690
  This needs a bit of theory. The quality of your passphrase is
599
691
  directly related to its entropy (information theoretic, not
600
692
  thermodynamic). The entropy says how many bits of "uncertainty" or
629
721
  days on a single CPU and is entirely feasible. To put that into
630
722
  perspective, using a number of Amazon EC2 High-CPU Extra Large
631
723
  instances (each gives about 8 real cores), this tests costs
632
 
  currently about $48, but can be made to run arbitrarily fast.
 
724
  currently about 50USD/EUR, but can be made to run arbitrarily fast.
633
725
 
634
726
  On the other hand, choosing 1.5 lines from, say, the Wheel of Time
635
727
  is in itself not more secure, but the book selection adds quite a
661
753
  0.0001 seconds on a modern CPU.
662
754
 
663
755
  Example 2: The user did a bit better and has 32 chars of English
664
 
  text. That would give use about 32 bits of entropy. With 1 second
 
756
  text. That would be about 32 bits of entropy. With 1 second
665
757
  iteration, that means an attacker on the same CPU needs around 136
666
758
  years. That is pretty impressive for such a weak passphrase.
667
759
  Without the iterations, it would be more like 50 days on a modern
703
795
  this danger significantly.
704
796
 
705
797
 
 
798
 * What about iteration count with plain dm-crypt?
 
799
 
 
800
  Simple: There is none. There is also no salting. If you use plain
 
801
  dm-crypt, the only way to be secure is to use a high entropy
 
802
  passphrase. If in doubt, use LUKS instead.
 
803
 
 
804
 
706
805
 * Is LUKS with default parameters less secure on a slow CPU?
707
806
 
708
807
  Unfortunately, yes. However the only aspect affected is the
793
892
6. Backup and Data Recovery 
794
893
 
795
894
 
 
895
 * Why do I need Backup?
 
896
 
 
897
  First, disks die. The rate for well-treated (!) disk is about 5%
 
898
  per year, which is high enough to worry about. There is some
 
899
  indication that this may be even worse for some SSDs. This applies
 
900
  both to LUKS and plain dm-crypt partitions.
 
901
 
 
902
  Second, for LUKS, if anything damages the LUKS header or the
 
903
  key-stripe area then decrypting the LUKS device can become
 
904
  impossible. This is a frequent occuurence. For example an
 
905
  accidental format as FAT or some software overwriting the first
 
906
  sector where it suspects a partition boot sector typically makes a
 
907
  LUKS partition permanently inacessible. See more below on LUKS
 
908
  header damage.
 
909
 
 
910
  So, data-backup in some form is non-optional. For LUKS, you may
 
911
  also want to store a header backup in some secure location. This
 
912
  only needs an update if you change passphrases.
 
913
 
 
914
 
 
915
 * How do I backup a LUKS header?
 
916
 
 
917
  While you could just copy the appropriate number of bytes from the
 
918
  start of the LUKS partition, the best way is to use command option
 
919
  "luksHeaderBackup" of cryptsetup. This protects also against
 
920
  errors when non-standard parameters have been used in LUKS
 
921
  partition creation. Example:
 
922
 
 
923
 
 
924
     cryptsetup luksHeaderBackup --header-backup-file h /dev/mapper/c1
 
925
 
 
926
  To restore, use the inverse command, i.e.
 
927
 
 
928
     cryptsetup luksHeaderRestore --header-backup-file h /dev/mapper/c1
 
929
 
 
930
 
 
931
 * How do I backup a LUKS or dm-crypt partition?
 
932
 
 
933
  There are two options, a sector-image and a plain file or
 
934
  filesystem backup of the contents of the partition. The sector
 
935
  image is already encrypted, but cannot be compressed and contains
 
936
  all empty space. The filesystem backup can be compressed, can
 
937
  contain only part of the encrypted device, but needs to be
 
938
  encrypted separately if so desired.
 
939
 
 
940
  A sector-image will contain the whole partition in encrypted form,
 
941
  for LUKS the LUKS header, the keys-slots and the data area. It can
 
942
  be done under Linux e.g. with dd_rescue (for a direct image copy)
 
943
  and with "cat" or "dd". Example:
 
944
 
 
945
      cat /dev/sda10 > sda10.img
 
946
      dd_rescue /dev/sda10 sda10.img 
 
947
 
 
948
  You can also use any other backup software that is capable of making
 
949
  a sector image of a partition. Note that compression is
 
950
  ineffective for encrypted data, hence it does not make sense to
 
951
  use it.
 
952
 
 
953
  For a filesystem backup, you decrypt and mount the encrypted
 
954
  partition and back it up as you would a normal filesystem. In this
 
955
  case the backup is not encrypted, unless your encryption method
 
956
  does that. For example you can encrypt a backup with "tar" as
 
957
  follows with GnuPG:
 
958
 
 
959
      tar cjf - <path> | gpg --cipher-algo AES -c - > backup.tbz2.gpg
 
960
 
 
961
  And verify the backup like this if you are at "path":
 
962
 
 
963
      cat backup.tbz2.gpg | gpg - | tar djf - 
 
964
 
 
965
  Note: Allways verify backups, especially encrypted ones.
 
966
 
 
967
  In both cases GnuPG will ask you interactively for your symmetric
 
968
  key. The verify will only output errors. Use "tar dvjf -" to get
 
969
  all comparison results. To make sure no data is written to disk
 
970
  unencrypted, turn off swap if it is not encrypted before doing the
 
971
  backup.
 
972
 
 
973
  You can of course use different or no compression and you can use
 
974
  an asymmetric key if you have one and have a backup of the secret
 
975
  key that belongs to it.
 
976
 
 
977
  A second option for a filestem-level backup that can be used when
 
978
  the backup is also on local disk (e.g. an external USB drive) is
 
979
  to use a LUKS container there and copy the files to be backed up
 
980
  between both mounted containers. Also see next item.
 
981
 
 
982
 
 
983
 * Do I need a backup of the full partition? Would the header and
 
984
   key-slots not be enough?
 
985
 
 
986
  Backup protects you against two things: Disk loss or corruption
 
987
  and user error. By far the most questions on the dm-crypt mailing
 
988
  list about how to recover a damaged LUKS partition are related
 
989
  to user error. For example, if you create a new filesystem on a
 
990
  LUKS partition, chances are good that all data is lost
 
991
  permanently.
 
992
 
 
993
  For this case, a header+key-slot backup would often be enough. But
 
994
  keep in mind that a well-treated (!) HDD has roughly a failure
 
995
  risk of 5% per year. It is highly advisable to have a complete
 
996
  backup to protect against this case.
 
997
 
 
998
 
 
999
  * *What do I need to backup if I use "decrypt_derived"?
 
1000
 
 
1001
  This is a script in Debian, intended for mounting /tmp or swap with
 
1002
  a key derived from the master key of an already decrypted device.
 
1003
  If you use this for an device with data that should be persistent,
 
1004
  you need to make sure you either do not lose access to that master
 
1005
  key or have a backup of the data. If you derive from a LUKS
 
1006
  device, a header backup of that device would cover backing up the
 
1007
  master key. Keep in mind that this does not protect against disk
 
1008
  loss.
 
1009
 
 
1010
  Note: If you recreate the LUKS header of the device you derive from
 
1011
  (using luksFormat), the master key changes even if you use the same
 
1012
  passphrase(s) and you will not be able to decrypt the derived
 
1013
  device with the new LUKS header.
 
1014
 
 
1015
 
796
1016
 * Does a backup compromise security?
797
1017
 
798
 
  Depends on how you do it. First, a backup is non-optional with
799
 
  encrypted data just the same way it is with non-encrypted data.
800
 
  Disks do break and they do not care whether they make plain or
801
 
  encrypted data inaccessible. As a gideline, a well-treated HDD (!)
802
 
  breaks with about 5% probability per year. This means everybody
803
 
  will be hit sooner or later.
 
1018
  Depends on how you do it. However if you do not have one, you are
 
1019
  going to eventually lose your encrypted data.
804
1020
 
805
 
  However there are risks introduced by backups. For example if you
 
1021
  There are risks introduced by backups. For example if you
806
1022
  change/disable a key-slot in LUKS, a binary backup of the partition
807
1023
  will still have the old key-slot. To deal with this, you have to
808
 
  be able to change the key-slot on the backup as well, or use a
809
 
  different set-up. One option is to have a different passphrase on
810
 
  the backup and to make the backup with both containers open.
811
 
  Another one is to make a backup of the original, opened container
812
 
  to a single file, e.g. with tar, and to encrypt that file with
813
 
  public-key-cryptography, e.g. with GnuPG. You can then keep the
814
 
  secret key in a safe place, because it is only used to decrypt a
815
 
  backup. The key the backup is encrypted with can be stored without
816
 
  special security measures, as long as an attacker cannot replace
817
 
  it with his own key.
 
1024
  be able to change the key-slot on the backup as well, securely
 
1025
  erase the backup or do a filesystem-level backup instead of a binary
 
1026
  one.
818
1027
 
819
1028
  If you use dm-crypt, backup is simpler: As there is no key
820
1029
  management, the main risk is that you cannot wipe the backup when
822
1031
  should consist of forgetting the passphrase and that you can do
823
1032
  without actual access to the backup.
824
1033
 
825
 
  In both cases, there is an additional (usually small) risk: An
826
 
  attacker can see how many sectors and which ones have been changed
827
 
  since the backup. This is not possible with the public-key method
828
 
  though.
 
1034
  In both cases, there is an additional (usually small) risk with
 
1035
  binary backups: An attacker can see how many sectors and which
 
1036
  ones have been changed since the backup. To prevent this, use a
 
1037
  filesystem level backup methid that encrypts the whole backup in
 
1038
  one go, e.g. as described above with tar and GnuPG.
829
1039
 
830
 
  My personal advice is to use one USB disk (low value date) or
 
1040
  My personal advice is to use one USB disk (low value data) or
831
1041
  three disks (high value data) in rotating order for backups, and
832
 
  either use different passphrases or keep them easily accessible
833
 
  in case you need to disable a key-slot. If you do network-backup
834
 
  or tape-backup, I strongly recommend to go the public-key path,
835
 
  especially as you typically cannot reliably delete data in these
836
 
  scenarios. (Well, you can burn the tape if it is under your
837
 
  control...)
 
1042
  either use independent LUKS partitions on them, or use encrypted
 
1043
  backup with tar and GnuPG.
 
1044
 
 
1045
  If you do network-backup or tape-backup, I strongly recommend to
 
1046
  go the filesystem backup path with independent encryption, as you
 
1047
  typically cannot reliably delete data in these scenarios,
 
1048
  especially in a cloud setting. (Well, you can burn the tape if it
 
1049
  is under your control...)
838
1050
 
839
1051
 
840
1052
 * What happens if I overwrite the start of a LUKS partition or damage
860
1072
  damage the key-slots in part or in full. See also last item.
861
1073
 
862
1074
 
 
1075
 * How do I recover the master key from a mapped LUKS container?
 
1076
 
 
1077
  This is typically only needed if you managed to damage your LUKS
 
1078
  header, but the container is still mapped, i.e. "luksOpen"ed.
 
1079
 
 
1080
  WARNING: This exposes the master key of the LUKS container. Note
 
1081
  that both ways to recreate a LUKS header with the old master key
 
1082
  described below will write the master key to disk. Unless you are
 
1083
  sure you have securely erased it afterwards, e.g. by writing it to
 
1084
  an encrypted partition, RAM disk or by erasing the filesystem you
 
1085
  wrote it to by a complete overwrite, you should change the master
 
1086
  key afterwards.    Changing the master key requires a full data
 
1087
  backup, luksFormat and then restore of the backup.
 
1088
 
 
1089
  First, there is a script by Milan that tries to automatize the
 
1090
  whole process, including generating a new LUKS header with the old
 
1091
  master key:
 
1092
 
 
1093
http://code.google.com/p/cryptsetup/source/browse/trunk/misc/luks-header-from-active
 
1094
 
 
1095
  You can also do this manually. Here is how:
 
1096
 
 
1097
  - Get the master key from the device mapper. This is done by the
 
1098
  following command. Substitute c5 for whatever you mapped to:
 
1099
 
 
1100
      # dmsetup table --target crypt --showkey /dev/mapper/c5
 
1101
      Result:
 
1102
      0 200704 crypt aes-cbc-essiv:sha256 
 
1103
      a1704d9715f73a1bb4db581dcacadaf405e700d591e93e2eaade13ba653d0d09 
 
1104
      0 7:0 4096
 
1105
 
 
1106
  The result is actually one line, wrapped here for clarity. The long
 
1107
  hex string is the master key.
 
1108
 
 
1109
  - Convert the master key to a binary file representation. You can
 
1110
  do this manually, e.g. with hexedit. You can also use the tool
 
1111
  "xxd" from vim like this:
 
1112
 
 
1113
      echo "a1704d9....53d0d09" | xxd -r -p > master_key
 
1114
 
 
1115
  - Do a luksFormat to create a new LUKS header. Unmapthe device
 
1116
  before you do that (luksClose). Replace \dev\dsa10 with the device
 
1117
  the LUKS container is on:
 
1118
 
 
1119
      cryptsetup luksFormat --master-key-file=master_key \dev\sda10
 
1120
 
 
1121
  Note that if the container was created with other than the default
 
1122
  settings of the cryptsetup version you are using, you need to give
 
1123
  additional parameters specifying the deviations. If in doubt, just
 
1124
  do the first step, keep the whole result safe and try with the
 
1125
  script by Milan. It does recover the other parameters as well.
 
1126
 
 
1127
  Side note: This is the way the decrypt_derived script gets at the
 
1128
  master key. It just omits the conversion and hashes the master key
 
1129
  string.
 
1130
 
 
1131
 
863
1132
 * What does the on-disk structure of dm-crypt look like?
864
1133
 
865
1134
  There is none. dm-crypt takes a block device and gives encrypted
910
1179
  http://code.google.com/p/cryptsetup/wiki/Specification
911
1180
 
912
1181
 
913
 
 * How do I backup a LUKS header?
914
 
 
915
 
  While you could just copy the appropriate number of bytes from the
916
 
  start of the LUKS partition, the best way is to use command option
917
 
  "luksHeaderBackup" of cryptsetup. This protects also against
918
 
  errors when non-standard parameters have been used in LUKS
919
 
  partition creation. Example:
920
 
 
921
 
 
922
 
     cryptsetup luksHeaderBackup --header-backup-file h /dev/mapper/c1
923
 
 
924
 
  To restore, use the inverse command, i.e.
925
 
 
926
 
     cryptsetup luksHeaderRestore --header-backup-file h /dev/mapper/c1
927
 
 
928
 
 
929
 
 * How do I backup a LUKS partition?
930
 
 
931
 
  You do a sector-image of the whole partition. This will contain
932
 
  the LUKS header, the keys-slots and the data ares. It can be done
933
 
  under Linux e.g. with dd_rescue (for a direct image copy) and with
934
 
  "cat" or "dd". Example:
935
 
 
936
 
      cat /dev/sda10 > sda10.img
937
 
      dd_rescue /dev/sda10 sda10.img 
938
 
 
939
 
  You can also use any other backup software that is capable of making
940
 
  a sector image of a partition. Note that compression is
941
 
  ineffective for encrypted data, hence it does not make sense to
942
 
  use it.
943
 
 
944
 
 
945
 
 * Do I need a backup of the full partition? Would the header and
946
 
   key-slots not be enough?
947
 
 
948
 
  Backup protects you against two things: Disk loss or corruption
949
 
  and user error. By far the most questions on the dm-crypt mailing
950
 
  list about how to recover a damaged LUKS partition are related
951
 
  to user error. For example, if you create a new filesystem on a
952
 
  LUKS partition, chances are good that all data is lost
953
 
  permanently.
954
 
 
955
 
  For this case, a header+key-slot backup would often be enough. But
956
 
  keep in mind that a well-treated (!) HDD has roughly a failure
957
 
  risk of 5% per year. It is highly advisable to have a complete
958
 
  backup to protect against this case.
959
 
 
960
 
 
961
 
 * Are there security risks from a backup of the LUKS header or a
962
 
   whole LUKS partition?
963
 
 
964
 
  Yes. One risk is that if you remove access rights for specific
965
 
  key-slots by deleting their contents, the data can still be
966
 
  accessed with invalidated passphrase and the backup. The other
967
 
  risk is that if you erase a LUKS partition, a backup could still
968
 
  grant access, especially if you only erased the LUKS header and
969
 
  not the whole partition.
970
 
 
971
 
 
972
1182
 * I think this is overly complicated. Is there an alternative?
973
1183
 
974
 
  Yes, you can use plain dm-crypt. It does not allow multiple
 
1184
  Not really. Encryption comes at a price. You can use plain
 
1185
  dm-crypt to simplify things a bit. It does not allow multiple
975
1186
  passphrases, but on the plus side, it has zero on disk description
976
1187
  and if you overwrite some part of a plain dm-crypt partition,
977
1188
  exactly the overwritten parts are lost (rounded up to sector
978
1189
  borders).
979
1190
 
980
1191
 
981
 
7. Issues with Specific Versions of cryptsetup 
 
1192
7. Interoperability with other Disk Encryption Tools  
 
1193
 
 
1194
 
 
1195
 * What is this section about?
 
1196
 
 
1197
  Cryptsetup for plain dm-crypt can be used to access a number of
 
1198
  on-disk formats created by tools like loop-aes patched into
 
1199
  losetup. This somtimes works and sometimes does not.    This section
 
1200
  collects insights into what works, what does not and where more
 
1201
  information is required.
 
1202
 
 
1203
  Additional information may be found in the mailing-list archives,
 
1204
  mentioned at the start of this FAQ document. If you have a
 
1205
  solution working that is not yet documented here and think a wider
 
1206
  audience may be intertested, please email the FAQ maintainer.
 
1207
 
 
1208
 
 
1209
 * loop-aes: General observations.
 
1210
 
 
1211
  One problem is that there are different versions of losetup around.
 
1212
  loop-aes is a patch for losetup. Possible problems and deviations
 
1213
  from cryptsetup option syntax include:
 
1214
 
 
1215
  - Offsets specifed in bytes (cryptsetup: 512 byte sectors)
 
1216
 
 
1217
  - The need to specify an IV offset
 
1218
 
 
1219
  - Encryption mode needs specifying (e.g. "-c twofish-cbc-plain")
 
1220
 
 
1221
  - Key size needs specifying (e.g. "-s 128" for 128 bit keys)
 
1222
 
 
1223
  - Passphrase hash algorithm needs specifying
 
1224
 
 
1225
  Also note that because plain dm-crypt and loop-aes format does not
 
1226
  have metadata, autodetection, while feasible in most cases, would
 
1227
  be a lot of work that nobody really wants to do. If you still have
 
1228
  the old set-up, using a verbosity option (-v) on mapping with the
 
1229
  old tool or having a look into the system logs after setup could
 
1230
  give you the information you need.
 
1231
 
 
1232
 
 
1233
 * loop-aes patched into losetup on debian 5.x, kernel 2.6.32
 
1234
 
 
1235
  In this case, the main problem seems to be that this variant of
 
1236
  losetup takes the offset (-o option) in bytes, while cryptsetup
 
1237
  takes it in sectors of 512 bytes each. Example: The losetupp
 
1238
  command
 
1239
 
 
1240
  losetup -e twofish -o 2560 /dev/loop0 /dev/sdb1 
 
1241
  mount /dev/loop0 mountpoint
 
1242
 
 
1243
  translates to
 
1244
 
 
1245
  cryptsetup create -c twofish -o 5 --skip 5 e1 /dev/sdb1
 
1246
  mount /dev/mapper/e1 mountpoint
 
1247
 
 
1248
 
 
1249
 * loop-aes with 160 bit key
 
1250
 
 
1251
  This seems to be sometimes used with twofish and blowfish and
 
1252
  represents a 160 bit ripemed160 hash output padded to 196 bit key
 
1253
  length. It seems the corresponding options for cryptsetup are
 
1254
 
 
1255
  --cipher twofish-cbc-null -s 192 -h ripemd160:20
 
1256
 
 
1257
 
 
1258
8. Issues with Specific Versions of cryptsetup 
982
1259
 
983
1260
 
984
1261
 * When using the create command for plain dm-crypt with cryptsetup