{"id":3977,"date":"2013-11-01T10:28:26","date_gmt":"2013-11-01T02:28:26","guid":{"rendered":"https:\/\/www.icocean.com\/wp\/?p=3977"},"modified":"2013-11-01T10:52:58","modified_gmt":"2013-11-01T02:52:58","slug":"truecrypt-versus-luks-speed-test","status":"publish","type":"post","link":"https:\/\/www.icocean.com\/blog\/?p=3977","title":{"rendered":"Truecrypt versus LUKS Speed Test"},"content":{"rendered":"<p>Friday October 26, 2007 by Jason &#8216;vanRijn&#8217; Kasper | 15 Comments<\/p>\n<p>I did a small performance test yesterday and was very surprised by the results. I wanted to see which encrypted filesystem was faster betweeen Truecrypt and LUKS. I created 2 20-gig files, one with Truecrypt and the other with LUKS encryption. Then I mounted the encrypted files and copied a 180 meg file 10 times, synced, and then reported the time taken. Here\u2019s the results:<\/p>\n<p>Truecrypt test:<br \/>\n    time (for f in $(seq 1 10); do; cp bigfile truecrypt-mnt\/bigfile-$f; done;)<br \/>\n    0.22s user 26.30s system 15% cpu 2:47.06 total<\/p>\n<p>LUKS test:<br \/>\n    time (for f in $(seq 1 10); do; cp bigfile luks-mnt\/bigfile-$f; done;)<br \/>\n    0.20s user 8.40s system 15% cpu 55.169 total<\/p>\n<p>Wow. Now, granted, this is a simple enough test, but does anyone have any ideas why LUKS would be 3 times faster in writing 1.8 Gigs than Truecrypt?<br \/>\nhttp:\/\/movingparts.net\/2007\/10\/26\/truecrypt-versus-luks-speed-test\/<br \/>\n<!--nextpage--><\/p>\n<p>anonymous<br \/>\nFriday October 26, 2007 at 6:26 pm\t<\/p>\n<p>Without further information, I would guess they default to using different encryption schemes and\/or key sizes.<br \/>\nben<br \/>\nFriday October 26, 2007 at 6:58 pm\t<\/p>\n<p>I just encrypted my whole linux server (Athlon 1400, 1000 RAM) three days ago using 256bit aes and LUKS. Generally, the whole system does feel really slow now.<\/p>\n<p>CPing a 700MB file from an encrypted LUKS-ext3-partition to \/dev\/null takes 40 seconds (thats 17.5 MB\/s).<\/p>\n<p>DDing 719MB of \/dev\/zero onto the LUKS partition takes 35 seconds, that makes almost 21MB\/s.<\/p>\n<p>Not exactly the values you\u2019d hope for after installing a new 500GB SATA drive ;( I\u2019d really like to know about your ciphers, keysizes and system specs for comparison\u2026<br \/>\nAndreas<br \/>\nFriday October 26, 2007 at 9:31 pm\t<\/p>\n<p>ben: if you had an idea how many steps any secure encryption algorithm requires you\u2019d wonder why it still works so *fast*. Linux even contains an assembly optimized implementation of AES. An interesting experiment would be to verify if, on a modern processor, the C version with profiling and all optimizations is still slower than the assembly version. The assembly version is hand-optimized for pentium class CPUs. I\u2019ve never tried profiling the kernel but it is possible AFAIK.<br \/>\nSebastian<br \/>\nFriday October 26, 2007 at 10:50 pm\t<\/p>\n<p>Thanks for the hint on LUKS, I didn\u2019t know that before.<br \/>\nPau Garcia i Quiles<br \/>\nSaturday October 27, 2007 at 4:29 am\t<\/p>\n<p>Did you run the LUKS test right after the TrueCrypt test? If so, the speed gain may very well be due to caching of \u2018bigfile\u2019.<\/p>\n<p>The test should be done in the very same conditions: hard disks already working and \u2018bigfile\u2019 cached or not cached for both algorithms. I\u2019d suggest retrying using this methodology:<br \/>\n1. Cold start your computer, TrueCrypt test. This is the \u201ccold test time\u201d.<br \/>\n2. TrueCrypt test again. This is the \u201ccached test time\u201d, as \u2018bigfile\u2019 is probably cached wholly or in part.<\/p>\n<p>Shutdown your computer and repeat for LUKS. Then compare the \u201ccold test times\u201d for LUKS and TrueCrypt and the \u201ccached test time\u201d for LUKS and TrueCrypt.<\/p>\n<p>Probably LUKS would still be faster than TrueCrypt, but this way we will be sure.<br \/>\nfrank<br \/>\nSaturday October 27, 2007 at 6:05 am\t<\/p>\n<p>ben: you compare reading\/decoding with writing\/encoding. Thats not fair\u2026<\/p>\n<p>I tried following with loop-AES on a Pentium III-M 1.2GHz<br \/>\ntime dd if=\/dev\/zero of=\/tmp\/testfile bs=1M count=700<\/p>\n<p>Without encryption:<br \/>\n24,3748 seconds, 30,1 MB\/s<br \/>\n0,00s user 4,15s system 16% cpu 24,503 total<\/p>\n<p>With AES-256:<br \/>\n41,2084 seconds, 17,8 MB\/s<br \/>\n0,00s user 12,30s system 29% cpu 41,213 total<\/p>\n<p>I don\u2019t have TrueCrypt or LUKS to compare with, sorry<br \/>\nben<br \/>\nSaturday October 27, 2007 at 7:05 am\t<\/p>\n<p>frank: Huh? I just listed the performance of both processes. I don\u2019t want to compare encoding with decoding, I want to compare to other machines.<\/p>\n<p>In essence, I\u2019d really like to know what an upgrade to e.g. a Core2Duo would give me. And whether the en\/decryption would use both CPUs.<br \/>\nFrank<br \/>\nSaturday October 27, 2007 at 7:31 am\t<\/p>\n<p>ben: Uh, sorry. I thought you would compare LUKS with TrueCrypt. Must have been too fast reading\u2026<br \/>\nben<br \/>\nSaturday October 27, 2007 at 8:44 am\t<\/p>\n<p>Here it comes:<br \/>\nIntel(R) Core(TM)2 CPU 6600 @ 2.40GHz<\/p>\n<p>cryptsetup -c aes-cbc-essiv:sha256 -y -s 256 luksFormat \/dev\/sda3<br \/>\ncryptsetup luksOpen \/dev\/sda3 crypt<br \/>\nmkfs.ext3 -m 0 -j -L test \/dev\/mapper\/crypt<br \/>\nmount \/dev\/mapper\/crypt \/mnt\/temp1\/<\/p>\n<p>time dd if=\/dev\/zero of=\/mnt\/temp1\/file.zero bs=1M count=700 takes 10.7 seconds<br \/>\ntime cp \/mnt\/temp1\/file.zero \/dev\/null takes 10.3 seconds<\/p>\n<p>During these ten seconds, both CPUs are saturated. Nice \ud83d\ude09<br \/>\nFrank<br \/>\nSaturday October 27, 2007 at 9:20 am\t<\/p>\n<p>Nice, still would love to see how it compares to loop-AES\u2026<br \/>\nbosco<br \/>\nSaturday March 14, 2009 at 2:11 pm\t<\/p>\n<p>this might be old just as tipp th mode cbc is not secure anymore (cryptsetup -c aes-cbc-essiv:sha25)<br \/>\ntruecrypt uses xts the mode wich is adviced only the newest kernel supports it now.<\/p>\n<p>but at least lrw mode is needed to havea secure entcryption<br \/>\nin case of big HDDs modes a far more important.<\/p>\n<p>but i must give you credits even on my core 2 duo 3Ghrz truecrypt \u201cwas\u201dslower but now \u2026 i dunno they made a lot ofimprovements<br \/>\nSicarius<br \/>\nMonday June 29, 2009 at 4:25 am\t<\/p>\n<p>Far as I know Luks is directly used as a kernel-module,<br \/>\nwhereas TrueCrypt isn\u2019t. This may be a major reason for the speed difference, since, as far as I know, the special assembly implementation is mostly the same in TrueCrypt and Luks. (Since both are OpenSource and same subject it sounds pretty logical \ud83d\ude09 )<br \/>\nBrandon<br \/>\nMonday December 14, 2009 at 1:43 am\t<\/p>\n<p>This is basically what Sicarius said, TrueCrypt is a FUSE File System Under Userspace module. Truecrypt is slow for the same reason that ntfs-3g is slow. (Actually ntfs-3g isn\u2019t that bad, but a filesystem shouldn\u2019t take up 20-30% of your CPU when ext4 takes <1%). Essentially it is slow because it has to constantly switch between kernel space and user space when writing\/reading from the disk because the actual write system call is a kernel mode call which must then make a userspace call to FUSE which must then make a kernel call to the disk controller. (If you know anything about threads, than you will know that userspace threads are much faster (sometimes up to 40x) than kernel threads because a full context switch is a very expensive operation).\nSeventeener\nSunday December 20, 2009 at 1:48 pm\t\n\nI can confirm the performance results. I have two external 3.5-inch Seagate drives: one is ntfs over truecrypt, the other is ext4 over luks. The last one is nearly four times faster!\nmrm00\nThursday January 14, 2010 at 3:28 pm\t\n\ntime dd if=\/dev\/zero of=\/media\/truecrypt1\/testfile bs=1M count=700\n700+0 Datens\u00e4tze ein\n700+0 Datens\u00e4tze aus\n734003200 Bytes (734 MB) kopiert, 9,29997 s, 78,9 MB\/s\n\nreal 0m9.363s\nuser 0m0.000s\nsys 0m2.344s\n<!--nextpage--><br \/>\n<strong>[dm-crypt] LUKS &#038; TrueCrypt &#8211; Speed Test<\/strong><br \/>\nJorge F\u00e1bregas jorge.fabregas at gmail.com<br \/>\nThu Jul 28 01:18:24 CEST 2011<\/p>\n<p>Hello everyone,<\/p>\n<p>Inspired by this old blog post:<\/p>\n<p>http:\/\/movingparts.net\/2007\/10\/26\/truecrypt-versus-luks-speed-test\/<\/p>\n<p>&#8230;I decided to perform some tests on my Fedora 14 box.   This is not a<br \/>\npro benchmark so be warned \ud83d\ude42<\/p>\n<p>Common Facts for both tests:<\/p>\n<p>&#8211; source &#038; destination filesystems were ext4<br \/>\n&#8211; destination is an external USB drive<br \/>\n&#8211; source data size is 143GB (a folder with lots of files &#038; directories,<br \/>\nsmall &#038; large files, regular data&#8230;)<br \/>\n&#8211; rsync was used to perform the actual copy<br \/>\n&#8211; I&#8217;m using an &#8220;encrypted partition &#8221; (against an encrypted file)<br \/>\n&#8211; I did a test first with TrueCrypt and then with LUKS<br \/>\n&#8211; Between the above tests, I shut down the machine (to flush filesystem<br \/>\ncache).<br \/>\n&#8211; my system kernel: 2.6.35.13-92.fc14.i686<\/p>\n<p>### TrueCrypt Results ####<br \/>\nI used AES-256 (XTS operation mode), hash algorithm: ripemd-160 and the<br \/>\npackage was realcrypt-7.0a-1.fc14.i686<\/p>\n<p>Output of time command after rsync finished:<\/p>\n<p>real\t105m22.211s<br \/>\nuser\t28m10.471s<br \/>\nsys\t41m35.319s<\/p>\n<p>### DM-Crypt LUKS Results ###<br \/>\nI used the defaults:  AES-256 (CBC), sha1 for header hashing and the<br \/>\npackage cryptsetup-luks-1.1.3-1.fc14.i686<\/p>\n<p>Output of time command after rsync finished:<\/p>\n<p>real\t108m55.291s<br \/>\nuser\t28m6.534s<br \/>\nsys\t42m53.400s<\/p>\n<p>As you can see, there&#8217;s almost a 4 minute difference.  I was expecting<br \/>\nLUKS to be faster (as dm-crypt is a kernel module) and TrueCrypt runs<br \/>\nmainly in user space isn&#8217;t it?  Do you think the cipher operation modes<br \/>\n(XTS vs CBC) played a role in this difference? Have any of you performed<br \/>\na similar test?<\/p>\n<p>Regards,<br \/>\nJorge<br \/>\nhttp:\/\/www.saout.de\/pipermail\/dm-crypt\/2011-July\/001838.html<br \/>\n<!--nextpage--><br \/>\nArno Wagner arno at wagner.name<br \/>\nThu Jul 28 07:11:17 CEST 2011<\/p>\n<p>There is an old gemran egineering saying:<\/p>\n<p>&#8220;wer mist mist mist&#8221; <\/p>\n<p>(along the lines of &#8220;Those who measure measure crap&#8221;)<br \/>\nI think it applies here.<\/p>\n<p>Real-time is tricky. It does not reflect effort invested. If you<br \/>\nlook at the sys itime, you see that the crypto-effort is only about<br \/>\n90 seconds more. Even that is pretty much below the measurement<br \/>\nerror. Very likely the differences are due to storage differences<br \/>\nand do not show crypto-speed differences.<\/p>\n<p>I suggest you run both tests at least 3 times and make sure<br \/>\nyour storage is significantly faster than the crypto, e.g.<br \/>\nby doing this between RAM disks or SSD storage. Also a complex<br \/>\ndisk access patterhn like rsync is not suitable as it may<br \/>\nhave complex interactions with caching and buffering.<\/p>\n<p>Arno<br \/>\n&#8212;<br \/>\nArno Wagner, Dr. sc. techn., Dipl. Inform., CISSP &#8212; Email: arno at wagner.name<br \/>\nGnuPG:  ID: 1E25338F  FP: 0C30 5782 9D93 F785 E79C  0296 797F 6B50 1E25 338F<br \/>\n<!--nextpage--><br \/>\nJorge F\u00e1bregas jorge.fabregas at gmail.com<br \/>\nFri Jul 29 01:58:58 CEST 2011<\/p>\n<p>Hi everyone,<\/p>\n<p>I performed the tests again (twice for each test) but this time I<br \/>\nformatted the LUKS partition using:<\/p>\n<p>cryptsetup luksFormat -c aes-xts-plain -s 256 -h ripemd160 \/dev\/sdd1<\/p>\n<p>&#8230;so that I was more _similar_ to the TrueCrypt setup.  Also, between<br \/>\neach test I run:<\/p>\n<p>echo 3 > \/proc\/sys\/vm\/drop_caches<\/p>\n<p>Here are the new results for the same payload (143 GB of data):<\/p>\n<p>### TRUECRYPT ####<\/p>\n<p>1st round:<br \/>\nreal\t105m39.547s<br \/>\nuser\t28m17.667s<br \/>\nsys\t42m25.300s<\/p>\n<p>2nd round:<br \/>\nreal\t105m40.271s<br \/>\nuser\t28m21.893s<br \/>\nsys\t42m19.672s<\/p>\n<p>### LUKS ###<\/p>\n<p>1st round:<br \/>\nreal\t104m33.901s<br \/>\nuser\t27m41.362s<br \/>\nsys\t41m0.339s<\/p>\n<p>2nd round:<br \/>\nreal\t104m44.913s<br \/>\nuser\t27m42.364s<br \/>\nsys\t40m57.655s<\/p>\n<p>Now as you may see, LUKS is roughly around 1 minute ahead (sytem-time)<br \/>\ncompared to TrueCrypt.  It appears the change in cipher operation mode<br \/>\ndefinitely affected the results (thing I should have done on the first<br \/>\nplace).<\/p>\n<p>Cheers and thank your for the feedback!<br \/>\nJorge<\/p>\n<nav class=\"page-links\"><strong>\u9875\u9762\uff1a<\/strong> <a href=\"https:\/\/www.icocean.com\/blog\/?p=3977\" class=\"post-page-numbers\"><span class=\"page-num\">1<\/span><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/?p=3977&#038;page=2\" class=\"post-page-numbers\"><span class=\"page-num\">2<\/span><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/?p=3977&#038;page=3\" class=\"post-page-numbers\"><span class=\"page-num\">3<\/span><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/?p=3977&#038;page=4\" class=\"post-page-numbers\"><span class=\"page-num\">4<\/span><\/a> <a href=\"https:\/\/www.icocean.com\/blog\/?p=3977&#038;page=5\" class=\"post-page-numbers\"><span class=\"page-num\">5<\/span><\/a><\/nav>\n","protected":false},"excerpt":{"rendered":"<p>Friday October 26, 2007 by Jason &#8216;vanRijn&#8217;  <a href='https:\/\/www.icocean.com\/blog\/?p=3977' class='excerpt-more'>[&#8230;]<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[3894,3893,3891,3892,3298,128,129,1533],"class_list":["post-3977","post","type-post","status-publish","format-standard","hentry","category-4","tag-crypt","tag-decrypt","tag-luks","tag-speed","tag-truecrypt","tag-128","tag-129","tag-1533","category-4-id","post-seq-1","post-parity-odd","meta-position-corners","fix"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3977","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3977"}],"version-history":[{"count":2,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3977\/revisions"}],"predecessor-version":[{"id":3979,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/3977\/revisions\/3979"}],"wp:attachment":[{"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3977"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3977"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.icocean.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3977"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}