<?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>Runtux Blog &#187; documentation</title>
	<atom:link href="http://blog.runtux.com/category/documentation/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.runtux.com</link>
	<description>Neues, Interessantes, Skurriles</description>
	<lastBuildDate>Fri, 23 Sep 2011 08:09:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>SIGALRM blocked forever &#8212; by init</title>
		<link>http://blog.runtux.com/2011/09/23/194/</link>
		<comments>http://blog.runtux.com/2011/09/23/194/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 08:09:43 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[skurril]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=194</guid>
		<description><![CDATA[I&#8217;m working on an embedded Linux system which allows to chose the root filesystem to boot from (flash card or NAND flash) early in the boot process. Now I was trying to get ppp (for a GSM/GPRS connection) working. But the chat-script hangs forever, it does not get a timeout. Turns out, chat uses alarm(2) [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m working on an embedded Linux system which allows to chose the root filesystem to boot from (flash card or NAND flash) early in the boot process. Now I was trying to get ppp (for a GSM/GPRS connection) working. But the chat-script hangs forever, it does not get a timeout. Turns out, chat uses alarm(2) to wait for a timeout. After quite some time of debugging I found out that SIGALRM is blocked (look for <code>SigBlk</code> in <code>/proc/pid/status</code>, this is the mask of blocked signals for process with <code>pid</code>).</p>
<p>After some googling I came across a <a href="http://www.landley.net/notes.html">blog entry</a> (look for September 5, 2011) that describes a bug in bash: Bash, when calling &#8220;read&#8221; with a timeout, will install a signal handler for SIGALRM and <em>longjump out of the signal handler</em>, leaving SIGALRM blocked forever.</p>
<p>The boot-script runs as init (with pid 1) and therefore will leave SIGALRM blocked for all children. My immediate workaround is to read the filesystem to boot in a sub-shell&#8230;seems the bug is fixed with newer versions of bash.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2011/09/23/194/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LILO &#8220;junk in compressed archive&#8221; and Grub2 &#8220;out of disk&#8221; error</title>
		<link>http://blog.runtux.com/2011/01/10/186/</link>
		<comments>http://blog.runtux.com/2011/01/10/186/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 09:44:52 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=186</guid>
		<description><![CDATA[I&#8217;ve recently upgraded a Debian/Asterisk Installation on an older Soekris Net 4501 embedded hardware. After the upgrade the device didn&#8217;t boot anymore. The installed LILO bootloader produced the error message:

Initramfs unpacking failed: junk in compressed archive

and later failed with a kernel panic


VFS: Unable to mount root fs on unknown-block(0,0)

Googling for the error message found a [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve recently upgraded a Debian/Asterisk Installation on an older Soekris <a href="http://soekris.com/net4501.htm">Net 4501</a> embedded hardware. After the upgrade the device didn&#8217;t boot anymore. The installed LILO bootloader produced the error message:</p>
<pre>
Initramfs unpacking failed: junk in compressed archive
</pre>
<p>and later failed with a kernel panic
<pre>

VFS: Unable to mount root fs on unknown-block(0,0)
</pre>
<p>Googling for the error message found a <a href="http://alien.slackbook.org/blog/initramfs-unpacking-failed-junk-in-compressed-archive/">blog entry</a> that indicated a missing LILO option &#8220;large-memory&#8221; &#8212; which wasn&#8217;t the problem in my case, the option was already present.<br />
So I booted into <a href="http://grml.org/">GRML</a> and installed grub2 instead of LILO. After a reboot, Grub2 ended up in rescue mode with the error message:</p>
<pre>
error: out of disk.
grub rescue&gt;
</pre>
<p>I could display the partitions with ls and also get a listing from my root partition but trying to list other directories produces the &#8220;out of disk&#8221; error again:
<pre>

grub rescue&gt; ls
(hd0) (hd0,msdos1) (hd1) (hd2) (hd3)
...
grub rescue&gt; ls (hd0,msdos1)/
./ ../ lost+found/ var/ etc/ media/ initrd.img usr/
...

grub rescue&gt; ls (hd0,msdos1)/boot

error: out of disk.
</pre>
<p>So my diagnosis was that the BIOS of the Soekris box is unable to address the whole (in this case 60GB) harddisk. The install had only worked before because the kernel and the /boot directory where within the BIOS-accessible area on the disk. So there are still BIOSes out there that don&#8217;t support large harddisks &#8212; I didn&#8217;t find out until now what the limit of the Soekris BIOS is. The fix after this diagnosis was easy: Shrink the root filesystem using resize2fs, create a new root partition and copy the shrunken filesystem there, resize2fs to the new partition size. Create a new small /boot partition at the start of the disk and copy the contents of the old /boot directory there. Of course this is only possible with a working rescue system, my rescue system of choice is a <a href="http://grml.org/">GRML</a> netboot setup which enables me to quickly boot any x86-based system that supports network boot.<br />
Lesson learned: For small X86 embedded hardware it still makes sense to have a small /boot partition.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2011/01/10/186/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Unix Domain Sockets</title>
		<link>http://blog.runtux.com/2010/11/09/179/</link>
		<comments>http://blog.runtux.com/2010/11/09/179/#comments</comments>
		<pubDate>Tue, 09 Nov 2010 10:13:42 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=179</guid>
		<description><![CDATA[I recently had to find a solution for a communication problem: An application running on a web-server should update configuration files that are only readable by a privileged user and these should not be directly writeable by the web-server user.
So the idea was to write an update-server running under the privileged account which receives update [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had to find a solution for a communication problem: An application running on a web-server should update configuration files that are only readable by a privileged user and these should not be directly writeable by the web-server user.<br />
So the idea was to write an update-server running under the privileged account which receives update requests (and can perform additional checks) from the unprivileged web server user.<br />
One of the checks I wanted to make was that only the web-server user (www-data on debian) should be able to send update requests. So I had to find out the user sending a request via the Unix-domain socket. Google found a nice socket howto on <a href="http://blog.henning.makholm.net/2008/06/unix-domain-socket-woes.html">Henning Makholm&#8217;s blog</a> which told me most of what I needed to know: &#8220;so I ended up just checking the EUID of the client process after the connection has been accept()ed. For your reference, the way to do this is getsockopt() with SO_PEERCRED for Linux&#8221;.<br />
But one issue was remaining: I didn&#8217;t need a SOCK_STREAM socket but wanted to send datagrams to the other side (and didn&#8217;t want to fiddle with implementing my own datagram layer on top of a stream socket). With normal SOCK_DGRAM datagram sockets there is no connection &#8212; and therefore I can&#8217;t determine the user sending the datagram from the other side of the socket.<br />
Looking further I discovered that Linux has connection-oriented datagram sockets for quite some time under the name SOCK_SEQPACKET. With this type of socket you first connect() to the other side and then you send a datagram. Since now there is a connection the trick with SO_PEERCRED as described above works, too.<br />
Code for Server (python):
<pre>

from socket import socket, SOCK_SEQPACKET, AF_UNIX, SOL_SOCKET
from struct import unpack
try :
    # Not implemented in python 2.6, maybe higher
    from socket import SO_PEERCRED
except ImportError :
    SO_PEERCRED = 17 # Linux
sock = socket (AF_UNIX, SOCK_SEQPACKET)
path = '/path/to/socket'
try :
    os.remove (path)
except OSError :
    pass
sock.bind (path)
conn, adr = self.sock.accept ()
ucred = conn.getsockopt (SOL_SOCKET, SO_PEERCRED, 12)
pid, uid, gid = unpack ('LLL', ucred)
if uid... check uid:
    error...
    conn.close ()

data = conn.recv (4096)
</pre>
<p>Code for client (python):
<pre>

from socket import socket, SOCK_SEQPACKET, AF_UNIX
s = socket (AF_UNIX, SOCK_SEQPACKET)
s.connect ('path/to/socket')
s.send (.....)
s.close ()
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2010/11/09/179/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Skypes Flux Capacitor: UDP</title>
		<link>http://blog.runtux.com/2010/10/06/176/</link>
		<comments>http://blog.runtux.com/2010/10/06/176/#comments</comments>
		<pubDate>Wed, 06 Oct 2010 17:20:13 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[skype]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=176</guid>
		<description><![CDATA[I recently wrote about the broken network obfuscation code (aka Flux Capacitor) of Skype published by Sean O&#8217;Neil. At the time I wasn&#8217;t able to decrypt UDP packets. Now I&#8217;ve looked a little more closely into the Vanilla Skype documentation &#8212; which also includes some code to decrypt Skype credentials on harddisk. This code contains [...]]]></description>
			<content:encoded><![CDATA[<p>I recently wrote about the <a href="http://blog.runtux.com/2010/08/25/167/">broken network obfuscation</a> code (aka Flux Capacitor) of Skype <a href="http://www.enrupt.com/index.php/2010/07/07/skype-biggest-secret-revealed">published by Sean O&#8217;Neil</a>. At the time I wasn&#8217;t able to decrypt UDP packets. Now I&#8217;ve looked a little more closely into the Vanilla Skype documentation &#8212; which also includes some code to decrypt Skype credentials on harddisk. This code contains a CRC implementation called CRC32. I had wrongly asumed that CRC32 of Skype would be the same as the crc32 implementation of pkzip, Ethernet, png, the POSIX cksum command etc. which is listed as &#8220;crc32&#8243; in the <a href="http://en.wikipedia.org/wiki/Cyclic_redundancy_check">CRC article on Wikipedia</a> and which is standardized in e.g. IEEE 802.3.<br />
The crc32 from the standards above inverts all the bits of the seed before using it (it uses an XOR mask of 0xFFFFFFFF) and does this again before returning the result of the CRC computation to the caller. But it uses the same polynomial as skype. So we can use an existing standard CRC implementation (e.g from the <a href="http://www.zlib.net/">zlib</a> library) as follows for computing the skype CRC:</p>
<pre>
def skype_crc (s, seed = 0xFFFFFFFF) :
    return (crc32 (s, seed ^ 0xFFFFFFFF)) ^ 0xFFFFFFFF
</pre>
<p>With this crc implementation I&#8217;m now able to also decrypt UDP (see <a href="http://project.runtux.com/skype/skype_deobfuscate.py">updated code</a>) packets. I&#8217;ve shown this some days ago at my <a href="http://linuxwochenende2010.luga.at/">talk @linuxwochenende</a>, for slides see my <a href="http://runtux.com/events.html">events page</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2010/10/06/176/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Linuxwochenende 2010</title>
		<link>http://blog.runtux.com/2010/09/21/170/</link>
		<comments>http://blog.runtux.com/2010/09/21/170/#comments</comments>
		<pubDate>Tue, 21 Sep 2010 07:47:13 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[deutsch]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[security]]></category>
		<category><![CDATA[skype]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=170</guid>
		<description><![CDATA[Dieses Wochenende ist wieder Linuxwochenende im metalab, ich werde einen Vortrag zu Skype und dem vor kurzem veröffentlichten Flux Capacitor code und einen zweiten zu Traffic Shaping unter Linux halten.
]]></description>
			<content:encoded><![CDATA[<p>Dieses Wochenende ist wieder <a href="http://linuxwochenende2010.luga.at/">Linuxwochenende</a> im <a href="http://metalab.at/">metalab</a>, ich werde einen Vortrag zu Skype und dem vor kurzem veröffentlichten <a href="http://blog.runtux.com/2010/08/25/167/">Flux Capacitor code</a> und einen zweiten zu Traffic Shaping unter Linux halten.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2010/09/21/170/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to get smartcards or crypto-tokens running on Debian Linux and Windows</title>
		<link>http://blog.runtux.com/2009/12/05/150/</link>
		<comments>http://blog.runtux.com/2009/12/05/150/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 16:16:23 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[howto]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=150</guid>
		<description><![CDATA[This is a step-by-step Howto on installation and usage of the necessary commands to get smartcards or crypto-tokens working on Linux &#8212; and on Windows.
Smart card software on Linux consists of a driver for the card reader also called card terminal and a driver for the smartcard or token. There are two projects, OpenSC and [...]]]></description>
			<content:encoded><![CDATA[<p>This is a step-by-step Howto on installation and usage of the necessary commands to get smartcards or crypto-tokens working on Linux &#8212; and on Windows.<br />
Smart card software on Linux consists of a driver for the <em>card reader</em> also called <em>card terminal</em> and a driver for the <em>smartcard or token</em>. There are two projects, <a href="http://www.opensc-project.org/">OpenSC</a> and <a href="http://www.linuxnet.com/">MUSCLE</a>. Both projects produce drivers for card terminals (for OpenSC this sub-project is called <a href="http://www.opensc-project.org/openct/">OpenCT</a>) and for various cards. There are configuration options to make one project see the drivers of the other and vice versa.<br />
I&#8217;m using OpenCT (card terminal) and OpenSC (smart card) software because these have worked better for me &#8212; except for the pcscd daemon from the MUSCLE project that might be needed for some applications. If you&#8217;re using software that depends on a <a href="http://en.wikipedia.org/wiki/PC/SC">PC/SC</a> interface, you&#8217;ll also need to install the pcscd daemon (comes as a debian package).<br />
Manufacturers are continuously improving their smartcards and the applications that run on the card. Up to now this has created an ever-changing pile of middleware to talk to these cards. An idea to improve the situation was a programmable card: Put a Java interpreter on the card and provide applets (so-called &#8220;cardlets&#8221;) for applications. The idea claims this would improve the situation for middleware on the host. Unfortunately this isn&#8217;t quite true: The Java virtual machine on smartcards is subject to change. So we have cards with a recent JVM and old cards with an ancient (1.1 from 2001) JVM. This means the applet needed to make the card work has to be cross-compiled to an older JVM depending on the card used. And there are still a number of host configuration issues.<br />
The situation is worsened by the fact that many manufacturers of smartcards provide cards with their proprietary cardlet in the ROM of the card. This means these cards cannot be used with the applet that matches your middleware. And we&#8217;re back to the start and have to write a driver for the proprietary (this time java) middleware as before.<br />
If you&#8217;re using Java-based smartcards you need to get a card that can accept a new applet and has the necessary developer keys published. Usually these cards are called &#8220;developer version&#8221; or similar. You then can use the MCardApplet from the <a href="http://muscleplugins.alioth.debian.org/">MUSCLE plugins</a> project. I recommend to build the applet yourself &#8212; after all this is a security application where your security depends on the software running on the card. There is a section below for preparing a java card with the appropriate applet.<br />
I got the eToken PRO 32k (4.2B) working with OpenSC but not the eToken PRO 72k (Java). The first uses Siemens CardOS, the number in parentheses denotes the version number. Unfortunately these old CardOS based tokens will be discontinued, and Siemens seems to have announced end of life status for its CardOS.<br />
The 72k eToken from Aladdin uses Java and needs a Java applet. The OpenSC project claims that the Java token works with OpenSC, but it didn&#8217;t for me. Maybe the token wasn&#8217;t a developer version that can accept an applet. The token also didn&#8217;t work under windows (although it worked with the Aladdin software there, i.e., I could initialize it) and I had a recent OpenSC binary release for windows from October 2009.<br />
From the <a href="http://www.opensc-project.org/opensc/">OpenSC documentation</a>: &#8220;For programmable java cards: the support is for the card with the specific applet &#8211; if you have a different applet on your card, it might not be supported.&#8221;<br />
First steps for non-Java cards or Java-cards with MCardApplet installed (for installation of the applet, see below):<br />
Install smartcard software and card terminal framework:
<pre>

apt-get install pcscd opensc libengine-pkcs11-openssl
</pre>
<pre>
The following NEW packages will be installed:
  libengine-pkcs11-openssl libp11-0
</pre>
<p>If your smartcard reader is <em>not</em> supported by <code>pcscd</code>, you should install the <code>openct</code> package in addition to the packages above. You can then run <code>pcscd</code> on top of <code>openct</code>.<br />
After installing these programs, we need to configure pcscd to correctly use our reader. Configure <code>/etc/opensc/opensc.conf</code> to use the pcscd method, search for <code>reader_drivers</code> inside the <code>app default</code> stanza of the config file and modify this to:</p>
<pre>
reader_drivers = pcsc;
</pre>
<p>For CCID compatible readers without <code>openct</code> installed, the reader should be visible after plugging in the reader into the USB port:</p>
<pre>
Readers known about:
Nr.    Driver     Name
0      pcsc       Gemplus GemPC Key 00 00
</pre>
<p>If the card reader is not directly supported by pcscd (but is supported by openct) we need to configure <code>/etc/reader.conf.d/openct</code>, a config file of pcscd, to use OpenCT as the input method, for this the file should contain:</p>
<pre>
FRIENDLYNAME     "OpenCT"
DEVICENAME       /dev/null
LIBPATH          /usr/lib/openct-ifd.so
CHANNELID        0
</pre>
<p>after modifying this file on Debian (on non-Debian systems you&#8217;ll probably have to modify <code>/etc/reader.conf</code> directly) we have to run:</p>
<pre>
update-reader.conf
</pre>
<p>which creates a new <code>/etc/reader.conf</code>. Now stop and restart openct and pcscd in the following order:</p>
<pre>
/etc/init.d/pcscd stop
/etc/init.d/openct restart
/etc/init.d/pcscd start
</pre>
<p>When everything went OK, you should see a pcscd based reader using <code>opensc-tool</code>:</p>
<pre>
opensc-tool -l
</pre>
<pre>
Readers known about:
Nr.    Driver     Name
0      pcsc       OpenCT 00 00
</pre>
<p>Add user to &#8220;scard&#8221; group in /etc/group and log in again to have the permissions to access the card. This is necessary if you want to use a reader provided by openct without going through <code>pcscd</code>.<br />
If all else fails, you can still use <code>openct</code> without <code>pcscd</code> and set <code>reader_drivers</code> in <code>/etc/opensc/opensc.conf</code> to:</p>
<pre>
reader_drivers = openct;
</pre>
<p>Then a reader should be visible like this:
<pre>

opensc-tool -l
</pre>
<pre>
Readers known about:
Nr.    Driver     Name
0      openct     Aladdin eToken PRO 64k
1      openct     OpenCT reader (detached)
2      openct     OpenCT reader (detached)
3      openct     OpenCT reader (detached)
4      openct     OpenCT reader (detached)
</pre>
<p>Now we should be able to read the card, if there is only one token in the USB port and no other smartcard readers are installed, we can leave out the -r option (for specifying the reader to use):
<pre>

cardos-info
</pre>
<pre>
3b:f2:18:00:02:c1:0a:31:fe:58:c8:09:75
Info : CardOS V4.2B (C) Siemens AG 1994-2005
Chip type: 123
Serial number: 27 37 c0 09 2b 18
Full prom dump:
33 66 00 45 CB CB CB CB 7B FF 27 37 C0 09 2B 18 3f.E....{.'7..+.
00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 ................
OS Version: 200.9 (that's CardOS M4.2b)
Current life cycle: 32 (administration)
Security Status of current DF:
Free memory : 1024
ATR Status: 0x0 ROM-ATR
Packages installed:
Ram size: 4, Eeprom size: 32, cpu type: 66, chip config: 63
Free eeprom memory: 27686
System keys: PackageLoadKey (version 0xfe, retries 10)
System keys: StartKey (version 0xff, retries 10)
Path to current DF:
</pre>
<p><b>1.&#160;&#160;&#160;Using Java-based Smartcards</b><br />
Java-based smartcards need some preparation to work with OpenSC. First you should make sure that you have a card that permits you to upload your own applet (cardlet) to the card. This usually means you need a so-called developer version. Avoid cards that have a proprietary manufacturer applet in read-only memory! You also usually need some development keys to upload a cardlet to the card.<br />
For the following instructions I&#8217;ve used the Gemalto TOP IM FIPS CY2 (Cyberflex Access 64k v2) which is an old card that has a Java virtual machine version 1.1 from 2001 (!) but the card is well established and will probably be available for some time.<br />
For the card reader I&#8217;ve used the Gemalto USB Shell V2 (GemPC Key), a CCID compatible reader. When buying a new reader, you should use one that follows the CCID specification from the <a href="www.pcscworkgroup.com">PC/SC Workgroup</a>, this ensures that OpenCT will support it. The card reader I&#8217;m using can read <a href="http://en.wikipedia.org/wiki/ID-000#ID-000">ID-000</a> format cards, also called SIM cards. These are small form-factor cards that are nice for authentication purposes. The Cyberflex card I&#8217;m using is available in ID-000. If a card isn&#8217;t available in ID-000, chances are you can make it fit using a service similar to this <a href="http://www.smartcardfocus.com/shop/ilp/id~82/p/index.shtml">SIM cutting service</a>.<br />
Preparing the card for use with OpenSC is a two-step process. The first step is to obtain the necessary applet for the card. The second is to upload the applet to the card and initialize the card with a default PIN. Note that 2048 bit keys may not work with MCardApplet with the current software versions, see <a href="#some-notes-on-key-sizes">Some notes on key sizes</a>.</p>
<p><b>1.1.&#160;&#160;&#160;Obtaining the MCardApplet for your card</b><br />
I recommend building your own version of the applet from source. Get the source code from svn://svn.debian.org/muscleplugins/trunk/MCardApplet using the source code control tool subversion:
<pre>

svn co svn://svn.debian.org/muscleplugins/trunk/MCardApplet
</pre>
<p>I had to make several changes to use Java 1.6 for cross-building for the ancient Java VM that runs on the card. My <code>Cflex.properties</code> looks like this:</p>
<pre>
CARD_NAME=Cflex
JAVA_BUILD_HOME=/usr
JC_HOME=${basedir}/depends/jc212
API_JAR=${JC_HOME}/lib/api21.jar
API_EXPORT_FILES=${JC_HOME}/api21_export_files
CAPTRANS=${basedir}/depends/jc212/bin/captransf.jar
VM_SOURCE_VERSION=1.2
VM_TARGET_VERSION=1.1
BOOTCLASSPATH=${basedir}/depends/jdk1.2.2/depends/jdk1.2.2/lib
</pre>
<p>In particular, I&#8217;m using the native java environment installed on debian lenny. This lives in /usr. Otherwise you should follow the excellent building instructions in the file <code>INSTALL</code>. Then I&#8217;ve modified the <code>javac</code> in the target named <code>compile</code> in the common.xml ant build file as follows:</p>
<pre>
&lt;target depends="precompile" name="compile"&gt;
    &lt;mkdir dir="${OUTPUT_DIR}"/&gt;
    &lt;javac debug="on"
        verbose="on"
        fork="true"
        executable="${JAVA_BUILD_HOME}/bin/javac"
        srcdir="${APPLET_SRC}"
        destdir="${OUTPUT_DIR}"
        target="${VM_TARGET_VERSION}"
        source="${VM_SOURCE_VERSION}"&gt;
        &lt;bootclasspath&gt;
            &lt;pathelement location="${BOOTCLASSPATH}"/&gt;
        &lt;/bootclasspath&gt;
        &lt;classpath&gt;
            &lt;pathelement location="${API_JAR}"/&gt;
            &lt;pathelement location="."/&gt;
            &lt;pathelement path="${java.class.path}"/&gt;
        &lt;/classpath&gt;
    &lt;/javac&gt;
&lt;/target&gt;
</pre>
<p>I&#8217;ve added the target and source options. These refer to the specific java virtual machine version we&#8217;re cross-building for. I&#8217;ve also added the bootclasspath to get the classes that are VM specific from the old java development package.<br />
This allows me to cross-build the applet for an old version of the java virtual machine without running the old java development environment which does no longer run on recent versions of Linux due to library incompatibilities.<br />
I also had to change all the backslashes in <code>common.xml</code> to forward slashes. It looks like the java compiler can handle the backslashes in path names, but the other tools cannot.<br />
Before building you should also look through <code>CflexCapabilities.properties</code> for any capabilities you want to enable which are not enabled in the default configuration. I had to enable <code>-DWITH_RSA_2048</code> and <code>-DWITH_SIGN</code> for example.<br />
For the impatiant I&#8217;m offering a <a href="http://project.runtux.com/download/CardEdgeCflex.ijc">pre-compiled version</a> of the applet. I&#8217;ll update this text with the build instructions soon.</p>
<p><b>1.2.&#160;&#160;&#160;Uploading the applet to the card</b><br />
As a preparation for this step, you should install the pcsc daemon and the pcsclite development packages on debian:
<pre>

apt-get install pcscd libpcsclite-dev
</pre>
<p>For uploading the applet to the card, I recommend using <a href="http://downloads.sourceforge.net/project/globalplatform/GPShell/GPShell-1.4.2/gpshell-1.4.2.tar.gz">gpshell</a>, a tool from the <a href="http://sourceforge.net/projects/globalplatform/">globalplatform project</a> which depends on the <a href="http://downloads.sourceforge.net/project/globalplatform/GlobalPlatform%20Library/GlobalPlatform%20Library%205.0.0/globalplatform-5.0.0.tar.gz">globalplatform library</a>. Unfortunately these are not yet packaged as Debian packages, so obtain the sourcecode to both, <a href="http://downloads.sourceforge.net/project/globalplatform/GPShell/GPShell-1.4.2/gpshell-1.4.2.tar.gz">gpshell</a> and the <a href="http://downloads.sourceforge.net/project/globalplatform/GlobalPlatform%20Library/GlobalPlatform%20Library%205.0.0/globalplatform-5.0.0.tar.gz">globalplatform library</a> . Unpack these packages and build using the normal process:</p>
<pre>
./configure
make
make install
</pre>
<p>For the <a href="http://downloads.sourceforge.net/project/globalplatform/GlobalPlatform%20Library/GlobalPlatform%20Library%205.0.0/globalplatform-5.0.0.tar.gz">globalplatform library</a> you need the development libraries for libpcsclite, available as the Debian package <code>libpcsclite-dev</code> which should be installed before the <code>./configure</code> step above.<br />
If you installed the globalplatform library without root privileges, you have to run <code>ldconfig</code> as root to make the new library available in the shared library cache.<br />
Check that your smartcard services are running (see above for how to do that) and verify that you see your card reader (or token) using:
<pre>

opensc-tool -l
</pre>
<p>The <code>gpshell</code> tool interfaces to the card via pcscd, so you should see something similar to the following:</p>
<pre>
Readers known about:
Nr.    Driver     Name
0      pcsc       Gemplus GemPC Key 00 00
</pre>
<p>Now we can proceed to upload the applet using <code>gpshell</code>. We need the following <a href="http://project.runtux.com/download/applet_install.gpshell">applet upload gpshell script</a>, put this into the file <code>applet_install.gpshell</code>, note that lines terminated with &#8220;\&#8221; need to be concatenated, gpshell currently doesn&#8217;t understand continuation lines:</p>
<pre>
enable_trace
establish_context
card_connect
select -AID a000000003000000
open_sc -security 1 -keyind 0 -keyver 0 \
   -mac_key 404142434445464748494a4b4c4d4e4f \
   -enc_key 404142434445464748494a4b4c4d4e4f
delete -AID a00000000101
delete -AID a000000001
delete -AID a0000003230101
delete -AID a00000032301
install_for_load -pkgAID a000000001 -nvCodeLimit 16000 \
   -sdAID a000000003000000
load -file CardEdgeCflex.ijc
install_for_install -instParam 00 -priv 02 -AID a00000000101 \
   -pkgAID a000000001 -instAID a00000000101 -nvDataLimit 32000
card_disconnect
release_context
</pre>
<p>and run the script with <code>gpshell</code>:</p>
<pre>
gpshell applet_install.gpshell
</pre>
<p>Finally we will have to set a default PIN for the card using <code>opensc-tool</code>:</p>
<pre>
opensc-tool -s 00:A4:04:00:06:A0:00:00:00:01:01 -s \
B0:2A:00:00:38:08:4D:75:73:63:6C:65:30:30:04:01:08:\
30:30:30:30:30:30:30:30:08:30:30:30:30:30:30:30:30:\
05:02:08:30:30:30:30:30:30:30:30:08:30:30:30:30:30:\
30:30:30:00:00:17:70:00:02:01
</pre>
<p>This sets the PIN to eight zeros, &#8220;00000000&#8243;. After this procedure the card can be used like a normal <a href="http://en.wikipedia.org/wiki/PKCS">PKCS#15</a> based card with OpenSC.</p>
<p><b>1.2.1.&#160;&#160;&#160;Some notes on using the gpshell script with other cards</b><br />
Many of the magic numbers in the gpshell script depend on the card in use and on the applet that is uploaded. An <code>AID</code> is an applet-ID. The <code>open_sc</code> command has nothing to do with OpenSC, but opens a secure channel to the card. The parameters are the developer keys of the card. In our example, the key is used twice and the hex-bytes denote the string:</p>
<pre>
@ABCDEFGHIJKLMNO
</pre>
<p>The AID used for the secure channel is different for other brands of cards. I was able to find out this AID using the following <a href="http://project.runtux.com/download/aid.gpshell">AID gpshell script</a>:</p>
<pre>
enable_trace
establish_context
card_connect
open_sc -security 1 -keyind 0 -keyver 0 \
   -mac_key 404142434445464748494a4b4c4d4e4f \
   -enc_key 404142434445464748494a4b4c4d4e4f
get_status -element 80
card_disconnect
release_context
</pre>
<p>This displays for the Gemalto TOP IM FIPS CY2:
<pre>

List of applets (AID state privileges)
a000000003000000        7       0
</pre>
<p>The delete commands remove older versions of the applet &#8212; there also was a version that had another applet ID &#8212; from the card before uploading the new version. Think of the applet living in a package named a000000001 and the applet named a00000000101. The <code>install_for_load</code> command establishes the package inside the a000000003000000 package. Then the <code>install_for_install</code> command installs the applet into non volatile memory after upload.<br />
Note that these numbers are hard-coded into the applet that is being uploaded. This is defined during compile-time and for the MCardApplet this can be configured in the <code>common.xml</code> ant-file. When packaging the compiled java classes, the build process generates <code>.cap</code> files which contain the applet ID in binary format, notably the <code>Applet.cap</code> file contains the AID of the applet.<br />
So if these numbers are changed when building a custom applet, be sure to adapt the upload commands, too. A warning here: All tools that depend on the MCardApplet expect the given AID, so changing the AID would incur a change of all tools or at least their configuration.</p>
<p><b>2.&#160;&#160;&#160;OpenVPN Preparation: Step by step process with high-level tool</b><br />
This section describes how to initialize a token, create a user key and certificate using tools that come with OpenVPN. This was only tested on Linux since the certificate handling scripts for OpenVPN are more advanced on Linux.<br />
I had to patch the <code>pkitool</code> of OpenVPN to use the <code>pkcs15-init</code> command instead of the <code>pkcs11-tool</code> command for initializing the token and creating keys. The reason is that Aladdin limits their tokens to use one key for only one purpose (encryption or signing). The <code>pkcs15-init</code> command allows the specification of the key purpose while the <code>pkcs11-tool</code> command does not.<br />
In the following we assume you are in the easy-rsa directory of OpenVPN, and you have initialized the configuration by reading the configuration in <code>vars</code>. It&#8217;s also always a good idea to have a backup of all the OpenVPN keys before starting.<br />
Initializing the token for first use (or re-using an already formatted token) THIS DESTROYS ALL DATA ON THE TOKEN:
<pre>

./pkitool --pkcs15-init 0 "Thomas Mustermann"
</pre>
<pre>
New User PIN.
Please enter User PIN:
Please type again to verify:
Unblock Code for New User PIN (Optional - press return for no PIN).
Please enter User unblocking PIN (PUK):
Please type again to verify:
</pre>
<p>If the token was already initialized, the procedure would also ask for the old password.<br />
Now we can check that everything worked, by looking at the PINs:
<pre>

pkcs15-tool --list-pins
</pre>
<p>Now we can proceed to generate a key pair and a certificate, this takes a long time:
<pre>

./pkitool --pkcs15 /usr/lib/opensc-pkcs11.so 0 45 "user cert" client27
</pre>
<p>When everything went OK, we should be able to display keys, public keys, and certificates on the token:
<pre>

pkcs15-tool --list-keys
pkcs15-tool --list-public-keys
pkcs15-tool --list-certificates
</pre>
<p><b>3.&#160;&#160;&#160;What is needed for Windows</b><br />
I&#8217;ve first installed the latest <a href="http://openvpn.net/release/openvpn-2.1_rc21-install.exe">OpenVPN installer</a>, only this package has the necessary <code>TAP</code> network driver for Linux. Only the TAP driver needs to be installed.<br />
I&#8217;ve used a compiled version of OpenVPN that comes bundled with OpenSC from the binary <a href="http://www.opensc-project.org/files/build/">windows repository</a>, I&#8217;ve used the latest</p>
<pre>
opensc-i686-w32-mingw32-007-*.*
</pre>
<p>files (from Oct 2009). For 64bit Windows (AMD64) the
<pre>

opensc-x86_64-pc-mingw32-003*.*
</pre>
<p>files should be used. Everything unpacked from these files should be installed to
<pre>

C:\Programs\OpenVPN
</pre>
<p>I&#8217;ve also created a configuration directory under that directory called <code>config</code>. In config there are the necessary certificates (root ca) and hash keys and the <code>client.ovpn</code> configuration file.<br />
When using my OpenVPN admin script, Python for windows from <a href="http://www.python.org">python.org</a> and the <code>Python WIN32</code> package are needed. In addition my <a href="http://rsclib.sourceforge.net">rsclib</a> library needs to be installed. For installing rsclib, unpack the <code>.zip</code> file and run:</p>
<pre>
setup.py install
</pre>
<p>from a command prompt. The admin script in <code>pyovpn.zip</code> has the same installation procedure.<br />
After installing everything, basic working of the smart card can be verified with the OpenSC tools:
<pre>

opensc-tool -l
cardos-info
pkcs15-tool --list-certificates
</pre>
<p><b>3.1.&#160;&#160;&#160;Aladdin Token</b><br />
For using the Aladdin eToken with Windows, the smart card tools of the manufacturer have to be installed &#8212; these include the driver for accessing the tokens. I&#8217;ve used:
<pre>

PKIClient-x32-5.00.msi
</pre>
<p>from
<pre>

eToken PKI Client 5.0 SP1 Windowsx32.zip
</pre>
<p><b>3.2.&#160;&#160;&#160;Gemalto USB Shell Token V2</b><br />
The driver for the Gemalto USB Shell Token reader can be downloaded free of charge from the <a href="http://support.gemalto.com/index.php?id=61">Gemalto website</a>.</p>
<p><b>4.&#160;&#160;&#160;Using OpenVPN with SmartCard</b><br />
OpenVPN uses a PKCS#11 provider library, on Debian this is <code>/usr/lib/opensc-pkcs11.so</code>, to access the smart card. We can show which certificates are on the card by issuing:</p>
<pre>
openvpn --show-pkcs11-ids /usr/lib/opensc-pkcs11.so
</pre>
<pre>
The following objects are available for use.
Each object shown below may be used as parameter to
--pkcs11-id option please remember to use single quote mark.

Certificate
      DN:             /C=AT/ST=AT/L=Weidling/ ...
      Serial:         03
      Serialized id:  OpenSC\x20Project/PKCS\x20 ...
</pre>
<p>Now OpenVPN can be started with the smartcard. I&#8217;m using the following additional config entries for OpenVPN &#8212; <code>pkcs11-providers</code> is set to the path of the PKCS#11 provider library:</p>
<pre>
pkcs11-providers "/usr/lib/opensc-pkcs11.so"
pkcs11-id-management
management 127.0.0.1 4711
management-query-passwords
management-hold
</pre>
<p>For Windows the provider library becomes (assuming the OpenSC tools where installed to C:ProgramsOpenVPNbin):
<pre>

pkcs11-providers "C:\\Programs\\OpenVPN\\bin\\opensc-pkcs11.dll"
</pre>
<p>The other parameters are the same as for other operating systems.<br />
Note also that the <code>askpass</code> option of OpenVPN does <em>not</em> work for querying the token password. In my experiment I had to give the token password to OpenVPN via the management interface using the config option <code>management-query-passwords</code>.<br />
This configuration tells OpenVPN to open the management interface on Port 4711 of localhost. It will ask for the passphrase of the Aladdin token on that port. Additionally we wait (<code>management-hold</code>) until a management program has opened the management interface and told OpenVPN to proceed.<br />
The <code>pkcs11-id-management</code> tells OpenVPN to accept the <code>pkcs11-id</code> to use via the management interface. With a little intelligence in the management interface we can avoid having the pkcs11-id in the configuration file (which would then be different for each user).<br />
OpenVPN can be asked via the management interface about a listing of all <code>pkcs11-ids</code>. If there is only one certificate on the card, we feed the id of the only certificate back to OpenVPN when it asks about the pkcs11-id. This can be done without user intervention.<br />
Unfortunately the feature that OpenVPN can ask the smartcard for all the certificates depends on the Token being present when OpenVPN is started. An alternative is to specify the <cite>pkcs11-id`</cite> directly in the configuration file. If this is specified, the management interface will ask for the token if it isn&#8217;t present when starting OpenVPN. The parameter to the <code>pkcs11-id</code> config parameter is the <code>Serialized id</code> from the command output above.<br />
Since I have not found any graphical user interface programs for OpenVPN that can deal with asking the user for the token passphrase, I&#8217;ve written a little command-line python script which can be run on both, Windows and Linux, and will ask the user to insert the token and specify the token passphrase.<br />
OpenVPN can be started with the script by issuing the command:
<pre>

pyovpn
</pre>
<p>in a command prompt window. The command will start openvpn and proceed to ask for necessary token passwords.<b></p>
<p>4.1.&#160;&#160;&#160;Low-level usage of the management interface</b><br />
With the <code>management-query-passwords</code> option, OpenVPN will ask the password from the management interface. After starting the OpenVPN daemon and connnecting to the managment interface on the defined port (e.g., using telnet) we see the following message:</p>
<pre>
&gt;INFO:OpenVPN Management Interface Version 1 -- type 'help' for more info
&gt;PASSWORD:Need 'OpenSC Card (New User) token' password
</pre>
<p>The password can then be entered using the password command of the managment interface:
<pre>

password 'OpenSC Card (New User) token' sehrgeheimespasswort
</pre>
<p>OpenVPN answers with:
<pre>

SUCCESS: 'OpenSC Card (New User) token' password entered, but not yet verified
</pre>
<p><b>5.&#160;&#160;&#160;Key Revocation</b><br />
Revoke a certificate:
<pre>

openssl ca  -config $KEY_CONFIG -revoke keys/02.pem
</pre>
<p>(re-) generate key revocation list (CRL):
<pre>

openssl ca  -config $KEY_CONFIG -gencrl -out keys/crl.pem
</pre>
<p><b>6.&#160;&#160;&#160;OpenVPN Preparation: Step by step process with low-level tools</b><br />
This section describes the low-level tools as used by the patched <code>pkitool</code> from OpenVPN. It does not create a certificate with OpenSSL. This is for documentation purposes only (to understand what goes on behind the scenes) and was my first approach to getting started with OpenSC.</p>
<ul>
<li>
Erase the card &#8212; if you already have a Security Officer PIN installed, you need this for erasing the card:
<pre>

pkcs15-init -E
</pre>
</li>
<li>
Create PKCS#15 structure (option &#8211;no-so-pin specified not to create security officer PIN and user PUK) on the card &#8212; note that the keys need to be between 6 and 8 characters long and should be numeric if you intend to use a keypad for key-entry (which applies mostly to smartcards not to USB tokens). Also note that if you omit &#8211;no-so-pin you should keep the Security Officer PIN secure &#8212; only with it can the token be re-formatted:
<pre>

pkcs15-init --create-pkcs15 --no-so-pin
</pre>
<pre>
New Security Officer PIN (Optional - press return for no PIN).
Please enter Security Officer PIN:
Please type again to verify:
Unblock Code for New User PIN (Optional - press return for no PIN).
Please enter User unblocking PIN (PUK):
Please type again to verify:
</pre>
</li>
<li>
The steps above can be rolled into one command:
<pre>

pkcs15-init -E --create-pkcs15 --no-so-pin
</pre>
</li>
<li>
Add an authentication (user) ID to the token with corresponding PIN and PUK:
<pre>

pkcs15-init --store-pin --auth-id 01 --label "User Name"
</pre>
<pre>
New User PIN.
Please enter User PIN:
Please type again to verify:
Unblock Code for New User PIN (Optional - press return for no PIN).
Please enter User unblocking PIN (PUK):
Please type again to verify:
</pre>
</li>
<li>
Check that everything worked, by looking at the PINs:
<pre>

pkcs15-tool --list-pins
</pre>
<pre>
PIN [Security Officer PIN]
    Com. Flags: 0x3
    ID        : ff
    Flags     : [0xB2], local, initialized, needs-padding, soPin
    Length    : min_len:6, max_len:8, stored_len:8
    Pad char  : 0x00
    Reference : 1
    Type      : ascii-numeric
    Path      : 3f005015

PIN [User Name]
    Com. Flags: 0x3
    ID        : 01
    Flags     : [0x32], local, initialized, needs-padding
    Length    : min_len:4, max_len:8, stored_len:8
    Pad char  : 0x00
    Reference : 3
    Type      : ascii-numeric
    Path      : 3f005015
</pre>
</li>
<li>
Now we can generate an RSA key on the card. Note that we could also import a PKCS-12 key onto the card, but the more secure option is to let the card generate the key (so the key will never be available outside the card). The split-key option actually generates two key-pairs, one for encryption and one for signing. There are some labelling options to attach names to the generated keys but these aren&#8217;t needed if you want only one key. You could specify an application profile with the &#8211;id option, if this isn&#8217;t given the default ID 45 (authentication purposes) is used. The command will ask for the Security officer PIN, then for the User PIN, then again for the Security officer PIN (!):
<pre>

pkcs15-init --generate-key rsa/2048 --auth-id 01 --split-key
</pre>
<p>Note that with Java smartcards the keysize 2048 might not work with the current version of the tools, see <a href="#some-notes-on-key-sizes">Some notes on key sizes</a>.
</li>
<li>
Now we can verify that the key was actually stored on the card:
<pre>

pkcs15-tool --list-keys
</pre>
<pre>
Private RSA Key [Private Key]
    Com. Flags  : 3
    Usage       : [0x4], sign
    Access Flags: [0x1D], sensitive, alwaysSensitive, neverExtract, local
    ModLength   : 2048
    Key ref     : 16
    Native      : yes
    Path        : 3f005015
    Auth ID     : 01
    ID          : 45
</pre>
</li>
<li>
List public keys:
<pre>

pkcs15-tool --list-public-keys
</pre>
<pre>
Public RSA Key [Public Key]
    Com. Flags  : 2
    Usage       : [0x4], sign
    Access Flags: [0x0]
    ModLength   : 2048
    Key ref     : 0
    Native      : no
    Path        : 3f0050153048
    Auth ID     :
    ID          : 45
</pre>
</li>
<li>
For the following steps we will need a minimum openssl config file:
<pre>

openssl_conf            = openssl_init

[ openssl_init ]
engines                 = engine_section

[ req ]
default_bits            = 2048
default_keyfile         = privkey.pem
distinguished_name      = req_distinguished_name

[ req_distinguished_name ]
countryName                     = Country Name (2 letter code)
countryName_default             = AT
countryName_min                 = 2
countryName_max                 = 2
stateOrProvinceName             = State or Province Name (full name)
stateOrProvinceName_default     = Austria
localityName                    = Locality Name (eg, city)
localityName_default            = Vienna
0.organizationName              = Organization Name (eg, company)
0.organizationName_default      = example.com
organizationalUnitName          = Organizational Unit Name (eg, section)
organizationalUnitName_default  = IT-Department
commonName                      = Common Name (eg, server\'s hostname)
commonName_max                  = 64
emailAddress                    = Email Address
emailAddress_max                = 40

[ engine_section ]
pkcs11 = pkcs11_section

[ pkcs11_section ]
engine_id = pkcs11
dynamic_path = /usr/lib/engines/engine_pkcs11.so
MODULE_PATH = /usr/lib/opensc-pkcs11.so
init = 0
</pre>
</li>
<li>
Generate a certificate request (CSR) from this key using openssl:
<pre>

CLIENT=newclient
openssl req -days 3650 -new -out $CLIENT.csr -config openssl.cnf \
  -engine pkcs11 -keyform engine -key 0:45 -sha1
</pre>
<p>This will ask for all the certificate parameters. Alternatively these can be specified using the <code>-subj</code> option of openssl (this is broken into several lines but should be assembled into one line) with the following parameter:</p>
<pre>
/C=AT/ST=Austria/L=Vienna/O=example.com/OU=IT-Department
/CN=$CLIENT/emailAddress=user@example.com
</pre>
</li>
<li>
You can view the contents of the CSR using:
<pre>

openssl req -in $CLIENT.csr -noout -text
</pre>
</li>
<li>
Now sign the certificate request with whatever tools you are using. With the pkitool of OpenVPN this would become (after having copied the certificate request newclient.csr to the keys directory):
<pre>

pkitool --sign newclient
</pre>
<p>The message about not being able to access <code>newclient.key</code> can be ignored.
</li>
<li>
You may want to delete old certificates from the token:
<pre>

pkcs15-init --delete-objects cert --id=45
</pre>
</li>
<li>
Then import the new certificate onto the token:
<pre>

pkcs15-init --store-certificate newclient.crt --id=45
</pre>
</li>
<li>
Reading a certificate from the token and output with openssl:
<pre>

pkcs15-tool --read-certificate 45 | openssl x509 -noout -text
</pre>
</li>
</ul>
<p><a name="some-notes-on-key-sizes"> </a><br />
<b>6.1.&#160;&#160;&#160;Some notes on key sizes</b><br />
Using 2048 bit keys should generally be possible with newer cards. I had some problems with these key sizes using my Java smartcard, though.<br />
After uploading the applet to the card, it is possible to create a key with either 1024 or 2048 bit. This indicates that the card <em>is</em> able to handle the large keysize. When trying to generate a CSR using openssl the command failed with:</p>
<pre>
[opensc-pkcs11] iso7816.c:99:iso7816_check_sw: No precise diagnosis
[opensc-pkcs11] muscle.c:745:msc_compute_crypt_process: returning with:
                Card command failed
[opensc-pkcs11] muscle.c:840:msc_compute_crypt: returning with:
                Card command failed
[opensc-pkcs11] card-muscle.c:749:muscle_compute_signature:
                Card signature failed: Card command failed
[opensc-pkcs11] sec.c:53:sc_compute_signature: returning with:
                Card command failed
[opensc-pkcs11] pkcs15-sec.c:273:sc_pkcs15_compute_signature:
                sc_compute_signature() failed: Card command failed
20808:error:0E06D06C:configuration file routines:NCONF_get_string:no value:
conf_lib.c:329:group=req_attributes name=unstructuredName_min
20808:error:0E06D06C:configuration file routines:NCONF_get_string:no value:
conf_lib.c:329:group=req_attributes name=unstructuredName_max
20808:error:8000A005:Vendor defined:PKCS11_rsa_sign:General Error:
p11_ops.c:97:
20808:error:0D0C3006:asn1 encoding routines:ASN1_item_sign:EVP lib:
a_sign.c:276:
</pre>
<p>Worse, after reinitializing the card in this state with:
<pre>

pkcs15-init -E --create-pkcs15 --no-so-pin
pkcs15-init --store-pin --auth-id 01 --label "User Name"
</pre>
<p>and trying to generate a smaller key, this fails with:
<pre>

pkcs15-init --generate-key rsa/1024 --auth-id 01 --split-key
</pre>
<pre>
[pkcs15-init] iso7816.c:102:iso7816_check_sw: Unknown SWs; SW1=9C, SW2=03
[pkcs15-init] muscle.c:557:msc_generate_keypair: returning with:
              Card command failed
[pkcs15-init] card.c:678:sc_card_ctl: returning with:
              Card command failed
[pkcs15-init] pkcs15-muscle.c:272:muscle_generate_key:
              Unable to generate key
[pkcs15-init] pkcs15-muscle.c:273:muscle_generate_key: returning with:
              Card command failed
Failed to generate key: Card command failed
</pre>
<p>I was able to fix this by re-downloading the applet onto the card. This also happens the other way round, when generating a 1024 bit key first and trying &#8212; after reinitializing the card with <code>pkcs15-init</code> &#8212; to generate a 2048 bit key.<br />
So I recommend to stick with 1024 bit keys with the current software versions (debian lenny).</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2009/12/05/150/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Media Ecologies Conference</title>
		<link>http://blog.runtux.com/2009/11/03/148/</link>
		<comments>http://blog.runtux.com/2009/11/03/148/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 12:05:08 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[licensing]]></category>
		<category><![CDATA[neu]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=148</guid>
		<description><![CDATA[I&#8217;m currently at the media ecologies conference in manchester, UK. I was just talking about what tools and interfaces we need for collaboration tools (on the web). This also rehashes some of the ideas in my blog entry on cloud computing and the problems with (lack of) openness of cloud applications. The slides of my [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently at the <a href="http://www.espach.salford.ac.uk/sssi/p2p/">media ecologies conference</a> in manchester, UK. I was just talking about what tools and interfaces we need for collaboration tools (on the web). This also rehashes some of the ideas in my <a href="http://blog.runtux.com/2009/08/04/106/">blog entry on cloud computing</a> and the problems with (lack of) openness of cloud applications. The slides of my talk can be downloaded from <a href="http://runtux.com/files/download/manchester.4.pdf">my website</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2009/11/03/148/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Did Ronja Fail?</title>
		<link>http://blog.runtux.com/2009/10/27/142/</link>
		<comments>http://blog.runtux.com/2009/10/27/142/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:30:32 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[documentation]]></category>
		<category><![CDATA[english]]></category>
		<category><![CDATA[licensing]]></category>
		<category><![CDATA[open hardware]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=142</guid>
		<description><![CDATA[Ronja, the optical data link device, is often cited as a failed open source hardware project &#8212; the last one mentioning it I just read is Lawrence Kincheloe&#8217;s excellent essay Musings Upon the Nature of Open Source Hardware as a Business at the end of his project visit summary at Factor e Farm.
Roja did fail [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://ronja.twibright.com/">Ronja</a>, the optical data link device, is often cited as a failed open source hardware project &#8212; the last one mentioning it I just read is Lawrence Kincheloe&#8217;s <em>excellent</em> essay <a href="http://openfarmtech.org/weblog/?p=1187">Musings Upon the Nature of Open Source Hardware as a Business</a> at the end of his project visit summary at <a href="http://openfarmtech.org/index.php?title=Factor_e_Farm">Factor e Farm</a>.<br />
Roja <em>did</em> fail (in the sense that it isn&#8217;t very widespread today not in the sense of being a cool open source project). One of the research studies I know of is the presentation &#8220;<a href="http://www.oekonux-conference.org/program/events/22.en.html">Ronja &#8212; Darknet of Lights</a>&#8221; by Johan <a href="http://www.oekonux-conference.org/program/speakers/33.en.html">S&#246;derberg</a> at the <a href="http://www.oekonux-conference.org/">4th Oekonux conference</a> for which <a href="http://www.oekonux-conference.org/documentation/croome/Soederberg.mp3">Audio</a> is available. The study is very interesting although I don&#8217;t agree with the conclusions. So why did Ronja &#8220;fail&#8221;?<br />
Ronja&#8217;s main application was cheap internet access. At the time of its design in 2001 <a href="http://en.wikipedia.org/wiki/Wireless_LAN">wireless LAN</a> (Wifi) wasn&#8217;t yet available cheaply. And in the Czech Republic <a href="http://en.wikipedia.org/wiki/Digital_subscriber_line">DSL</a> wasn&#8217;t available at the time.<br />
Now consider the technical characteristics of Ronja:
<ul class="simple">
<li>Up to 10MBit/s</li>
<li>Up to 1.4 km range</li>
<li>Light: Doesn&#8217;t work in fog, or other bad weather (snow)</li>
<li>Light: Hard to get the beam to the destination (direction)</li>
<li>Light: Interference with daylight</li>
<li>For full-duplex communication we need two (receiver + transmitter) devices</li>
<li>sold for around 700$ at the time (the LED alone cost 120$ you get these for .75$ now)</li>
<li>needed &#8220;a hell of a lot of time to build one&#8221; according to <a href="http://www.oekonux-conference.org/program/speakers/33.en.html">S&#246;derberg</a></li>
</ul>
<p>And compare these with WLAN:
<ul class="simple">
<li>Up to 54MBit/s</li>
<li>With good antennas several km range (I&#8217;ve built a link with 5.5km)</li>
<li>Antennas are cheap and can even be built at home, e.g., a <a href="http://en.wikipedia.org/wiki/Cantenna">Cantenna</a> &#8212; you can build a cantenna in an evening</li>
<li>Works in fog and bad weather</li>
<li>we need only one antenna at sender and one at receiver</li>
<li>WLAN is <em>very</em> cheap nowadays, it became available (with new frequencies) in 2005 in cz.</li>
</ul>
<p>So I think that Ronja &#8220;failed&#8221; because it was replaced by something better and cheaper that was readily available. It isn&#8217;t an example of a failed open source business model for hardware and shouldn&#8217;t be used as an example. This doesn&#8217;t mean that we already know how a business model for open source hardware should look like, though.<br />
The idea behind Ronja &#8212; according to the <a href="http://en.wikipedia.org/wiki/RONJA">Wikipedia article on Ronja</a> &#8220;User Controlled Technology&#8221; is (mostly) achieved with WLAN technology today: We can use cheap devices and modify them (using open source firmware and homegrown antennas) to suit our needs. And there are large wireless communities now like <a href="http://funkfeuer.at/">Funkfeuer</a> in Vienna who do their own Internet communication.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2009/10/27/142/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
<enclosure url="http://www.oekonux-conference.org/documentation/croome/Soederberg.mp3" length="65504681" type="audio/mpeg" />
		</item>
		<item>
		<title>PGAPy: Genetische Algorithmen mit Python</title>
		<link>http://blog.runtux.com/2009/10/25/138/</link>
		<comments>http://blog.runtux.com/2009/10/25/138/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 07:57:22 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[deutsch]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[howto]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=138</guid>
		<description><![CDATA[[Dies ist der Abstract meines Vortrags am Linuxwochenende im Metalab, die alte Version des Abstracts ist inzwischen von der Linuxwochen Homepage verschwunden...]
PGAPy ist ein Python-Wrapper f&#252;r PGAPack, eine der vollst&#228;ndigsten Bibliotheken f&#252;r genetischen Algorithmen. Die Python-Bibliothek eignet sich f&#252;r eigene Experimente mit genetischen Algorithmen, aber auch f&#252;r die Implementierung von kompletten Anwendungen.
Der Vortrag gibt eine [...]]]></description>
			<content:encoded><![CDATA[<p>[Dies ist der Abstract meines Vortrags am Linuxwochenende im Metalab, die alte Version des Abstracts ist inzwischen von der Linuxwochen Homepage verschwunden...]</p>
<p><a href="http://pgapy.sourceforge.net/">PGAPy</a> ist ein Python-Wrapper f&#252;r <a href="ftp://info.mcs.anl.gov/pub/pgapack/README">PGAPack</a>, eine der vollst&#228;ndigsten Bibliotheken f&#252;r genetischen Algorithmen. Die Python-Bibliothek eignet sich f&#252;r eigene Experimente mit genetischen Algorithmen, aber auch f&#252;r die Implementierung von kompletten Anwendungen.</p>
<p>Der Vortrag gibt eine kurze Einf&#252;hrung in genetischen Algorithmen mit Beispielen in Python. Vorgestellt wird u.a. ein Programm zum automatischen Erzeugen der bekannten Sudoku Zahlenr&#228;tsel. Dabei wird schrittweise die Bewertungsfunktion f&#252;r ein Sudoku entwickelt.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2009/10/25/138/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Linuxwochenende 2009</title>
		<link>http://blog.runtux.com/2009/10/23/134/</link>
		<comments>http://blog.runtux.com/2009/10/23/134/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 13:39:42 +0000</pubDate>
		<dc:creator>Ralf Schlatterbeck</dc:creator>
				<category><![CDATA[deutsch]]></category>
		<category><![CDATA[documentation]]></category>
		<category><![CDATA[money]]></category>

		<guid isPermaLink="false">http://blog.runtux.com/?p=134</guid>
		<description><![CDATA[Dieses Wochenende ist wieder Linuxwochenende im metalab, ich werde wieder einen Vortrag zu Open Money halten, ausserdem einen Lightning-Talk zu Generierung von Morse-Code als MIDI-Datei (was für einige Anwärter auf die Amateurfunklizenz vielleicht interessant ist, auch wenn das Code-Requirement inzischen gefallen ist.)
]]></description>
			<content:encoded><![CDATA[<p>Dieses Wochenende ist wieder <a href="http://linuxwochenende2009.luga.at/">Linuxwochenende</a> im <a href="http://metalab.at">metalab</a>, ich werde wieder einen <a href="http://linuxwochenende2009.luga.at/paper15.html">Vortrag zu Open Money</a> halten, ausserdem einen Lightning-Talk zu Generierung von <a href="http://linuxwochenende2009.luga.at/paper16.html">Morse-Code als MIDI-Datei</a> (was für einige Anwärter auf die <a href="http://metalab.at/wiki/MetaFunk">Amateurfunklizenz</a> vielleicht interessant ist, auch wenn das Code-Requirement inzischen gefallen ist.)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.runtux.com/2009/10/23/134/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

