Do you have a netbook, laptop, desktop or a server which uses dm-crypt to encrypt data on your disks? If yes, you will probably find that raw hard disk performance is better than encrypted disk performance. You will notice that especially on slow machines (i.e. netbooks), but also high-performance servers, because of the current dm-crypt design.

What cipher in the Linux kernel provides you with the best performance?

Currently, dm-crypt in the Linux kernel suffers from at least one performance-wise flaw: it is not SMP aware. This means, even if you have several CPUs in your machine, only one processor will be used to encrypt/decrypt data (ed. 31-May-2010: there was a patch posted today to make dm-crypt scale to multiple CPUs).

With moderately fast disks and RAID arrays in a server, you will hit a a limit where one processor is not able to encrypt/decrypt data fast enough. With netbooks and slow CPUs, and probably fast SSD disks, you will hit this limit even earlier.

Here is a list of different ciphers and throughput they delivered, when reading from a given device linearly.

The tests were made on a Celeron 2.93GHz CPU with Seagate Barracuda 7200.11 SATA 3Gb/s 1.5-TB ST31500341AS disks. Raw linear speed of these disks was about 105 MB/s.

What performance could different ciphers deliver on this machine? Note that you have to consider security implications / encryption strength yourself when using custom encryption schemes (i.e. using -essiv instead of -plain on similar hardware will usually decrease the performance by about 10 MB/s, but your encryption should be “harder to crack”).

Default parameters for creating an encrypted device are:

cryptsetup luksFormat /dev/$DEVICE

You can add options like:

cryptsetup luksFormat -c cast5-cbc-plain -s 128 /dev/$DEVICE

To open an encrypted device:

cryptsetup luksOpen /dev/$DEVICE $SOMENAME

You will have a new block device in /dev/mapper/$SOMENAME, which you can i.e. use for a filesystem

@Frank: “-c aes-xts-plain -s 128″ can’t work though. The key needs to be at least 256 bit long. The kernel Kconfig help suggests that for XTS you need to double the key size (so aes-xts-plain: 256/384/512 bits). That’s neccessary because one part of the key is used by XTS and the other by AES. It’s also strange that the bigger the keysize gets the more read/write throughput you get.

Seems a flawed post, the most important benchmark was missing and thats the one with the default options (without -c set), so now I am sitting here wondering where does the default option sit in that league table.

To print a table with 3 digit precision and then say that the default (essiv) will be “about 10 MB/s” slower than something somewhere in the table makes no sense. If anything is worth measuring precisely for comparison’s sake, it’s the default. And if anything is worth listing explicitly in the table, it’s the default.

I don’t doubt that you measured 10 MB/s difference, but that’s 1 digit precision. You listed everything else with 3 digits, so this should be too.

You have an authoritative source that it is not able to use multiple cores? Because Fruwith even fought with the kernel devel guys to restructure the kernel so that luks could run LRW (hence parallel). And that was 5 years ago.

I tested about 1200 combinations of cipher, cipher mode, iv hash, and key length based on the available blkciphers, hashes, and modes in /proc/crypto on an OpenSuSE 11.2 system. Each test was run ten times on a one gig, memory backed loopback device. I skipped a number of irrelevant configurations (tnepres, xeta, arc4, essiv hashes for xts modes, etc.) but a few weird setups still make the list (michael_mic for an essiv hash and every possible key length for blowfish, for example.)

All tests were run on a system with a single dual core Xeon 5160 processor and 4 GB of RAM. Caches were dropped before each test.

In his test script, he runs “cryptsetup … luksFormat …” without checking for an error. If a previous iteration left a valid luks device AND the failed luksFormat left loop0 unmodified, the subsequent luksOpen would succeed and the benchmark would run for the previous cipher-mode-iv combination. This appears to explain why there are valid results for impossible modes such as “-c aes-xts-plain -s 128″ (128 is an invalid blocksize for aes-xts), “-c blowfish-xts-X” and “cast5-xts-X” (blowfish and cast5 have 8 byte block size and won’t work in XTS mode at all), anything with salsa20 (salsa20 is a stream cipher), and “-c arc4-xts-plain -s arc4″ (interesting block size, that.)

Are there any news concerning benchmarks and dm-crypt since the last comments were posted on this blog about a year ago? In particular, how is the multi-CPU-support coming that you mentioned on May 31 last year?

By the way, I really appreciate this site, even if my previous comments may have sounded quite critical. Keep up the good work!