Fix default modes in man page.
[platform/upstream/cryptsetup.git] / FAQ
diff --git a/FAQ b/FAQ
index 3436d8d..3288a9a 100644 (file)
--- a/FAQ
+++ b/FAQ
@@ -41,7 +41,7 @@ A. Contributors
   SSDs/FLASH DRIVES: SSDs and Flash are different. Currently it is
   unclear how to get LUKS or plain dm-crypt to run on them with the
   full set of security features intact. This may or may not be a
-  problem, depending on the attacher model. See Section 5.17.
+  problem, depending on the attacher model. See Section 5.19.
 
   BACKUP: Yes, encrypted disks die, just as normal ones do. A full
   backup is mandatory, see Section "6. Backup and Data Recovery" on
@@ -136,13 +136,17 @@ A. Contributors
 
  * 1.5 Who wrote this?
 
-  Current FAQ maintainer is Arno Wagner <arno@wagner.name>. Other
-  contributors are listed at the end. If you want to contribute, send
-  your article, including a descriptive headline, to the maintainer,
-  or the dm-crypt mailing list with something like "FAQ ..." in the
-  subject. You can also send more raw information and have me write
-  the section. Please note that by contributing to this FAQ, you
-  accept the license described below.
+  Current FAQ maintainer is Arno Wagner <arno@wagner.name>. If you
+  want to send me encrypted email, my current PGP key is DSA key
+  CB5D9718, fingerprint 12D6 C03B 1B30 33BB 13CF B774 E35C 5FA1 CB5D
+  9718.
+
+  Other contributors are listed at the end. If you want to contribute,
+  send your article, including a descriptive headline, to the
+  maintainer, or the dm-crypt mailing list with something like "FAQ
+  ..." in the subject. You can also send more raw information and
+  have me write the section. Please note that by contributing to this
+  FAQ, you accept the license described below.
 
   This work is under the "Attribution-Share Alike 3.0 Unported"
   license, which means distribution is unlimited, you may create
@@ -214,7 +218,82 @@ A. Contributors
 2. Setup 
 
 
- * 2.1 What is the difference between "plain" and LUKS format?
+ * 2.1 LUKS Container Setup mini-HOWTO
+
+  This item tries to give you a very brief list of all the steps you
+  should go though when creating a new LUKS encrypted container, i.e.
+  encrypted disk, partition or loop-file.
+
+  01) All data will be lost, if there is data on the target, make a 
+  backup.
+
+  02) Make very sure you have the right target disk, partition or
+  loop-file.
+
+  03) If the target was in use previously, it is a good idea to
+  wipe it before creating the LUKS container in order to remove any
+  trace of old file systems and data. For example, some users have
+  managed to run e2fsck on a partition containing a LUKS container,
+  possibly because of residual ext2 superblocks from an earlier use.
+  This can do arbitrary damage up to complete and permanent loss of
+  all data in the LUKS container.
+
+  To just quickly wipe file systems (old data may remain), use
+
+     wipefs -a <target device>
+  To wipe file system and data, use something like
+
+     cat /dev/zero > <target device>
+  This can take a while. To get a progress indicator, you can use
+  the tool dd_rescue (->google) instead or use my stream meter "wcs"
+  (source here: http://www.tansi.org/tools/index.html) in the
+  following fashion:
+
+     cat /dev/zero | wcs > <target device>
+  Be very sure you have the right target, all data will be lost!
+
+  Note that automatic wiping is on the TODO list for cryptsetup, so
+  at some time in the future this will become unnecessary.
+
+  04) Create the LUKS container:
+     cryptsetup luksFormat <target device>
+  Just follow the on-screen instructions.
+
+  05) Map the container. Here it will be mapped to /dev/mapper/c1:
+     cryptsetup luksOpen <target device> c1 
+  06) (Optionally) wipe the container (make sure you have the right target!):
+     cat /dev/zero > /dev/mapper/c1
+      
+  Note that this creates a small information leak, as an attacker can
+  determine whether a 512 byte block is zero if the attacker has
+  access to the encrypted container multiple times. Typically a
+  competent attacker that has access multiple times can install a
+  passphrase sniffer anyways, so this leakage is not very
+  significant. For getting a progress indicator, see step 03.
+
+  Note that at some time in the future, cryptsetup will do this for
+  you, but currently it is a TODO list item.
+
+  07) Create a file system in the mapped container, for example an 
+  ext3 file system (any other file system is possible):
+
+     mke2fs -j /dev/mapper/c1
+  08) Mount your encrypted file system, here on /mnt:
+     mount /dev/mapper/c1 /mnt 
+  Done. You can now use the encrypted file system to store data. Be
+  sure to read though the rest of the FAQ, these are just the very
+  basics. In particular, there are a number of mistakes that are
+  easy to make, but will compromise your security.
+
+
+ * 2.2 What is the difference between "plain" and LUKS format?
 
   First, unless you happen to understand the cryptographic background
   well, you should use LUKS. It does protect the user from a lot of
