<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>twam.info &#187; LUKS</title>
	<atom:link href="http://www.twam.info/tag/luks/feed" rel="self" type="application/rss+xml" />
	<link>http://www.twam.info</link>
	<description>My computer, physics, electronics &#38; photography blog</description>
	<lastBuildDate>Wed, 25 Jan 2012 20:49:27 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Using Geode&#8217;s AES engine on ALIX.3D3</title>
		<link>http://www.twam.info/hardware/alix/using-geodes-aes-engine-on-alix3d3</link>
		<comments>http://www.twam.info/hardware/alix/using-geodes-aes-engine-on-alix3d3#comments</comments>
		<pubDate>Wed, 13 May 2009 17:08:45 +0000</pubDate>
		<dc:creator>twam</dc:creator>
				<category><![CDATA[Alix]]></category>
		<category><![CDATA[ALIX.3D3]]></category>
		<category><![CDATA[Encryption]]></category>
		<category><![CDATA[Gentoo]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[LUKS]]></category>

		<guid isPermaLink="false">http://www.twam.info/?p=491</guid>
		<description><![CDATA[The AMD Geode LX800 CPU has an on-chip AES 128-bit crypto accelerations block and a true random number generator. Using this block for encryption and decryption is a lot faster than software implemented algorithms and it unloads the CPU. There are two main purposes where en/decryption is needed: Storing files Communication over network (IPSEC, OpenVPN, [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://www.amd.com/us-en/ConnectivitySolutions/ProductInformation/0,,50_2330_9863_13022,00.html">AMD Geode LX800</a> CPU has an on-chip AES 128-bit crypto accelerations block and a true random number generator. Using this block for encryption and decryption is a lot faster than software implemented algorithms and it unloads the CPU. There are two main purposes where en/decryption is needed:</p>
<ul>
<li>Storing files</li>
<li>Communication over network (IPSEC, OpenVPN, WPA2, &#8230;)</li>
</ul>
<p>I&#8217;ll focus on the first point in this article using <a href="http://en.wikipedia.org/wiki/LUKS">LUKS</a> (Linux Unified Key Setup).</p>
<p><span id="more-491"></span>To use LUKS and the crypto block, some kernel adjustments have to be made:</p>
<pre>Device Drivers  ---&gt;
   [*] Multiple devices driver support (RAID and LVM)  ---&gt;
   &lt;*&gt;   Device mapper support
   &lt;*&gt;     Crypt target support

-*- Cryptographic API  ---&gt;
   -*- Cryptographic algorithm manager
   -*- CBC support
   {*} ECB support
   {*} AES cipher algorithms
   &lt;*&gt; AES cipher algorithms (i586)
   -*-   MD5 digest algorithm
   &lt;*&gt; SHA224 and SHA256 digest algorithm
   [*] Hardware crypto devices  ---&gt;
   &lt;*&gt;   Support for the Geode LX AES engine</pre>
<p>If you want to test with and without crypto acceleration, I recommend compiling the last one as a module. After compiling and rebooting we have to install LUKE userspace tools:</p>
<pre>emerge -v cryptsetup</pre>
<p>That&#8217;s all. Now we&#8217;re ready to test. As we want to bandwidth limitation from a slow CF card or USB stick, we create a memory loopback device for testing purposes with a size of 128 MB:</p>
<pre>mkdir /tmp/tmpfs
mount -t tmpfs none /tmp/tmpfs -o size=130m
dd if=/dev/zero of=/tmp/tmpfs/test.img count=131072 bs=1024
losetup /dev/loop1 /tmp/tmpfs/test.img</pre>
<p>The tmpfs ramdisk is with intent 130MB large, as the maximum default value is 50% of RAM and with that 128 MB wouldn&#8217;t fit in.</p>
<p>At first, we want to measure software AES performance. For this, we have to assure, that the driver for the crypto block is not loaded. You can get a list of all loaded modules with</p>
<pre>lsmod</pre>
<p>If there&#8217;s geode_aes listed, remove it by</p>
<pre>rmmod geode_aes</pre>
<p>Now we can create a LUKS device by</p>
<pre>cryptsetup -y --cipher aes --key-size 128 luksFormat /dev/loop1</pre>
<p>Mind the key size of 128 bit as the Geode crypto block is only capable of 128 bit keys. You have to confirm this command with a uppercase YES and entering the passphrase twice:</p>
<pre>Are you sure? (Type uppercase yes): YES
Enter LUKS passphrase:
Verify passphrase:
Command successful.</pre>
<p>Now we can open the container. Run</p>
<pre>cryptsetup luksOpen /dev/loop1 test</pre>
<p>and enter the previous set passphrase:</p>
<pre>Enter LUKS passphrase:
key slot 0 unlocked.
Command successful.</pre>
<p>The container is now under /dev/mapper/test and we can do some write test by running dd:</p>
<pre>dd if=/dev/zero of=/dev/mapper/test bs=16384</pre>
<p>After a few seconds, dd will terminate, complaining no space left:</p>
<pre>dd: writing `/dev/mapper/test': No space left on device
8160+0 records in
8159+0 records out
133689344 bytes (134 MB) copied, 18.574 s, 7.2 MB/s</pre>
<p>That&#8217;s OK. We can read here there 7.2 MB/s throughput with crypto block. After closing the container with</p>
<pre>cryptsetup luksClose test</pre>
<p>we can load the crypto block driver by</p>
<pre>modprobe geode_aes</pre>
<p>and can run the same commands as above. We&#8217;ll get a</p>
<pre>dd: writing `/dev/mapper/test': No space left on device
8160+0 records in
8159+0 records out
133689344 bytes (134 MB) copied, 4.88397 s, 27.4 MB/s</pre>
<p>noticing that we&#8217;ve got a 27.4 MB/s throughput now! This also works with <a href="http://de.wikipedia.org/wiki/ESSIV">ESSIV</a> as well. It&#8217;s a bit slower, but more secure. You can to alter the luksFormat to use it:</p>
<pre>cryptsetup -y --cipher aes-cbc-essiv:sha256 --key-size 128 luksFormat /dev/loop1</pre>
<p>I measured 7.0 MB/s without and 24.0 MB/s with crypto block. After all testing don&#8217;t forget to remove the loopback device and umount the ramdisk:</p>
<pre>losetup  -d /dev/loop1
umount /tmp/tmpfs/
rmdir /tmp/tmpfs</pre>
<p>Now you can setup your real crypto disk. You might want to initialize your partition with random data before creating the luksContainter. <em>dd</em> is once again your friend:</p>
<pre>dd if=/dev/urandom of=/dev/XXX bs=1M</pre>
<p>Concerning the use of the crypto block for network encryption: By chance it noticed that if I use WPA2 with AES the geode_aes has a 2 in the used row of lsmod:</p>
<pre>Module                  Size  Used by
lib80211_crypt_ccmp     4808  2
ipw2200               115904  0
libipw                 22792  1 ipw2200
geode_aes               5464  2
lib80211                4568  3 lib80211_crypt_ccmp,ipw2200,libipw</pre>
<p>So it seems, like WPA2 is using this as well. If you know a method to confirm this, let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.twam.info/hardware/alix/using-geodes-aes-engine-on-alix3d3/feed</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
	</channel>
</rss>