@@ -234,13 +313,24 @@ A. Contributors
 
   Side-note: That has limited value against the authorities. In
   civilized countries, they cannot force you to give up a crypto-key
-  anyways. In the US, the UK and dictatorships around the world,
-  they can force you to give up the keys (using imprisonment or worse
-  to pressure you), and in the worst case, they only need a
-  nebulous "suspicion" about the presence of encrypted data. My
-  advice is to either be ready to give up the keys or to not have
+  anyways. In quite a few countries around the world, they can force
+  you to give up the keys (using imprisonment or worse to pressure
+  you, sometimes without due process), and in the worst case, they
+  only need a nebulous "suspicion" about the presence of encrypted
+  data. Sometimes this applies to everybody, sometimes only when you
+  are suspected of having "illicit data" (definition subject to
+  change) and sometimes specifically when crossing a border. Note
+  that this is going on in countries like the US and the UK, to
+  different degrees and sometimes with courts restricting what the
+  authorities can actually demand.
+
+  My advice is to either be ready to give up the keys or to not have
   encrypted data when traveling to those countries, especially when
-  crossing the borders.
+  crossing the borders. The latter also means not having any
+  high-entropy (random) data areas on your disk, unless you can
+  explain them and demonstrate that explanation. Hence doing a
+  zero-wipe of all free space, including unused space, may be a good
+  idea.
 
   Disadvantages are that you do not have all the nice features that
   the LUKS metadata offers, like multiple passphrases that can be
@@ -268,7 +358,7 @@ A. Contributors
   non-default XTS mode).
 
 
- * 2.2 Can I encrypt an already existing, non-empty partition to use
+ * 2.3 Can I encrypt an already existing, non-empty partition to use
    LUKS?
 
   There is no converter, and it is not really needed. The way to do
@@ -283,7 +373,7 @@ A. Contributors
   to be in a filesystem.
 
 
- * 2.3 How do I use LUKS with a loop-device?
+ * 2.4 How do I use LUKS with a loop-device?
 
   This can be very handy for experiments. Setup is just the same as
   with any block device. If you want, for example, to use a 100MiB
@@ -297,7 +387,7 @@ A. Contributors
   To unmap the file when done, use "losetup -d /dev/loop0".
 
 
- * 2.4 When I add a new key-slot to LUKS, it asks for a passphrase but
+ * 2.5 When I add a new key-slot to LUKS, it asks for a passphrase but
    then complains about there not being a key-slot with that
    passphrase?
 
@@ -309,7 +399,7 @@ A. Contributors
   new key-slot.
 
 
- * 2.5 Encryption on top of RAID or the other way round?
+ * 2.6 Encryption on top of RAID or the other way round?
 
   Unless you have special needs, place encryption between RAID and
   filesystem, i.e. encryption on top of RAID. You can do it the other
@@ -318,8 +408,24 @@ A. Contributors
   not work anymore. Therefore it is better to encrypt the RAID
   device, e.g. /dev/dm0 .
 
+  This means that the typical layering looks like this:
+
+  Filesystem     <- top
+  |
+  Encryption
+  |
+  RAID
+  |
+  Raw partitions
+  |
+  Raw disks      <- bottom
+  The big advantage is that you can manage the RAID container just
+  like any RAID container, it does not care that what is in it is
+  encrypted.
 
- * 2.6 How do I read a dm-crypt key from file?
+
+ * 2.7 How do I read a dm-crypt key from file?
 
   Note that the file will still be hashed first, just like keyboard
   input. Use the --key-file option, like this:
@@ -327,7 +433,7 @@ A. Contributors
       cryptsetup create --key-file keyfile e1 /dev/loop0
  
 
- * 2.7 How do I read a LUKS slot key from file?
+ * 2.8 How do I read a LUKS slot key from file?
 
   What you really do here is to read a passphrase from file, just as
   you would with manual entry of a passphrase for a key-slot. You can
@@ -353,7 +459,7 @@ A. Contributors
       cryptsetup luksOpen --key-file keyfile /dev/loop0 e1
  
 
- * 2.8 How do I read the LUKS master key from file?
+ * 2.9 How do I read the LUKS master key from file?
 
   The question you should ask yourself first is why you would want to
   do this. The only legitimate reason I can think of is if you want
@@ -364,7 +470,7 @@ A. Contributors
   do this here.
 
 
- * 2.9 What are the security requirements for a key read from file?
+ * 2.10 What are the security requirements for a key read from file?
 
   A file-stored key or passphrase has the same security requirements
   as one entered interactively, however you can use random bytes and
@@ -376,7 +482,7 @@ A. Contributors
       head -c 256 /dev/random > keyfile
  
 
- * 2.10 If I map a journaled file system using dm-crypt/LUKS, does it
+ * 2.11 If I map a journaled file system using dm-crypt/LUKS, does it
    still provide its usual transactional guarantees?
 
   Yes, it does, unless a very old kernel is used. The required flags
@@ -404,7 +510,7 @@ A. Contributors
   should improve further and eventually the problem should go away.
 
 
- * 2.11 Can I use LUKS or cryptsetup with a more secure (external)
+ * 2.12 Can I use LUKS or cryptsetup with a more secure (external)
    medium for key storage, e.g. TPM or a smartcard?
 
   Yes, see the answers on using a file-supplied key. You do have to
@@ -413,8 +519,12 @@ A. Contributors
   own tool that in turn gets the key from the more secure key
   storage.
 
+  For TPM support, you may want to have a look at tpm-luks at
+  https://github.com/shpedoikal/tpm-luks. Note that tpm-luks is not
+  related to the cryptsetup project.
+
 
- * 2.12 Can I resize a dm-crypt or LUKS partition?
+ * 2.13 Can I resize a dm-crypt or LUKS partition?
 
   Yes, you can, as neither dm-crypt nor LUKS stores partition size.
   Whether you should is a different question. Personally I recommend
@@ -434,6 +544,47 @@ A. Contributors
   for that.
 
 
+ * 2.14 How do I Benchmark the Ciphers, Hashes and Modes?
+
+  Since version 1.60 cryptsetup supports the "benchmark" command.
+  Simply run as root:
+
+   cryptsetup benchmark
+  It will output first iterations/second for the key-derivation
+  function PBKDF2 parameterized with different hash-functions, and
+  then the raw encryption speed of ciphers with different modes and
+  key-sizes. You can get more than the default benchmarks, see the
+  man-page for the relevant parameters. Note that XTS mode takes two
+  keys, hence the listed key sizes are double that for other modes
+  and half of it is the cipher key, the other half is the XTS key.
+
+
+ * 2.15 How do I Verify I have an Authentic cryptsetup Source Package?
+
+  Current maintainer is Milan Broz and he signs the release packages
+  with his PGP key. The key he currently uses is the "RSA key ID
+  D93E98FC", fingerprint 2A29 1824 3FDE 4664 8D06 86F9 D9B0 577B
+  D93E 98FC. While I have every confidence this really is his key and
+  that he is who he claims to be, don't depend on it if your life is
+  at stake. For that matter, if your life is at stake, don't depend
+  on me being who I claim to be either.
+
+  That said, as cryptsetup is under good version control, a malicious
+  change should be noticed sooner or later, but it may take a while.
+  Also, the attacker model makes compromising the sources in a
+  non-obvious way pretty hard. Sure, you could put the master-key
+  somewhere on disk, but that is rather obvious as soon as somebody
+  looks as there would be data in an empty LUKS container in a place
+  it should not be. Doing this in a more nefarious way, for example
+  hiding the master-key in the salts, would need a look at the
+  sources to be discovered, but I think that somebody would find that
+  sooner or later as well.
+
+  That said, this discussion is really a lot more complicated and
+  longer as an FAQ can sustain. If in doubt, ask on the mailing list.
+
+
 3. Common Problems 
 
 
@@ -542,7 +693,38 @@ A. Contributors
   diagnosing and (if still possible) repairing this.
 
 
- * 4.2 Can a bad RAM module cause problems?
+ * 4.2 I cannot unlock my LUKS container! What could be the problem?
+
+  First, make sure you have a correct passphrase. Then make sure you
+  have the correct key-map and correct keyboard. And then make sure
+  you have the correct character set and encoding, see also
+  "PASSPHRASE CHARACTER SET" under Section 1.2.
+
+  If you are sure you are entering the passphrase right, there is the
+  possibility that the respective key-slot has been damaged. There
+  is no way to recover a damaged key-slot, except from a header
+  backup (see Section 6). For security reasons, there is also no
+  checksum in the key-slots that could tell you whether a key-slot has
+  been damaged. The only checksum present allows recognition of a
+  correct passphrase, but that only works if the passphrase is
+  correct and the respective key-slot is intact.
+
+  In order to find out whether a key-slot is damaged one has to look
+  for "non-random looking" data in it. There is a tool that
+  automatizes this in the cryptsetup distribution from version 1.6.0
+  onwards. It is located in misc/keyslot_checker/. Instructions how
+  to use and how to interpret results are in the README file. Note
+  that this tool requires a libcryptsetup from cryptsetup 1.6.0 or
+  later (which means libcryptsetup.so.4.5.0 or later). If the tool
+  complains about missing functions in libcryptsetup, you likely
+  have an earlier version from your distribution still installed. You
+  can either point the symbolic link(s) from libcryptsetup.so.4 to
+  the new version manually, or you can uninstall the distribution
+  version of cryptsetup and re-install that from cryptsetup >= 1.6.0
+  again to fix this.
+
+
+ * 4.3 Can a bad RAM module cause problems?
 
   LUKS and dm-crypt can give the RAM quite a workout, especially when
   combined with software RAID. In particular the combination RAID5 +
@@ -584,7 +766,7 @@ A. Contributors
   did a verify.
 
 
- * 4.3 How do I test RAM?
+ * 4.4 How do I test RAM?
 
   First you should know that overclocking often makes memory
   problems worse. So if you overclock (which I strongly recommend
@@ -1022,7 +1204,7 @@ A. Contributors
   power, all of it with plenty of memory for computing "large
   memory" hashes. Bot-net operators also have all the memory they
   want. The only protection against a resourceful attacker is a
-  high-entropy passphrase, see items 5.8 and 5.9.
+  high-entropy passphrase, see items 5.9 and 5.10.
 
 
  * 5.12 What about iteration count with plain dm-crypt?
@@ -1197,7 +1379,7 @@ A. Contributors
   foot, you can figure out how to do it yourself.
 
 
- * 5.19 What about SSDs or Flash Drives?
+ * 5.19 What about SSDs, Flash and Hybrid Drives?
 
   The problem is that you cannot reliably erase parts of these
   devices, mainly due to wear-leveling and possibly defect
@@ -1211,7 +1393,7 @@ A. Contributors
   done in some fashion so that larger writes do not cause a lot of
   small internal updates.
 
-  The thing is that the mappings between outside-adressable sectors
+  The thing is that the mappings between outside-addressable sectors
   and inside sectors is arbitrary (and the vendors are not talking).
   Also the discarded sectors are not necessarily erased immediately.
   They may linger a long time.
@@ -1240,11 +1422,15 @@ A. Contributors
 
   If you trust the device vendor (you probably should not...) you can
   try an ATA "secure erase" command for SSDs. That does not work for
-  USB keys though. And if it finishes after a few seconds, it was
-  possibly faked by the SSD.
+  USB keys though and may or may not be secure for a hybrid drive. If
+  it finishes on an SSD after a few seconds, it was possibly faked.
+  UNfortunately, for hybrid drives that indicator does not work, as
+  the drive may well take the time to dully erase the magnetic part,
+  but only mark the SSD/Flash part as erased while data is still in
+  there.
 
   If you can do without password management and are fine with doing
-  physical destruction for permenently deleting data (allways after
+  physical destruction for permanently deleting data (always after
   one or several full overwrites!), you can use plain dm-crypt or
   LUKS.
 
@@ -1255,13 +1441,13 @@ A. Contributors
   security as on a magnetic disk.
 
   If you are concerned about your laptop being stolen, you are likely
-  fine using LUKS on an SSD. An attacker would need to have access
-  to an old passphrase (and the key-slot for this old passphrase
-  would actually need to still be somewhere in the SSD) for your
-  data to be at risk. So unless you pasted your old passphrase all
-  over the Internet or the attacker has knowledge of it from some
-  other source and does a targetted laptop theft to get at your
-  data, you should be fine.
+  fine using LUKS on an SSD or hybrid drive. An attacker would need
+  to have access to an old passphrase (and the key-slot for this old
+  passphrase would actually need to still be somewhere in the SSD)
+  for your data to be at risk. So unless you pasted your old
+  passphrase all over the Internet or the attacker has knowledge of
+  it from some other source and does a targeted laptop theft to get
+  at your data, you should be fine.
 
 
 6. Backup and Data Recovery 
@@ -1846,7 +2032,7 @@ http://code.google.com/p/cryptsetup/source/browse/misc/luks-header-from-active
   - Some code examples are in the source package under docs/examples
 
 
 * *Brute-forciong passphrases
* Brute-forcing passphrases
 
   -
   http://news.electricalchemy.net/2009/10/password-cracking-in-cloud-part-5.html