<?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>Aaron Toponce &#187; Cryptology</title>
	<atom:link href="http://pthree.org/category/cryptology/feed/" rel="self" type="application/rss+xml" />
	<link>http://pthree.org</link>
	<description>Linux.  GNU.  Freedom.</description>
	<lastBuildDate>Sun, 05 Feb 2012 14:33:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.4-alpha</generator>
		<item>
		<title>Making Sense of Hashed Hosts in ~/.ssh/known_hosts</title>
		<link>http://pthree.org/2011/12/30/making-sense-of-hashed-hosts-in-sshknown_hosts/</link>
		<comments>http://pthree.org/2011/12/30/making-sense-of-hashed-hosts-in-sshknown_hosts/#comments</comments>
		<pubDate>Fri, 30 Dec 2011 21:19:57 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=2168</guid>
		<description><![CDATA[I don&#8217;t expect you to follow this post completely, but it&#8217;s so amazingly cool, I have to blog it. Consider the hashed sections of ~/.ssh/known_hosts file for (recent) OpenSSH clients, not including the public key parts: &#124;1&#124;kFJT5z0x3ndyutgZ4E5pRk+ORBA=&#124;hzXvdYUudo+qK9BGlFWtSAUXlXc= &#124;1&#124;8wo1+FO0hkATPgQZoeNHeIlvAjw=&#124;dt/a9jz9CnLKP72j+Jr8MKMjgEE= &#124;1&#124;pvBQEKEGLnH0RCJr+8Dmqqnvlrs=&#124;fJJvjyG/TmHFnuIX57nDThq/C4M= &#124;1&#124;HKV4DzgDkajXoUHf9B82JBu7J10=&#124;c/K+MdJvWaZeJFs/W7iqhqo0wvE= &#124;1&#124;rtvQhRVnNanQZYkLUMbjoBGNhn0=&#124;0U6a1LUQqLL6P1T2Wji3VWw69pw= &#124;1&#124;0ziSYi4c+xBXGEBZcNN1LMhYUc4=&#124;qRSN5GSPyQi+fmaVz2zNwkmKoy8= &#124;1&#124;6nv6Vpk3AYgICHxJGVgVdsYRuq0=&#124;fBNOIz1l3RW+N61jyDPunKX9n7E= &#124;1&#124;+b4uA+Mq7RHRAFW21qv8aO3rIRs=&#124;1eizMri01IxEKrXquBnwTYP61Ow= &#124;1&#124;BkB0PZu2qtsLID/Ibe/D68gANQU=&#124;qW6uAzcpecOOKNI4zEvngyfpGkI= &#124;1&#124;n+QrRn7QXeAJ5hRe2M8v8IspihE=&#124;EqUxXdSeIF1cl1fQjl5zILebkGY= &#124;1&#124;BOKuKnWojy028tJf9Y671lws0d0=&#124;SuBQJmJZp5JNVYG/rP9yb9ZhJcE= &#124;1&#124;WACsxtodOiM89kf4rNPLgF1CXZ4=&#124;UTccVeLDZJF3wlH8V05XJNlsOBw= &#124;1&#124;o6FFoirXYblM7wBMdeJDYGMPI58=&#124;5jJB7T7itY702ZHHByXtSpGk9SE= The column fields are similar to [...]]]></description>
			<content:encoded><![CDATA[<p>I don&#8217;t expect you to follow this post completely, but it&#8217;s so amazingly cool, I have to blog it. Consider the hashed sections of ~/.ssh/known_hosts file for (recent) OpenSSH clients, not including the public key parts:</p>
<pre>|1|kFJT5z0x3ndyutgZ4E5pRk+ORBA=|hzXvdYUudo+qK9BGlFWtSAUXlXc=
|1|8wo1+FO0hkATPgQZoeNHeIlvAjw=|dt/a9jz9CnLKP72j+Jr8MKMjgEE=
|1|pvBQEKEGLnH0RCJr+8Dmqqnvlrs=|fJJvjyG/TmHFnuIX57nDThq/C4M=
|1|HKV4DzgDkajXoUHf9B82JBu7J10=|c/K+MdJvWaZeJFs/W7iqhqo0wvE=
|1|rtvQhRVnNanQZYkLUMbjoBGNhn0=|0U6a1LUQqLL6P1T2Wji3VWw69pw=
|1|0ziSYi4c+xBXGEBZcNN1LMhYUc4=|qRSN5GSPyQi+fmaVz2zNwkmKoy8=
|1|6nv6Vpk3AYgICHxJGVgVdsYRuq0=|fBNOIz1l3RW+N61jyDPunKX9n7E=
|1|+b4uA+Mq7RHRAFW21qv8aO3rIRs=|1eizMri01IxEKrXquBnwTYP61Ow=
|1|BkB0PZu2qtsLID/Ibe/D68gANQU=|qW6uAzcpecOOKNI4zEvngyfpGkI=
|1|n+QrRn7QXeAJ5hRe2M8v8IspihE=|EqUxXdSeIF1cl1fQjl5zILebkGY=
|1|BOKuKnWojy028tJf9Y671lws0d0=|SuBQJmJZp5JNVYG/rP9yb9ZhJcE=
|1|WACsxtodOiM89kf4rNPLgF1CXZ4=|UTccVeLDZJF3wlH8V05XJNlsOBw=
|1|o6FFoirXYblM7wBMdeJDYGMPI58=|5jJB7T7itY702ZHHByXtSpGk9SE=</pre>
<p>The column fields are similar to that of the /etc/shadow file on GNU systems, except where the &#8220;$&#8221; is the column delimiter, &#8220;|&#8221; is in this case. If the string was &#8220;|1|o6FFoirXYblM7wBMdeJDYGMPI58=|5jJB7T7itY702ZHHByXtSpGk9SE=&#8221;, then the breakdown is as follows:</p>
<ul>
<li><strong>|1</strong>- HASH_MAGIC. This tells the client that the host information has been salted and hashed with the SHA1 algorithm.</li>
<li><strong>|o6FFoirXYblM7wBMdeJDYGMPI58=</strong> This is the salt applied to the host- base 64 encoded 160-bit string.</li>
<li><strong>|5jJB7T7itY702ZHHByXtSpGk9SE=</strong> This is the base 64 encoded version of the hashed host</li>
</ul>
<p>Now, if you want to get at the actual strings, not base 64 encoded, you could run the following command (I admit, not elegant, and could probably be better solved without nesting, and a single awk(1) statement, but I&#8217;ll get to that later):</p>
<pre>% echo $(echo o6FFoirXYblM7wBMdeJDYGMPI58= | openssl base64 -d | xxd | cut -c 10-48) | sed 's/ //g'
a3a145a22ad761b94cef004c75e24360630f239f
% echo $(echo 5jJB7T7itY702ZHHByXtSpGk9SE= | openssl base64 -d | xxd | cut -c 10-48) | sed 's/ //g'
e63241ed3ee2b58ef4d991c70725ed4a91a4f521</pre>
<p>There you have it. Very cool. Now, the only question is how to apply the salt to the hostname, to get to the hash? I&#8217;m working that out, but I wasn&#8217;t motivated enough to get to it. Of course, there&#8217;s no application to this, that I can tell, unless you want to brute force the known_hosts file.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/12/30/making-sense-of-hashed-hosts-in-sshknown_hosts/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenSSH Best Practices</title>
		<link>http://pthree.org/2011/07/22/openssh-best-practice/</link>
		<comments>http://pthree.org/2011/07/22/openssh-best-practice/#comments</comments>
		<pubDate>Fri, 22 Jul 2011 07:46:54 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1930</guid>
		<description><![CDATA[This post comes from Matt Taggart, who put together a document about the best practices for using OpenSSH. A lot of the points brought up in that document rang the bells of common sense, and are so good, it&#8217;s worth blogging about in hopes that the points mentioned therein reach as many as possible. I&#8217;ve [...]]]></description>
			<content:encoded><![CDATA[<p>This post comes from Matt Taggart, who put together a document about the <a href="http://lackof.org/taggart/hacking/ssh/">best practices for using OpenSSH</a>. A lot of the points brought up in that document rang the bells of common sense, and are so good, it&#8217;s worth blogging about in hopes that the points mentioned therein reach as many as possible. I&#8217;ve also added a couple extra points that I&#8217;ve learned with my experience using OpenSSH.</p>
<p>These are best practices from the client perspective, not the server. Many of these points you will have already been familiar with, but some of them not as much. If you sit down and think about what you are doing as a client when you SSH to a server, some of the implications mentioned here make sense.</p>
<p>Lastly, security is a big topic, and not something that can be flipped on and off with a switch. Security always starts with the user. Unfortunately, increasing your security could mean making usability more of a pain in the rear. However, as an OpenSSH client, I hope the techniques mentioned here won&#8217;t decrease your usability too bad, while greatly increasing your overall OpenSSH security. With that said, let&#8217;s get started.</p>
<p><strong>0. Use ECC first, then RSA, then DSA with maximum bit strength.</strong><br />
When generating your OpenSSH keys, you should be aware of the cryptographic algorithms of the OpenSSH server that you are accessing, and what you can and cannot use. As of OpenSSH version 5.7, <a href="http://pthree.org/2011/02/17/elliptic-curve-cryptography-in-openssh/">elliptic curve cryptography is a supported algorithm</a>. It is proving to be a very secure, robust and light crypto algorithm, but it also must be supported by both the client and the remote server. This means that both the client and the server must be relatively new installations of OpenSSH- something that RHEL 6 and earlier, Debian GNU/Linux Stable 6 and earlier, Ubuntu 10.10 and earlier, and likely many other stable releases from other GNU/Linux operating systems, do not support. When you can, use elliptic curve cryptography for your SSH keys.</p>
<p>If ECC is not available on either your client or server, then you should choose RSA as your key&#8217;s crypto. DSA suffers from a weakness, where if the host does not have a sufficiently strong pseudorandom number generator (PRNG), then the &#8220;random k&#8221; could become exposed from the public key, allowing the attacker to build the private key from the public. The PRNG supplied by GNU/Linux (the device file &#8220;/dev/urandom&#8221;) is sufficiently strong, providing good random data from entropy pools- thus, GNU/Linux generally doesn&#8217;t suffer from this problem. Other operating systems could.</p>
<p>A great demonstration of DSA&#8217;s weakness can be found in <a href="http://rdist.root.org/2010/11/19/dsa-requirements-for-random-k-value/">this excellent blog post</a>, where the author demonstrates how trivial it is to build the private key when the &#8220;random k value&#8221; is known. Fortunately, RSA does not suffer from this weakness, and also allows you to build larger keys than DSA.</p>
<p>If neither ECC nor RSA is supported by the client nor server, as is the case with some archaic proprietary SSH implementations, then DSA is your only option. Unfortunately, it is also the default for OpenSSH when generating a key. So, you should always get into the habit of passing the &#8220;-t [type]&#8221; switch when generating your keys.</p>
<p>In all 3 cases, where possible, you should choose the maximum bit strength that the algorithm allows. This will put a bit of strain on the client&#8217;s CPU, but it will also give you the greatest strength when authenticating on the wire. When generating your key, use the &#8220;-b [size]&#8221; switch to specify the bit strength.</p>
<p><strong>1. Use SSH keys and make your servers require them.</strong><br />
There are three reasons why you would want to use SSH keys:</p>
<ol>
<li>SSH keys with a passphrase provide two-factor authentication.</li>
<li>SSH passwords can be read in plain text on the remote server.</li>
<li>SSH keys aren&#8217;t subject to brute force dictionary attacks, like passwords.</li>
</ol>
<p>Let&#8217;s cover each in detail. First, two-factor authentication. SSH keys use public key cryptography. You are given a private and public key when generated. During generation, you are asked to provide a passphrase for the private key. DO NOT GIVE IT AN EMPTY PASSPHRASE! By providing a passphrase to your key, you have enabled the two-factor authentication- something you have (the key) and something you know (the passphrase). Using SSH keys can be troublesome, however. As a result, take advantage of the SSH agent for your system to cache the passphrase locally on your client. This will increase your usability by only entering your key passphrase once, and using the agent to login to other servers without providing the key passphrase again.</p>
<p>Second is reading the user password in plain text on the remote SSH server. You may not think this is possible, as everything in OpenSSH is encrypted, right? Wrong. The two Achilles Heel&#8217;s in the connection are the client and servers themselves, where the decryption is taking place. Other users, specifically those who have superuser access, can exploit this. To demonstrate this, make a connection to a server that you have superuser access on. Then, from the client initiate a connection that would require your server password, but don&#8217;t supply it. Go back to the server, and find the process of the connection, and run an strace on the PID. Go back to the client, and type in your password. Watch, very likely in horror, the password be displayed on your console.</p>
<p><a href="http://blog.josephhall.com/2009/12/fun-with-sshd-and-strace.html">Here is an excellent writeup</a> by Joseph Hall on this very issue. The problem lies in whether or not you trust those who have superuser access on the server. You should only trust them enough to do their job on the server, and nothing more. Just because they have superuser access on the server, doesn&#8217;t mean they can be trusted with your banking account information. Because people use the same passwords over and over across multiple accounts, it&#8217;s likely that the password sniffed out of the connection is the same password for their email account. Or bank.</p>
<p>Third, as should be obvious, SSH keys aren&#8217;t subject to brute force dictionary attacks like passwords are. If you control the SSH server, and require that SSH keys are the mode of authentication, then brute force attacks will be in vain, regardless how long they try. If you have a publicly facing SSH server, you&#8217;re likely aware of how hard your server gets hit from attackers all over the world. By forcing key authentication, all those attacks are in vain.</p>
<p><strong>2. Don&#8217;t use a blank passphrase on your keys.</strong><br />
This should come as no surprise, but needs to be mentioned. Your SSH keys are something that should be guarded carefully, with sufficient paranoia. If for any reason, your SSH client is compromised, your SSH keys are a way in to the remote servers that you have access to. If your keys are not protected by passphrases, then after scouring your shell history, or SSH config for hosts to connect to, they&#8217;re in the SSH server with little effort. You must protect your keys with strong passphrases!</p>
<p>Now, I understand that there are some like me, who use SSH as the connection for nightly local backups, at which point the client will be asked for the passphrase of the SSH key. Because you wish this to be an automated process, and likely when you&#8217;re in bed, you won&#8217;t be available all the time to provide the credentials. So, you create an SSH keypair that is not passphrase protected. In such a scenario, here is what I would do:</p>
<ol>
<li>Only install this key on the backup SSH server, and no where else.</li>
<li>Do not install this key into an account that has superuser access.</li>
<li>Do not install this key into the superuser account.</li>
<li>On the backup server, change the key entry in the authorized_keys file to only allow connections from that client using that key (documented how below).</li>
</ol>
<p>The first, second and third points are easy enough to configure, but how do you configure the fourth point, and is it even possible? When you copy the key to the authorized_keys file on the SSH server, it could look something like this:</p>
<pre>ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAzoblHIUARNP5Kq12QwUqxB6T7m8TWti4LIFcvOCa...</pre>
<p>Change the beginning of that entry to this:</p>
<pre>from="10.19.84.10",command="/home/user/bin/validate.sh" ssh-rsa AAAAB3NzaC1y...</pre>
<p>This tells the server that the only connections allowed to use this key can come from &#8220;10.19.84.10&#8243;, and when the connection is made, a local script is ran called &#8220;validate.sh&#8221;. Here are the contents of that script for me:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #666666; font-style: italic;">#!/bin/sh</span><br />
<br />
<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SSH_ORIGINAL_COMMAND</span>&quot;</span> <span style="color: #000000; font-weight: bold;">in</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">&amp;*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\;<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">&lt;*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">`*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span>\<span style="color: #000000; font-weight: bold;">|*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; rsync\ --server<span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #007800;">$SSH_ORIGINAL_COMMAND</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">*</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;Rejected&quot;</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">;;</span><br />
<span style="color: #000000; font-weight: bold;">esac</span></div></td></tr></tbody></table></div>
<p>Make sure the script is executable by the user account on the SSH server, and test it before committing to it as part of your backup policy. If the client host is behind a dynamic IP address, or some other variable that prevents it from having a static address, you can remove the &#8220;from=&#8221; part, but leave the &#8220;command=&#8221; part. The goal is to minimize damage that can be done with that key.</p>
<p>Again, this is all if you need to perform an automated backup with SSH keys, where a passphrase cannot be performed. In almost every other case, your SSH key should be protected by a good, strong, <a href="http://pthree.org/2011/03/07/strong-passwords-need-entropy/">loaded with entropy</a> passphrase. Using one from a <a href="http://pthree.org/2010/09/21/password-cards/">passwordcard</a> is probably best.</p>
<p><strong>3. Use a separate key for every client you SSH from.</strong><br />
I admit that when I first started using SSH, this didn&#8217;t make much sense to me. The amount of keys that I generated was a lot, and managing them became somewhat of a pain. Then, when becoming system administrator of a large organization, and controlling upwards of 300 servers, managing that many keys become immensely intense.</p>
<p>I soon came to the realization that it wasn&#8217;t that big of a deal. It is trivial to copy the key to the remote host (this can be done with the &#8220;<a href="http://linux.die.net/man/1/ssh-copy-id">ssh-copy-id(1)</a>&#8221; command). Further, for work SSH keys, while I am in charge of managing those keys, I should only worry about work keys at work, and home keys at home. In other words, separate the management of the keys.</p>
<p>But the point of this is to NOT copy the same client key to multiple clients. Think about it. By copying the key around to multiple clients, this means that the key is on every server you ever access from those clients, even if some of the other clients cannot access that server directly. Thus, if a client is compromised, and the key is stolen, it&#8217;s difficult to know which client was compromised, and all servers that have that key in their authorized_keys file, are subject to compromise. If you have a different key for each client, then those keys are only on the servers that the client has direct access to, and should a client become compromised, you know which servers to saefguard, and damage is minimal.</p>
<p><strong>4. Limit the number of clients you SSH from.</strong><br />
If an attacker can compromise your client, then they can get access to your SSH keys, as they are stored on the filesystem. Further, they may be able to install a keylogger to log passwords and passphrases, including those for your key. Once this information is gained, then all the accounts on the servers the key is installed on are now compromised as well. By limiting the number of clients you SSH from, you minimize the exposure of SSH servers to the attacker.</p>
<p><strong>5. Don&#8217;t &#8220;chain&#8221; or &#8220;loop&#8221; logins, but do &#8220;star&#8221;.</strong></p>
<p><img alt="" src="http://lackof.org/taggart/hacking/ssh/ssh.png" title="SSH Scenarios" class="alignnone" width="961" height="262" /></p>
<p>The point relates to the one above it, namely limiting the number of hosts you SSH FROM. There are a few scenarios on how you can create SSH sessions:</p>
<ul>
<li>Chain: As a client, you make a connection with an SSH server. Then, from that server, you make another connection to a different SSH server. Once, twice, three times or more, you&#8217;ve created a chain of connections from the client to the final host.</li>
<li>Loop: As a client, you make a connection with an SSH server. Then, from that server, you make a connection back to the client you started from, thus creating a loop with your connections.</li>
<li>Star: As a client, one connection is made to an SSH server. If another connection is needed to a different SSH server, this is made from the client. For each connection, the original client makes it.</li>
</ul>
<p>The reasons why this is a &#8220;best practice&#8221; might not be obvious. Let&#8217;s start first with chaining connections. If one client is compromised in the chain, the other clients in the chain might possibly be compromised using the same method. Thus, all connections in the chain could become compromised. And a loop is nothing more than a specific instance of a chain.</p>
<p>Of course, this isn&#8217;t always possible. Maybe a chain is the only way to get to an SSH server on a private VLAN or behind a DMZ. These connections might be necessary (typically called &#8220;jump hosts&#8221;), but they should be used with caution, and as little as possible. When you are done with your task, rather than idle the SSH connection, terminate it to minimize exposure, should an attack occur.</p>
<p>When using a jump host, install netcat(1) on the jump host and use the ProxyCommand configuration paramater. Something like this would be sufficient:</p>
<pre>Host inaccessiblehost1 inaccessiblehost2
   ProxyCommand ssh accessiblehost nc -q0 %h %p</pre>
<p>With star connections, you minimize the risk of compromise with each of your connections, but security is maximized, even if extra work is required on your end. For example, if you wish to transfer data from one SSH server to another, this may mean bringing the data to the client, then sending it to the destination server.</p>
<pre></pre>
<p><strong>6. Consider disabling the SSH server on the client you are connecting from.</strong><br />
This rule shouldn&#8217;t apply only to the SSH server, but to any daemon you have running on your machine. If you don&#8217;t need a service running, then turn it off. By doing so, you minimize the attack vector and greatly increase your security. OpenBSD prides itself in having only two remote holes in the default install in a heck of a long time, but then it also doesn&#8217;t have any services running on a default install either.</p>
<p>So, for SSH, because you followed rule #5, and you aren&#8217;t doing &#8220;chain&#8221; or &#8220;loop&#8221; connections from your client, then this means that you&#8217;re not connecting to your own machine that you started your initial connection from. I understand that this isn&#8217;t always possible. I have 300+ SSH servers at work, and I can&#8217;t possible turn off the SSH server on a host, just because I&#8217;m connecting from it. But then, do I need an SSH server on my virtual laptop? Not likely, and if there are things I need, I can turn it on, do my work, then turn it off.</p>
<p><strong>7. Don&#8217;t ignore SSH host key warnings.</strong><br />
When you install an SSH server for the first time, it creates a server public and private keypair. This set of keys is what is used for the encryption and decryption between your client and the SSH server. Thus, all traffic that you are sending to that server, is done because you trust that the SSH server key presented to you, is indeed the key of the server itself. So, what happens when you connect a different time, and your client warns you that the public SSH server key has changed? Should you trust the connection?</p>
<p>Depends. Usually, it&#8217;s due to the fact that you either reinstalled the SSH server or reinstalled the operating system. In this case, you can move forward, so long as you know that the key presented is the new key from the server. However, someone could setup a proxy SSH server, for the intent of gaining system passwords. Your client will warn you the key is different, and you should pay attention to the warning.</p>
<p>So, in your SSH client config, you generally should not set the following:</p>
<pre>Host *
    StrictHostKeyChecking no</pre>
<p>Default is &#8220;yes&#8221;, and it should stay yes in your config. OpenSSH is verbose enough for your benefit. Try to take advantage of it, rather than silence it, or ignore it. After all, it&#8217;s your data.</p>
<p><strong>8. Be wary of using X11 forwarding.</strong><br />
While taking advantage of the ability to run remote X applications locally on your client is nice, it has some very grave drawbacks. For example, it&#8217;s common for people to launch a remote browser, such as Firefox. What isn&#8217;t realized, is that you&#8217;re providing usernames and passwords through the browser, which could be caught on the remote machine from which the app is running (taking advantage of X events, for example).</p>
<p>There is a time and a place for X11 forwarding, and I have benefited by it, but generally, it&#8217;s not needed. Set the following in your SSH client config, and only enable it when needed:</p>
<pre>Host *
    ForwardX11 no</pre>
<p><strong>9. Don&#8217;t use agent forwarding.</strong><br />
As with X11 forwarding, you are giving ultimate trust to the remote host when forwarding your local agent. If that connection makes a connection to an account with superuser privileges, then a user on the remote SSH server could hijack your agent by connecting to the socket the SSH server creates.</p>
<p>Also, on the client initiating the connection, the superuser must be trusted, which isn&#8217;t always the case. The local superuser can access the agent socket on the client, and attack. Thus, it&#8217;s generally not a good idea to enable agent forwarding. Thus, as it is by default, the following should be sent in your client SSH config:</p>
<pre>Host *
    ForwardAgent no</pre>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/07/22/openssh-best-practice/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Convert Text To Base-64 By Hand</title>
		<link>http://pthree.org/2011/04/06/convert-text-to-base-64-by-hand/</link>
		<comments>http://pthree.org/2011/04/06/convert-text-to-base-64-by-hand/#comments</comments>
		<pubDate>Thu, 07 Apr 2011 05:11:20 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1862</guid>
		<description><![CDATA[When I was a kid, I had this fascination with cryptography. I learned and used, as most kids to, the Caesar cipher first (using my trusty Captain Crunch Decoder Ring), then later learned and used the Affine cipher. It was great for passing notes in class when I was in elementary and secondary education. I [...]]]></description>
			<content:encoded><![CDATA[<p>When I was a kid, I had this fascination with cryptography. I learned and used, as most kids to, the Caesar cipher first (using my trusty Captain Crunch Decoder Ring), then later learned and used the Affine cipher. It was great for passing notes in class when I was in elementary and secondary education. I even learned the ancient runes, and used those quite a bit too.</p>
<p>Since then, I&#8217;ve been fascinated by hand cipher techniques, and I&#8217;ve learned a few historical ones over the years. I&#8217;ve even invented my own hand cipher, even though I doubt it would show any form of cryptanalytic strength. While I don&#8217;t do anything with hand ciphers practically, I still consider it a fun skill to have, whether or not it actually proves to be useful (when I was a Boy Scout, I always wanted to learn Morse Code, so I could tap out answers to a quiz or test in class to a fiend, and back to me without anyone knowing. How cool would that be?!).</p>
<p>While I know base-64 is not considered a cipher algorithm, I thought to myself that I don&#8217;t know how to convert a string of ASCII text to base-64 by hand. So, I figured I might as well learn. It could be an interesting skill to add to my own hand cipher, and could even prove to be useful around the house. So, if you&#8217;re curious, here we go.</p>
<p><strong>STEP ONE: Know the ASCII code chart</strong></p>
<p>I would recommend memorizing or printing out (and stuffing in your wallet) this chart here: <a href="http://en.wikipedia.org/wiki/File:ASCII_Code_Chart-Quick_ref_card.png">http://en.wikipedia.org/wiki/File:ASCII_Code_Chart-Quick_ref_card.png</a>. Reason being, is you need to covert the ASCII text to numerical binary. The chart linked to gives you the table on how to do it.</p>
<p>Really, you can use any standard ASCII chart that provides you with the decimal, octal or hexadecimal values of the character. So long as you can convert it to binary, that&#8217;s all that matters. I like the linked chart above, because it gives it to me out the gate, which is one less conversion to worry about.</p>
<p><strong>STEP TWO: Convert your ASCII string to numerical binary</strong></p>
<p>This is the tedious part. It&#8217;s going to take you some time to write down every character in 8-bit binary. I need to stress that you need to write down the FULL 8 BITS, even though the card linked to only gives you 7. So, the 8th bit will always be zero when writing down the full binary word. Here&#8217;s a rundown of how you would read the card:</p>
<ol>
<li>Find the character you wish to convert</li>
<li>Write down 0 + the first three binary bits on the top</li>
<li>Write down the last four binary bits for that letter on the left</li>
</ol>
<p>So, for example, the text &#8220;green&#8221; would be &#8220;01100111 01110010 01100101 01100101 01101110&#8243;. Notice that each binary word is 8 bits, each with leading zeros. This should be the case for EVERY character you write down. Further, the space between letters is NOT ignored. It has the binary value of &#8220;00100000&#8243; (&#8220;SP&#8221; in the chart).</p>
<p><strong>STEP THREE: Pad at the end as necessary with zeros</strong></p>
<p>The total number of bits should be divisible by 6. If it is not, add the necessary zeros at the end until it is. So, for our example of &#8220;green&#8221;, we have a total of 40 bits, which means we need to add two more zeros to make it divisible by 6 (42 divided by 6 is 7). It&#8217;s important that you stop at the first multiple of 6, which means that you should never be adding more than 4 zeros. In fact, you will either be adding two zeros, four zeros, or none at all.</p>
<p>So, for &#8220;green&#8221; with padded zeros at the end, our binary string becomes: &#8220;01100111 01110010 01100101 01100101 01101110 00&#8243;</p>
<p><strong>STEP FOUR: Divide your binary string into words of 6 bits</strong></p>
<p>Because our binary string is now divisible by six, we want to make 6-bit words using the same string. So, for &#8220;green&#8221;, I should end up with 7 total words (because I have 42 bits total in the string). As a result, &#8220;01100111 01110010 01100101 01100101 01101110 00&#8243; becomes &#8220;011001 110111 001001 100101 011001 010110 111000&#8243;</p>
<p><strong>STEP FIVE: Convert your 6-bit words to decimal</strong></p>
<p>Now we need to covert the newly created binary words into decimal. You need to know your binary to pull this off. Thankfully, this isn&#8217;t too terribly difficult- you just need to know your powers of 2. So, our string of &#8220;011001 110111 001001 100101 011001 010110 111000&#8243; becomes &#8220;25 55 9 37 25 22 56&#8243;.</p>
<p><strong>STEP SIX: Convert decimal to ASCII</strong></p>
<p>Now, we need to covert our newly calculated decimal numbers to ASCII, and we&#8217;ll almost be finished. For this, we&#8217;re going to use a different chart than what we started with. We need a chart that will correspond to our values, starting at 0 and ending on 63 (64 possible values, thus the reason it&#8217;s called &#8220;base-64&#8243;).</p>
<ol>
<li>If the value is between 0 and 25, then the character is uppercase &#8220;A-Z&#8221; respectfully.</li>
<li>If the value is between 26 and 51, then the character is lowercase &#8220;a-z&#8221; respectfully.</li>
<li>If the value is between 52 and 61, then the character is the numbers &#8220;0-9&#8243; respectfully.</li>
<li>If the value is 62 or 63, then the character is &#8220;+&#8221; and &#8220;/&#8221; respectfully.</li>
</ol>
<p>If that was confusing to you, see the table at <a href="http://en.wikipedia.org/wiki/Base64#Examples">http://en.wikipedia.org/wiki/Base64#Examples</a>.</p>
<p>So, for our string of numbers &#8220;25 55 9 37 25 22 56&#8243;, which came from the text &#8220;green&#8221;, we see the following come out: &#8220;Z3JlZW4&#8243;.</p>
<p><strong>STEP SEVEN: Pad the string with &#8220;=&#8221; as necessary</strong></p>
<p>The last step in your conversion is to pad the string with &#8220;=&#8221; as necessary, so the total number of your characters is divisible by four. Our base-64 string has only 7 characters, so we must add a &#8220;=&#8221; at the end to bring the total to 8 characters, which is indeed divisible by four. Thus, we would end up with &#8220;Z3JlZW4=&#8221; as the final result for &#8220;green&#8221;.</p>
<p><strong>QUICK EXAMPLE: &#8220;Attack at dawn!&#8221;</strong></p>
<ol>
<li>Attack at dawn!</li>
<li>01000001 01110100 01110100 01100001 01100011 01101011 00100000 01100001 01110100 00100000 01100100 01100001 01110111 01101110 00100001</li>
<li>010000 010111 010001 110100 011000 010110 001101 101011 001000 000110 000101 110100 001000 000110 010001 100001 011101 110110 111000 100001</li>
<li>No zero padding necessary</li>
<li>16 23 17 52 24 22 13 43 8 6 5 52 8 6 17 33 29 54 56 33</li>
<li>QXR0YWNrIGF0IGRhd24h</li>
<li>No &#8220;=&#8221; padding necessary</li>
</ol>
<p><strong>NOTE:</strong></p>
<p>The base 64 utilities that ship with GNU Coreutils and OpenSSL use a different padding at the end of the encoded string than just equal signs. I haven&#8217;t parsed the code yet, so I don&#8217;t know why this is, but from what I&#8217;m reading online, the standard is to use just &#8220;=&#8221;, unless I&#8217;m missing something. If anyone knows why &#8220;K&#8221;, &#8220;o=&#8221; and others show up, I&#8217;m all ears. Thanks.</p>
<p><strong>CONCLUSION:</strong></p>
<p>Encoding text to base-64 certainly doesn&#8217;t really yield any cryptographic strength, and there exist utilities for doing it on the computer. So, why bother learning it by hand? As stated earlier, it&#8217;s a fun skill to have around the house. Combine it with other hand ciphers that you might already know, and you could have a decent algorithm on your hands (pun intended). Heck, let&#8217;s see your English teacher decrypt your notes now!</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/04/06/convert-text-to-base-64-by-hand/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Verifying Hashcash Tokens With Mutt</title>
		<link>http://pthree.org/2011/03/29/verifying-hashcash-tokens-with-mutt/</link>
		<comments>http://pthree.org/2011/03/29/verifying-hashcash-tokens-with-mutt/#comments</comments>
		<pubDate>Wed, 30 Mar 2011 03:32:35 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1842</guid>
		<description><![CDATA[Just five days ago, I blogged about minting Hashcash tokens in Mutt using a Python script (make sure you check that page for any updates to the source if you&#8217;re using it). Well today, I finished writing my verification script. It takes some additional changes to your ~/.muttrc, which I&#8217;ll outline here, and it requires [...]]]></description>
			<content:encoded><![CDATA[<p>Just five days ago, I blogged about <a href="http://pthree.org/2011/03/24/hashcash-and-mutt/">minting Hashcash tokens in Mutt</a> using a Python script (make sure you check that page for any updates to the source if you&#8217;re using it). Well today, I finished writing my verification script. It takes some additional changes to your ~/.muttrc, which I&#8217;ll outline here, and it requires the installation of a Python script. Of course, as previous, I&#8217;m assuming that you&#8217;re running at least Python 2.5 and the latest version of <a href="http://hashcash.org">Hashcash</a>. With that, let&#8217;s get busy.</p>
<p>First, the necessary changes to your &#8220;~/.muttrc&#8221; config. The script relies on the &#8220;X-Hashcash:&#8221; header (as well as the &#8220;Hashcash:&#8221; header- I guess there was some discrepancy or something about X-headers being deprecated, or something) not being weeded out. It must be displayed if present. This way, the script can actually see the token in the header, and process the logic of checking if it&#8217;s valid. If you hid the hashcash headers, then the script won&#8217;t execute, and as a result, won&#8217;t add anything to the token database. We use the $display_filter variable to execute the Python script, and show the results to the pager. Here&#8217;s the changes you will need to make:</p>
<pre># file: ~/.muttrc
ignore *                                    # draconian header weed - recommended
unignore from date subject to cc user-agent # standard headers unignored - recommended
unignore x-hashcash hashcash                # required</pre>
<p>You will also need to set the $display_filter variable. I like having my theme consistent, so I&#8217;ve also added color to my theme to show the Hashcash verification at the top of the mail:</p>
<pre># file: ~/.muttrc
set display_filter="/path/to/verify_hashcash.py"    # required
color body brightyellow default "^\\[--.*Hashcash*" # recommended</pre>
<p>Now with that set, all we need to do is install the Python script, and we&#8217;re ready to go. When looking over the code, you&#8217;ll notice that it&#8217;s creating a database of spent tokens. I&#8217;ve placed the database in ~/.mutt/, seeing as though I only have Mutt working with Hashcash at the moment (and it&#8217;s really the only MUA I use these days). If you have something else that uses Hashcash tokens, in an already existing database, you may want to make the necessary modifications to the Python script, so it&#8217;s pointing to the right file. Also, we&#8217;re only interested in keeping track of tokens minted for us personally, not all tokens we can find in the headers. Lastly, this Python script is only working for one email address. If you have multiple emails, as I do, you&#8217;ll have to either use a primary email to verify the tokens against, or modify the Python script to support checking tokens under multiple accounts.</p>
<p>With that said, here&#8217;s the script:</p>
<div class="codecolorer-container python twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;"># Licensed under the public domain</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">rfc822</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">StringIO</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Change the DB path in COMMAND as needed, and change your email address</span><br />
COMMAND<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;hashcash -cdb '%s' -r '%s' -f /home/user/.mutt/hashcash.db '%s'&quot;</span><br />
EMAILADDR<span style="color: #66cc66;">=</span><span style="color: #483d8b;">&quot;foo@bar.com&quot;</span><br />
<br />
tokens <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
token_status <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># converting a list to a file-type object for parsing rfc822 headers</span><br />
original <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdin</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
emailmsg <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">StringIO</span>.<span style="color: #dc143c;">StringIO</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>original<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
message <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">rfc822</span>.<span style="color: black;">Message</span><span style="color: black;">&#40;</span>emailmsg<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># check for the presence of &quot;X-Hashcash&quot; and &quot;Hashcash&quot; headers</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> message.<span style="color: black;">has_key</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;X-Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> hc_list <span style="color: #ff7700;font-weight:bold;">in</span> message.<span style="color: black;">getheaders</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;X-Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; tokens.<span style="color: black;">append</span><span style="color: black;">&#40;</span>hc_list<span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> message.<span style="color: black;">has_key</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> hc_list <span style="color: #ff7700;font-weight:bold;">in</span> message.<span style="color: black;">getheaders</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; tokens.<span style="color: black;">append</span><span style="color: black;">&#40;</span>hc_list<span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># check each token</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> tokens:<br />
&nbsp; &nbsp; token_status.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;[-- Begin Hashcash output --]&quot;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> hc_token <span style="color: #ff7700;font-weight:bold;">in</span> tokens:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> hc_token.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span> <span style="color: #66cc66;">==</span> EMAILADDR:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hc_bits <span style="color: #66cc66;">=</span> hc_token.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; hc_resource <span style="color: #66cc66;">=</span> hc_token.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; p <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span>COMMAND % <span style="color: black;">&#40;</span>hc_bits<span style="color: #66cc66;">,</span>hc_resource<span style="color: #66cc66;">,</span>hc_token<span style="color: black;">&#41;</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; shell<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: #66cc66;">,</span> stderr<span style="color: #66cc66;">=</span><span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: #66cc66;">,</span> stdout<span style="color: #66cc66;">=</span><span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; out <span style="color: #66cc66;">=</span> p.<span style="color: black;">stderr</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token_status.<span style="color: black;">append</span><span style="color: black;">&#40;</span>out<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; token_status.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;No valid tokens for %s found.&quot;</span> % EMAILADDR<span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; token_status.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;[-- End Hashcash output --]&quot;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>message.<span style="color: black;">headers</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> status <span style="color: #ff7700;font-weight:bold;">in</span> token_status:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>status<span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> tokens:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">''</span><br />
emailmsg.<span style="color: black;">seek</span><span style="color: black;">&#40;</span>message.<span style="color: black;">startofbody</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #66cc66;">&gt;&gt;</span> <span style="color: #dc143c;">sys</span>.<span style="color: black;">stdout</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">''</span>.<span style="color: black;">join</span><span style="color: black;">&#40;</span>emailmsg.<span style="color: black;">readlines</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>One thing I do find odd about the code above, is the hashcash binary, when checking tokens, prints to STDERR rather than STDOUT. I&#8217;m guessing this could change in the future, so that&#8217;s something that will need to be watched out for.</p>
<p>So far, the Python script has been working flawless for me. I haven&#8217;t noticed a single hiccup, and it&#8217;s fast, which it should be. However, standard disclaimers apply, such as not coming with any warranty, blah, blah, blah, and if you find any bugs, or have any enhancements (such as supporting multiple email addresses), I&#8217;m all ears. At any rate, I hope you find it helpful, should you wish to get into Hashcash with Mutt.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/03/29/verifying-hashcash-tokens-with-mutt/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Hashcash and Mutt</title>
		<link>http://pthree.org/2011/03/24/hashcash-and-mutt/</link>
		<comments>http://pthree.org/2011/03/24/hashcash-and-mutt/#comments</comments>
		<pubDate>Fri, 25 Mar 2011 00:09:58 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Scripting]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1814</guid>
		<description><![CDATA[Introduction I wanted to used Hashcash with Mutt, for nothing more than a curiosity to see if it generates any discussion, and to see if people notice. Further, I&#8217;m a big crypto advocate, and while Hashcash isn&#8217;t exactly crypto, it&#8217;s highly related to it, and uses it. Regardless, I wanted to see if I could [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Introduction</strong></p>
<p>I wanted to used Hashcash with Mutt, for nothing more than a curiosity to see if it generates any discussion, and to see if people notice. Further, I&#8217;m a big crypto advocate, and while Hashcash isn&#8217;t exactly crypto, it&#8217;s highly related to it, and uses it. Regardless, I wanted to see if I could seamlessly tie in Hashcash with Mutt, both for minting and verification.</p>
<p>I make the following assumptions:</p>
<ul>
<li>You have Hashcash installed.</li>
<li>You have Mutt installed.</li>
<li>You have Python 2.5 or later installed.</li>
</ul>
<p>With that, let&#8217;s continue.</p>
<p><strong>What is Hashcash?</strong></p>
<p>Hashcash is a proof-of-work protocol, with the motivation of eliminating SPAM. The idea is simple, although we&#8217;ll cover it in greater detail. The TL;DR version, is using Hashcash is about generating tokens, and attaching them to the header of the message you&#8217;re sending. The recipient checks the token for verification. If it passes, then you must not be SPAM, as you&#8217;ve put your computer through enough strenuous work to prove it. If the token fails, you could be SPAM, or you just did it wrong. Either way, it&#8217;s no guarantee that you&#8217;re not a spammer.</p>
<p>Now, the detailed version.</p>
<p>The premise behind Hashcash is that some certain mathematical results are difficult to discover but easy to verify. Factoring large numbers is one such example. So Hashcash is some sort of challenge for your CPU. For example, I say that you cannot comment on my blog, unless you can find the two prime factors of some large number. Once you&#8217;ve paid the work through CPU cycles, and provide the numbers, I multiply them together to see if it gives the result. The work was difficult for you to find, but simple for me to verify. Hashcash is based on this principle.</p>
<p>Using a lot of CPU cycles to answer a question non-interactively is one way to beat spammers at their own game, which Hashcash hopes to address. Rather than looking for large prime factors though, Hashcash is looking for a SHA1 sum of a unique string where the first set of characters in the sum are zero. Because SHA1 can provide 2^160 possible hashes before a collision is found, it shouldn&#8217;t take too much work to find such a string. In other words, the search space is large enough for the work to be reasonable. However, the search space is also large enough, that given a certain criteria, it can be difficult to find the requested string.</p>
<p>Let&#8217;s look at an example. Consider the SHA1 string:</p>
<pre>00000528ba02c4da777839db269fde97de56ddf7</pre>
<p>The first 20 bits of the string are zero. So, this is one such SHA1 hash that would work. The questions are, how did we find it, and what string did we use to generate it? Well, because the first 20 bits of the string are zero, this means that I should only have to search up to 2^20 possible hashes to find the string I&#8217;m looking for. On a moderate system within the last 10 years or so, this should take under a second. Indeed, the SHA1 hash string above was done on an AMD Athlon(tm) XP 1800+ with only 384 MB of PC133 RAM, and it was calculated in 940 milliseconds. The string, or in this case, our &#8220;Hashcash token&#8221; that generated that SHA1 hash is:</p>
<pre>1:20:110321:&#97;&#97;&#114;&#111;&#110;&#46;<u></u>&#116;<i></i>&#111;&#112;&#111;&#110;&#99;&#101;<b></b>&#64;<u></u>&#103;<u></u>&#109;&#97;&#105;<i></i>&#108;&#46;&#99;<i></i>&#111;&#109;<i></i>::Ci2v7/gsBbYY/dhk:0BTS</pre>
<p>You can verify this easily enough:</p>
<pre>echo -n 1:20:110321:&#97;&#97;&#114;&#111;&#110;&#46;<u></u>&#116;<i></i>&#111;&#112;&#111;&#110;&#99;&#101;<b></b>&#64;<u></u>&#103;<u></u>&#109;&#97;&#105;<i></i>&#108;&#46;&#99;<i></i>&#111;&#109;<i></i>::Ci2v7/gsBbYY/dhk:0BTS | sha1sum
00000528ba02c4da777839db269fde97de56ddf7  -</pre>
<p>So, if that is indeed a Hashcash token, then what are all the fields, and how are they used when searching for a SHA1 hash that starts with zeros? Well, the breakdown is thus:</p>
<ol>
<li>The version number.</li>
<li>The claimed bit value.</li>
<li>The date (and time) a stamp was minted.</li>
<li>The resource for which a stamp is minted.</li>
<li>Extensions that a specialized application may want.</li>
<li>A random salt.</li>
<li>The suffix.</li>
</ol>
<p>Hashcash has undergone two revisions thus far. The version number shows the claimed version of the protocol being used. With the latest release of Hashcash, this is &#8220;1&#8243;. &#8220;0&#8243; has shown to have some limitations.</p>
<p>The claimed bit value it telling the verifier of the token how many zeros the resulting SHA1 hash should have. The default is 20-bits, but this can be changed. If the bit value is too low, then it becomes trivial for spammers to reproduce with minimal effort. If the bit value is too high, it may take some considerable time for your CPU to mint the token.</p>
<p>The timestamp is the date when the token was minted. We can take advantage of this for expiry. When the verifier downloads the token, he can keep it in a database. This is useful to hopefully prevent someone else from claiming the same token. However, holding on to tokens indefinitely could be cumbersome, so we can set expiration dates on when the tokens expire, to help manage the database. The default expiration is 28 days.</p>
<p>The resource for which the token is minted is generally the email address of the recipients. However, it&#8217;s flexible enough to be anything. It could be a URL to a webpage, some string of text, or anything that uniquely identifies a certain resource. We&#8217;ll be using email addresses as our resource.</p>
<p>The fifth field is generally left blank, but the protocol specifies that this is used for extensions that any specialized application may want.</p>
<p>The salt is used just like it is used anywhere else. Here, we wish to make our token unique for our resource. The email address and timestamp might not be unique enough to prevent two minted tokens from being the same. So, we add a random, hopefully unique salt here to the token. Once the salt is chosen, just like the timestamp and the resource, it won&#8217;t change for that token. The real grunt work is done with the next field. But, the goal with the salt is to just eliminate the possibility that two people send me an email on the same day, and the minted token is the same. If each salt is randomly chosen, then the tokens will differ.</p>
<p>As stated, this last field is where the real grunt work of your CPU lies. Every previous field is statically set upon instantiation. It is only this field that changes until we find the SHA1 sum that produces the correct number of zeros that we&#8217;ve asked for. Fortunately, the suffix is sequential, starting at zero, and working it&#8217;s way up, base 64, until the appropriate suffix attached to this string gives us the SHA1 we want. As mentioned, if our bit size is 20 bits, by default, then we will only have to work our way through 2^20 possible suffixes, on average, to find the right string that gives us the SHA1 with 20 bits of leading zeros.</p>
<p>The security of the token comes from the fact that there should only be one collision for every 2^160 possible strings in SHA1. Let&#8217;s not get tied up in the cryptanalysis. Suffice it to say, that SHA1 is still holding well in cryptographic circles, and for all practical purposes, we are interested in the amount of work it takes for the CPU to find the right token. When SHA1 becomes broken, and cryptanalysis shows it&#8217;s no longer secure enough for today&#8217;s applications, Hashcash is flexible enough to move to a different cryptographic hashing algorithm by just changing the protocol version. In the meantime, SHA1 works.</p>
<p>Also, given today&#8217;s multicore CPUs, and Moore&#8217;s Law, 20 bits might not be enough work for the CPU to crunch through. Remember, the idea is to beat spammers at their own game. If they can produce mass valid tokens for each spam mail they send, then we should make sure that our bit strength is stronger. Right now, 20 bits seems to be strong enough, but maybe moving it to 24 or 28 bits in the future might be necessary. Just remember the amount of time it takes for your CPU to calculate the work needed for the token.</p>
<p><strong>How Hashcash works with email</strong></p>
<p>When the token is minted, we wish to add the token to our mail header. We can add a token for each recipient in the &#8220;To:&#8221; and &#8220;Cc:&#8221; lines (with special care on how the headers are modified with Bcc: recipients (generally solved by sending separate emails with individual tokens)). What is added to the mail header is the following:</p>
<pre>X-Hashcash: 1:20:110321:&#97;&#97;&#114;&#111;&#110;&#46;<u></u>&#116;<i></i>&#111;&#112;&#111;&#110;&#99;&#101;<b></b>&#64;<u></u>&#103;<u></u>&#109;&#97;&#105;<i></i>&#108;&#46;&#99;<i></i>&#111;&#109;<i></i>::Ci2v7/gsBbYY/dhk:0BTS</pre>
<p>For those using Hashcash, including antispam utilities such as SpamAssassin, looking for the X-Hashcash header in the mail, then verifying that the minted token is valid takes a fraction of a second. But, as we discussed earlier, minting the token takes some time. 20 bits for me takes just under a second. So, now imagine a SPAM ring with control of thousands of zombie computers infected with trojans. There are only 86400 seconds in a day, so if it takes one second to mint a valid token, then a single computer could only send out at most 86400 mails in a day, a far cry from the millions it wishes to send out. So, while it doesn&#8217;t completely eliminate the zombie nets from sending mass emails, it does slow them down considerably.</p>
<p>Yet, for those of us who only send a couple dozen mails per day, it&#8217;s trivial for our CPU to do the work, and doesn&#8217;t slow us down any. Further, those receiving our messages can verify the token is valid in a fraction of the time it took to mint it. As the receiver, you set the price of the token you wish to validate as antispam. Again, 20 bits seems sufficient enough for today, but 24 or 28 bits might need to be your standard in the future.</p>
<p>For those of you who are not using Hashcash, you can simply ignore the header, and move on with your life. It won&#8217;t slow your mail experience down any, and shouldn&#8217;t get in the way of reading or replying to it.</p>
<p><strong>Mutt Configuration</strong></p>
<p>Now that we have a decent understanding of how the Hashcash protocol works, let&#8217;s see how we set this up with Mutt. Thankfully, this is rather straight forward. All you need to add to your ~/.muttrc is:</p>
<pre>set edit_headers="yes"                 # required
set editor="/path/to/mint_hashcash.py" # required
set askcc="yes"                        # recommended, but not required</pre>
<p>This will allow you to edit the mail headers when composing your message with the editor of your choice. The editor is chosen for you in the Python script. I use Vim, so it&#8217;s hardcoded to that. Feel free to change it to your preferred editor of choice. I should also mention at this point that I have only found a way to automate minting tokens with Mutt. I haven&#8217;t found a way yet, although I&#8217;m working on it, to automate the process of verifying tokens, and storing tokens in a database, with Mutt. Hopefully, a followup post can come to fruition when I figure it out (after all, what&#8217;s the point of minting tokens if you can&#8217;t verify others&#8217; tokens yourself?).</p>
<p>The script is here:</p>
<div class="codecolorer-container python twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br />37<br />38<br />39<br />40<br />41<br />42<br />43<br />44<br />45<br />46<br />47<br />48<br />49<br />50<br />51<br />52<br />53<br />54<br />55<br /></div></td><td><div class="python codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #808080; font-style: italic;">#!/usr/bin/env python</span><br />
<span style="color: #808080; font-style: italic;"># Licensed under the public domain</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">fileinput</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">rfc822</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span><br />
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span><br />
<br />
<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">call</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;vim %s&quot;</span> % <span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> shell<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #008000;">file</span> <span style="color: #66cc66;">=</span> <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> <span style="color: #483d8b;">'r'</span><span style="color: black;">&#41;</span><br />
headers <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">rfc822</span>.<span style="color: black;">Message</span><span style="color: black;">&#40;</span><span style="color: #008000;">file</span><span style="color: black;">&#41;</span><br />
<br />
to_emails <span style="color: #66cc66;">=</span> headers.<span style="color: black;">getaddrlist</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;To&quot;</span><span style="color: black;">&#41;</span><br />
cc_emails <span style="color: #66cc66;">=</span> headers.<span style="color: black;">getaddrlist</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Cc&quot;</span><span style="color: black;">&#41;</span><br />
<br />
email_addrs <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
tokens <span style="color: #66cc66;">=</span> <span style="color: black;">&#91;</span><span style="color: black;">&#93;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Harvest all email addresses from the header</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">email</span> <span style="color: #ff7700;font-weight:bold;">in</span> to_emails:<br />
&nbsp; &nbsp; email_addrs.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">email</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">email</span> <span style="color: #ff7700;font-weight:bold;">in</span> cc_emails:<br />
&nbsp; &nbsp; email_addrs.<span style="color: black;">append</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">email</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Remove duplicate emails from the list, requires Python 2.5 and later</span><br />
email_addrs <span style="color: #66cc66;">=</span> <span style="color: #008000;">list</span><span style="color: black;">&#40;</span><span style="color: #008000;">set</span><span style="color: black;">&#40;</span>email_addrs<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Check if an appropriate token is already generated for the mail</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> headers.<span style="color: black;">has_key</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;X-Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">list</span> <span style="color: #ff7700;font-weight:bold;">in</span> headers.<span style="color: black;">getheaders</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;X-Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; email_addrs.<span style="color: black;">remove</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">if</span> headers.<span style="color: black;">has_key</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #008000;">list</span> <span style="color: #ff7700;font-weight:bold;">in</span> headers.<span style="color: black;">getheaders</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;Hashcash&quot;</span><span style="color: black;">&#41;</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; email_addrs.<span style="color: black;">remove</span><span style="color: black;">&#40;</span><span style="color: #008000;">list</span>.<span style="color: black;">split</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;:&quot;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">3</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Call the hashcash function from the operating system to mint tokens</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">email</span> <span style="color: #ff7700;font-weight:bold;">in</span> email_addrs:<br />
&nbsp; &nbsp; t <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;hashcash -m %s -X -Z 2&quot;</span> % <span style="color: #dc143c;">email</span><span style="color: #66cc66;">,</span> shell<span style="color: #66cc66;">=</span><span style="color: #008000;">True</span><span style="color: #66cc66;">,</span> stdout<span style="color: #66cc66;">=</span><span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; tokens.<span style="color: black;">append</span><span style="color: black;">&#40;</span>t.<span style="color: black;">stdout</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#41;</span><br />
<br />
<span style="color: #808080; font-style: italic;"># Write the newly minted tokens to the header</span><br />
f <span style="color: #66cc66;">=</span> <span style="color: #dc143c;">fileinput</span>.<span style="color: black;">FileInput</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span><span style="color: #66cc66;">,</span> inplace<span style="color: #66cc66;">=</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span><br />
<span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> f:<br />
&nbsp; &nbsp; line <span style="color: #66cc66;">=</span> line.<span style="color: black;">strip</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">if</span> f.<span style="color: black;">lineno</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span> <span style="color: #66cc66;">==</span> <span style="color: #ff4500;">1</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">for</span> <span style="color: #dc143c;">token</span> <span style="color: #ff7700;font-weight:bold;">in</span> tokens:<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #dc143c;">token</span><span style="color: #66cc66;">,</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> line<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">continue</span><br />
&nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">else</span>:<br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #ff7700;font-weight:bold;">print</span> line<br />
<br />
<span style="color: #008000;">file</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span></div></td></tr></tbody></table></div>
<p>The code is fairly straight forward. Parse the email headers using RFC 822, grab the necessary email addresses, and mint the tokens as necessary. You&#8217;ll quickly note that &#8220;Bcc:&#8221; addresses aren&#8217;t supported, as minting tokens for those addresses would give them away in the header. I could send separate emails for each Bcc recipient, putting their own token in the header, but I&#8217;m not motivated enough to write that code, and I rarely, if ever, use blind carbon copy.</p>
<p>I&#8217;ve been running the above code now for 2-3 days, trying to break it as best I can, and I haven&#8217;t come across anything. If you do notice a bug, or something sloppy in the code, let me know, and I&#8217;ll make a best attempt at addressing it. However, it seems to be working quite well. The only thing I would mention, is if you have a lot of emails in the &#8220;To:&#8221; or &#8220;Cc:&#8221; fields, it may take some time to mint all those tokens. Just let it do its thing. It will get you back to Mutt. I promise.</p>
<p> <img src='http://pthree.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/03/24/hashcash-and-mutt/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Bitlbee and OTR</title>
		<link>http://pthree.org/2011/03/08/bitlbee-and-otr/</link>
		<comments>http://pthree.org/2011/03/08/bitlbee-and-otr/#comments</comments>
		<pubDate>Tue, 08 Mar 2011 23:27:18 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1778</guid>
		<description><![CDATA[I&#8217;m actually surprised that I haven&#8217;t blogged about this before, seeing as though I use it daily. Further, seeing as though I seem to be on a security blogging trip, it only seems fitting to discuss OTR support in Bitlbee now. OTR, or Off-The-Record messaging is the ability to have encrypted and authenticated communication with [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m actually surprised that I haven&#8217;t blogged about this before, seeing as though I use it daily. Further, seeing as though I seem to be on a security blogging trip, it only seems fitting to discuss OTR support in Bitlbee now.</p>
<p>OTR, or <a href="http://en.wikipedia.org/wiki/Off-the-Record_Messaging">Off-The-Record messaging</a> is the ability to have encrypted and authenticated communication with full deniability and perfect forward secrecy. The idea is simple. Just as you want to be able to deny anything you say to a journalist when &#8220;off-the-record&#8221;, you should be able to have that ability with instant messaging. It works by not cryptographically signing the message. It&#8217;s just encrypted, and your buddy decrypts it on the other end. Further, each message is encrypted with a one-time AES session key. This means that even if you successfully snatch the AES key for encrypting and decrypting the message, it only applies to the current message, and does nothing for the previous messages, nor does it do anything for you on future messages. Thus, you have perfect forward secrecy with your chat. However, I want to spend some time on the inner workings of how authentication and trust are established, if the messages aren&#8217;t signed for validation.</p>
<p>First, OTR is fully supported in <a href="http://bitlbee.org">Bitlbee</a> version 3.0 and later. For Debian and Ubuntu packages, you will need to install both the &#8220;bitlbee&#8221; and &#8220;bitlbee-plugin-otr&#8221; packages if you want to take advantage of it. Of course, you could grab the source, and compile it in yourself as well. Once installed, you will want to generate master keys for each account you wish to use OTR with. You can get a list of your accounts with &#8220;account list&#8221; in the &#038;bitlbee window of your IRC client:</p>
<pre>15:20 &lt;@aaron&gt; account list
15:20 &lt;@root&gt;  0 (gmail): jabber, &#97;&#97;<u></u>&#114;<u></u>&#111;&#110;&#46;&#116;&#111;&#112;&#111;&#110;&#99;&#101;<b></b><i></i>&#64;<i></i>&#103;<b></b>&#109;&#97;&#105;<u></u>&#108;&#46;&#99;<i></i>&#111;<i></i>&#109; (connected)
15:20 &lt;@root&gt;  1 (twitter): twitter, aarontoponce (connected)
15:20 &lt;@root&gt;  2 (identica): twitter, eightyeight
15:20 &lt;@root&gt; End of account list</pre>
<p>I wish to use OTR with my Gmail account. Thus, I need a key for the account. You can run &#8220;otr keygen &lt;account-no&gt;&#8221; for this:</p>
<pre>otr keygen 0</pre>
<p>It will take some time to generate the key, as it grabs entropy from /dev/random. You may want to add more entropy to the pool by running &#8220;du -sh /&#8221; from a different terminal to help speed things up. Wiggle the mouse, type in text editors, do other things to generate environmental noise. After it&#8217;s finished, you can see the key fingerprint by running &#8220;otr info&#8221;:</p>
<pre>15:28 &lt;@aaron&gt; otr info
15:28 &lt;@root&gt; private keys:
15:28 &lt;@root&gt;   &#97;&#97;<u></u>&#114;<u></u>&#111;&#110;&#46;&#116;&#111;&#112;&#111;&#110;&#99;&#101;<b></b><i></i>&#64;<i></i>&#103;<b></b>&#109;&#97;&#105;<u></u>&#108;&#46;&#99;<i></i>&#111;<i></i>&#109;/jabber - DSA
15:28 &lt;@root&gt;     8D57F662 D991493F 1084427E 31C7E1B9 2074B713
15:28 &lt;@root&gt;
15:28 &lt;@root&gt; connection contexts: (bold=currently encrypted)
15:28 &lt;@root&gt;   (none)</pre>
<p>Now, you&#8217;re ready to communicate with your buddies via OTR. The question that will likely come up now is how do you know if the person you wish to communicate with secretly is really the person you expect? Well, for the years that I&#8217;ve used OTR, I&#8217;ve trusted the individual implicitly. I&#8217;ve communicated with their account enough that when we both decide to &#8220;go secure&#8221; with our chats, that it&#8217;s no big deal. I just trust their keys, they trust mine, and we go about our day. However, you may not want to do that, but want to explicitly acknowledge that you are communicating with who you think.</p>
<p>This can be solved a number of ways:</p>
<ol>
<li>You could call them on the phone, and verify fingerprints verbally.</li>
<li>You could agree on a shared secret before initiating the communication electronically, and use that shared secret to trust the keys.</li>
<li>You could issue a challenge/response question to the opposite party. If they answer correctly, trust the key.</li>
</ol>
<p>Personally, I like the challenge and response system. It&#8217;s not too terrible difficult to think of a question that only your buddy would know, and issue the challenge for them to respond. Of course, they need to do the same with you. This is known as the <a href="http://en.wikipedia.org/wiki/Socialist_millionaire">Socialist Millionaire Protocol</a>. Use &#8220;otr smpq &lt;nick&gt; &lt;question&gt; &lt;answer&gt;&#8221;. It could go something like this:</p>
<pre>otr smpq foobar "What color pen did I use on your whiteboard yesterday? one word, lowercase" red
15:35 &lt;@root&gt; smp: initiating with foobar...</pre>
<p>On the other end, the nick &#8220;foobar&#8221; would have seen this:</p>
<pre>06:42 &lt;@root&gt; smp: initiated by aaron with question: "What color ped did I use on your whiteboard yesterday? one word, lowercase"
06:42 &lt;@root&gt; smp: respond with otr smp aaron &lt;answer&gt;</pre>
<p>At this point, &#8220;foobar&#8221; wishes to respond, as he thinks he knows the question. He would use &#8220;otr smp &lt;nick&gt; &lt;answer&gt;&#8221;:</p>
<pre>otr smp aaron red
06:43 &lt;@root&gt; smp: responding to aaron...
06:43 &lt;@root&gt; smp aaron: correct answer, you are trusted</pre>
<p>At this point, I now trust that foobar is who he says he is, so I can trust any OTR communication from him. However, he hasn&#8217;t verified that I am who he thinks I is. After all, I could be someone pretending to be Aaron, and get sensitive information from him. So, he should issue the same challenge and response to me. Something that only Aaron would know, to thwart any potential baddies. Should I answer correctly, he can then trust my fingerprint, and we will have 2-way OTR communication.</p>
<p>When everything is said and done, Bitlbee will print out the following:</p>
<pre>15:36 &lt;@root&gt; smp foobar: secrets proved equal, fingerprint trusted</pre>
<p>You can also verify it with &#8220;otr info &lt;nick&gt;&#8221;:</p>
<pre>15:37 &lt;@aaron&gt; otr info copecd
15:37 &lt;@root&gt; foobar is foobar@gmail.com/jabber; we are &#97;&#97;<u></u>&#114;<u></u>&#111;&#110;&#46;&#116;&#111;&#112;&#111;&#110;&#99;&#101;<b></b><i></i>&#64;<i></i>&#103;<b></b>&#109;&#97;&#105;<u></u>&#108;&#46;&#99;<i></i>&#111;<i></i>&#109;/jabber to them
15:37 &lt;@root&gt;   otr offer status: none sent
15:37 &lt;@root&gt;   connection state: cleartext
15:37 &lt;@root&gt;   fingerprints: (bold=active)
15:37 &lt;@root&gt;     13C45179 F2A8645B 466463E8 228DBE16 787D1A82 (affirmed)</pre>
<p>As already mentioned, there are other ways for verifying that the person on the other end is who they say they are, and OTR in Bitlbee supports it. You will notice too, that once the fingerprints have been trusted on both sides, the text is green in the chat window. If not trusted, the text is red. As far as I know, there is no way to change the color, or have any other sort of visual clue on whether or not trusted encryption is taking place in the communication.</p>
<p>Also, is should be worthy to note that Bitlbee OTR only supports conversations through Bitlbee, not your IRC client. This means that if you are using Irssi, Weechat, or some other IRC client, Bitlbee OTR won&#8217;t help you for IRC messages. You&#8217;ll need an OTR plugin for that as well. This is definitely a drawback. For example, if you use Irssi like I do, there is an <a href="http://irssi-otr.tuxfamily.org/">OTR plugin for Irssi</a>. Not only will it handle IRC, but any message through IRC, including those of Bitlbee. However, the Irssi OTR plugin hasn&#8217;t been updated in two years, and it has security holes that haven&#8217;t been addressed. The Bitlbee OTR plugin is up-to-date and in my opinion, much more streamlined. I don&#8217;t use private IRC messages much, so the Bitlbee OTR plugin works just fine for me.</p>
<p>Now, start using OTR with Bitlbee. If you love your Bitlbee as much as I do, you will. <img src='http://pthree.org/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/03/08/bitlbee-and-otr/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Elliptic Curve Cryptography in OpenSSH</title>
		<link>http://pthree.org/2011/02/17/elliptic-curve-cryptography-in-openssh/</link>
		<comments>http://pthree.org/2011/02/17/elliptic-curve-cryptography-in-openssh/#comments</comments>
		<pubDate>Fri, 18 Feb 2011 03:54:29 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1700</guid>
		<description><![CDATA[I&#8217;ve been meaning to add this as a post, as it&#8217;s light and quick, but as the release of OpenSSH 5.7, Elliptic Curve Cryptography has been implemented. Why should you care? The generated keys are substantially smaller, the algorithm is faster and lighter, giving a break to slower CPUs and the cryptanalysis hasn&#8217;t shown any [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been meaning to add this as a post, as it&#8217;s light and quick, but as the release of OpenSSH 5.7, <a href="http://en.wikipedia.org/wiki/Elliptic_curve_cryptography">Elliptic Curve Cryptography</a> has been implemented. Why should you care? The generated keys are substantially smaller, the algorithm is faster and lighter, giving a break to slower CPUs and the cryptanalysis hasn&#8217;t shown any substantial weaknesses, unlike traditional RSA or DSA.</p>
<p>To generate an ECC SSH key for your host, you need to use the &#8220;<a href="http://en.wikipedia.org/wiki/ECDSA">ecdsa</a>&#8221; encryption type. The bit strengths are 256, 384 and 521. Generally speaking, the equivalent DSA keys would require 4-times the bit strength of ECDSA keys. In other words, a 256-bit ECDSA key is equivalent in strength to a 1024-bit DSA key.</p>
<p>Pull up your terminal, and type:</p>
<pre>% ssh-keygen -t ecdsa -b 256</pre>
<p>Go through the prompts, and you should have your generated private and public keys. Then, copy the key over to your remote server, and start using:</p>
<pre>% ssh-copy-id -i ~/.ssh/id_ecdsa.pub user@server.tld</pre>
<p>Of course, the remote server does need to support ECC in order to take advantage of ECDSA keys, which means it too needs to be running OpenSSH 5.7 or later. Here&#8217;s a result of the key sizes:</p>
<pre>% ls -l ~/.ssh/*.pub
-rw-r--r-- 1 aaron aaron 604 Feb 17 20:05 id_dsa.1024.pub
-rw-r--r-- 1 aaron aaron 176 Feb 17 19:41 id_ecdsa.256.pub
-rw-r--r-- 1 aaron aaron 220 Feb 17 19:42 id_ecdsa.384.pub
-rw-r--r-- 1 aaron aaron 268 Feb 17 19:42 id_ecdsa.521.pub
-rw-r--r-- 1 aaron aaron 228 Feb 17 20:07 id_rsa.1024.pub
-rw-r--r-- 1 aaron aaron 398 Feb 17 20:08 id_rsa.2048.pub</pre>
<p>As you can clearly see, ECDSA keys are substantially smaller compared to their DSA counterparts and a bit smaller than equivalent RSA keys. Also, it should be mentioned that when setting up the OpenSSH server on a new host for the first time, you can also choose to have ECDSA host keys generated for the server, rather than the standard RSA or DSA keys.</p>
<p>I don&#8217;t recommend wiping your existing RSA or DSA keys in favor of ECDSA quite yet. Plenty of OpenSSH and proprietary SSH servers exist that do not support ECC. Thus, your newly generated ECDSA key won&#8217;t work, even if you copy it to the authorized_keys file. However, if you have the servers that support it, then why not give it a go, and see what you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2011/02/17/elliptic-curve-cryptography-in-openssh/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>GnuPG Up And Close</title>
		<link>http://pthree.org/2009/06/08/gnupg-up-and-close/</link>
		<comments>http://pthree.org/2009/06/08/gnupg-up-and-close/#comments</comments>
		<pubDate>Tue, 09 Jun 2009 06:09:15 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=1069</guid>
		<description><![CDATA[Every GNU/Linux distribution ships with GnuPG by default. While they all don&#8217;t ship with the same GUI frontend, they do ship with the the same CLI backend. So, we&#8217;ll be interfacing with that throughout this informational session. I&#8217;m not presenting this as anything necessarily useful. Rather, I hope you find it informational/educational, and learn a [...]]]></description>
			<content:encoded><![CDATA[<p>Every GNU/Linux distribution ships with GnuPG by default. While they all don&#8217;t ship with the same GUI frontend, they do ship with the the same CLI backend. So, we&#8217;ll be interfacing with that throughout this informational session. I&#8217;m not presenting this as anything necessarily useful. Rather, I hope you find it informational/educational, and learn a little bit with how GnuPG works &#8220;under the hood&#8221;. So, let&#8217;s have some fun. First, a list of the &#8220;standard&#8221; algorithms that ship with GnuPG on a GNU/Linux system. This is completely based on the type of main public and private keys as well as any subkeys that you&#8217;ve generated. You can see a list of supported cipher, digest and compression algorithms by invoking the gpg binary and passing &#8220;&#8211;version&#8221; as an option. For example, here is the output from my Debian GNU/Linux unstable laptop:</p>
<pre>$ gpg -v --version
gpg (GnuPG) 1.4.9
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
Cipher: 3DES (S2), CAST5 (S3), BLOWFISH (S4), AES (S7), AES192 (S8),
        AES256 (S9), TWOFISH (S10)
Hash: MD5 (H1), SHA1 (H2), RIPEMD160 (H3), SHA256 (H8), SHA384 (H9),
      SHA512 (H10), SHA224 (H11)
Compression: Uncompressed (Z0), ZIP (Z1), ZLIB (Z2), BZIP2 (Z3)</pre>
<p>So, for ciphers, I support 3DES, CAST5, BLOWFISH, AES, AES192, AES256 and BLOWFISH. For digest hashes, I support MD5, SHA1, RIPEMD160, SHA224, SHA256, SHA384 and SHA512. Lastly, for compression algorithms, I support uncompressed, ZIP, ZLIB and BZIP2. Your output my vary slightly one way or the other. For example, you may not see the full suite of SHA algorithms. This can be obtained by generating an RSA subkey for signing only. Other ciphers might include IDEA, CAMELLIA128, CAMELLIA192 and CAMELLIA256, and you could have TIGER and WHIRLPOOL as possible supported hashes.</p>
<p>With all these algorithms, how do you know which to use and when? Fortunately, GnuPG takes care of that for you automatically. However, you can tell it what you would to prefer to use for each, if you like. You can set these in your ~/.gnupg/gpg.conf file. The options you are looking to set are &#8220;default-preference-list&#8221;, &#8220;personal-cipher-preferences&#8221;, &#8220;personal-digest-preferences&#8221; and &#8220;personal-compress-preferences&#8221;. For myself, here is what I have set in my gpg.conf:</p>
<pre>default-preference-list 3DES CAST5 BLOWFISH AES AES192 AES256 TWOFISH MD5 SHA1 RIPEMD160 SHA224 SHA256 SHA384 SHA512 Uncompressed ZIP ZLIB BZIP2
personal-cipher-preferences TWOFISH AES256 AES192 AES BLOWFISH CAST5 3DES
personal-digest-preferences SHA512 SHA384 SHA256 SHA224 SHA1 RIPEMD160 MD5
personal-compress-preferences BZIP2 ZLIB ZIP Uncompressed</pre>
<p>Now, when we printed out the verbose version, we saw in parenthesis S2, S3, H8, H9, Z1, Z2 and so on. We can use these instead of the name in our gpg.conf if we so wish. I prefer the name, as I can&#8217;t recall the key to the algorithm, and it&#8217;s easier to read. So, in my case, I list out everything that I want for a default list of preferences, then I choose the order of which to pick from when encrypting, signing and compressing. So, for encryption, I have set TWOFISH as my first choice, with AES256 as my second choice, then AES192 as my third, and so forth. I&#8217;ve done the same with my preferred digest hashing algorithm choosing SHA512 first, then SHA384 second, and so on, and the same with compression.</p>
<p>Why set the preference? For starters, if you&#8217;re like me, you sign all your email by default. You probably want your signature to withstand the test of time as long as possible. Given the strength of today&#8217;s hardware, why not choose the strongest encryption and hash algorithms? But on a more practical note, if you&#8217;re encrypting data to yourself, this would tell GnuPG to use TWOFISH as the encryption algorithm. This means that if you want to decrypt it at a later date, maybe on another computer, you&#8217;ll need to make sure TWOFISH is compiled into GnuPG. How would you know what was used? We&#8217;ll cover that in a bit.</p>
<p>However, what about encrypting to someone else other than yourself? How do these preferences come into play? Well, you can also set preferences in your public key. The purpose of this, is when people grab a copy of your key, and they want to encrypt something to you, GnuPG will negotiate the first preferred algorithm that is common between the two end points (the one doing the encrypting and the one receiving the encrypted data).</p>
<p>For example, let&#8217;s suppose Alice has a GnuPG keypair as does Bob. In Alice&#8217;s public key, which Bob has a legitimate copy of, she has set a cipher preference order of: TWOFISH BLOWFISH AES CAST5 and 3DES. Bob wants to encrypt data to Alice. Because he has a copy of her public key, he can do this. The question here is, which algorithm will be chosen for the encryption? Well, Alice prefers TWOFISH as a first pick. If Bob has compiled TWOFISH support in his copy of GnuPG, then it will be used. Suppose he doesn&#8217;t have TWOFISH support. Then the next preferred algorithm is BLOWFISH, because it&#8217;s Alice&#8217;s second pick. Let&#8217;s say Bob does support it, then BLOWFISH is the algorithm used for encrypting the data to Alice. When Alice receives the encrypted data, she&#8217;ll use the BLOWFISH algorithm along with her private key to decrypt the data. Should she wish to reply, her copy of GnuPG will pull out the preferences from Bob&#8217;s public key, and go through the same process looking for the first preferred algorithm by Bob that is supported by both parties. The &#8220;SSL handshake&#8221; works much in this same manner.</p>
<p>Digest hashing works much the same way, but slightly different. Because the recipient doesn&#8217;t matter with signed data, then rather than looking to public keys for the digest algorithm preference, you turn to your gpg.conf file, if listed, and use that there. If the recipient, or recipients have a copy of your public key, <em>and</em> the same digest algorithm compiled into their copy of GnuPG, they can verify your signature. If either is missing, the public key, or the algorithm, the signature will fail, and GnuPG will explain the problem. This process is the same for compression algorithms.</p>
<p>So, we&#8217;ve made the preferences in our gpg.conf, but how do we set them in the public key, so we can distribute this to others? Well, in this case, we need to edit our key. From the terminal (I&#8217;ve snipped out the noise, focusing only on what&#8217;s important):</p>
<pre>$ gpg --edit-key KEYID
gpg (GnuPG) 1.4.9; Copyright (C) 2008 Free Software Foundation, Inc.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Secret key is available.
[ ... SNIP ... ]

Command&gt;</pre>
<p>We are now sitting at a command prompt that we can use to pass commands in an interactive fashion. I should mention that all this can be done non-interactively. Checking out the gpg manual will provide the list of options for making this possible. Typing &#8220;help&#8221; will give us the list of commands that we can pass:</p>
<pre>Command&gt; help
[... SNIP ...]
pref        list preferences (expert)
showpref    list preferences (verbose)
setpref     set preference list for the selected user IDs
[... SNIP ...]</pre>
<p>The commands that we are interested in &#8220;pref&#8221; and &#8220;setpref&#8221;. Passing &#8220;pref&#8221; might give us something like the following:</p>
<pre>Command&gt; pref
[ultimate] (1). Aaron &lt;aaron@example.com&gt;
     S10 S9 S8 S7 S4 S3 S2 H10 H9 H8 H11 H2 H3 H1 Z3 Z2 Z1 Z0 [mdc] [no-ks-modify]</pre>
<p>See those algorithm codes we saw at the beginning of this tutorial? They are listed in the preferred order that we wish to have each algorithm. In my case, I have all my encryption algorithms lists, from strong to weak, then hashing from strong to weak, then compression from most tight to no compression. What if I wanted to set a different order, or maybe not include some preferences: Using &#8220;setpref&#8221; makes this possible:</p>
<pre>Command> setpref S10 S9 S8 S7 H10 H9 H8 H2 H3 Z2 Z1 Z3 Z0
Set preference list to:
     Cipher: TWOFISH, AES256, AES192, AES, 3DES
     Digest: SHA512, SHA384, SHA256, SHA1, RIPEMD160
     Compression: ZLIB, ZIP, BZIP2, Uncompressed
     Features: MDC, Keyserver no-modify
Really update the preferences? (y/N)</pre>
<p>Typing &#8220;y&#8221; will of course make the setting in your key. At this point, you&#8217;ll be asked to enter your private key passphrase successfully before continuing. At that point, it will be statically set in your public key, and you can send your key off to the keyservers and emailed to your family and friends, so they can immediately start taking advantage of the new preferences. Type &#8220;quit&#8221; to leave the prompt.</p>
<p>Now, let&#8217;s say you have some signed and encrypted data, and you&#8217;re curious of the algorithms used when creating the cipher text. This can be done by passing the &#8220;&#8211;list-packets&#8221; option to gpg to see the data packets. We&#8217;ll need to turn on verbosity as well. For example, the output of a file I sent to a friend using the Mutt email client (emphasis mine):</p>
<pre>gpg -v --list-packets file.txt
gpg: armor header: Version: GnuPG v2.0.11 (GNU/Linux)
[... SNIP ...]
<b>gpg: AES256 encrypted data</b>
<b>:compressed packet: algo=3</b>
<b>&#58;onepass_sig packet</b>: keyid CE7911B7FC04088F
	version 3, sigclass 0x01, <b>digest 8</b>, pubkey 1, last=1
:literal data packet:
	mode t (74), created 1244484492, name="mutt-helios-1000-24974-13",
	raw data: unknown length
</pre>
<p>Here, I can easily see that AES256 was used for the encryption algorithm, but what&#8217;s this compressed &#8220;algo=3&#8243; and &#8220;onepass_sig packet digest 8&#8243; stuff? Well, in order to understand those, we need to turn to <a href="http://www.faqs.org/rfcs/rfc4880.html">RFC 4880</a>. This RFC describes the OpenPGP message format and the standards used. Browse your way down to section 9, and you&#8217;ll see what &#8220;algo=3&#8243; means for compression and &#8220;digest 8&#8243; is for signatures. It appears, according to that RFC, that BZIP2 was used for compression and SHA256 was used for the hashing algorithm. So, in this case, Christer and myself preferred those settings higher than the others, and my GnuPG acknowledged those preferences and did the encrypting, signing and compressing as told. We can see these by &#8220;editing&#8221; his key:</p>
<pre>$ gpg --edit-key christer
[... SNIP ...]
Command&gt; pref
[  full  ] (1). Christer &lt;christer@example.com&gt;
     S9 S8 S7 S3 S2 H2 H8 H3 Z2 Z3 Z1 [mdc] [no-ks-modify]
[... SNIP ...]

Command&gt; quit</pre>
<p>Christer places AES256 has his first preferred encryption algorithm. Because I also support this algorithm, this is used for the encryption. SHA1 is his preferred digest hashing algorithm with SHA256 as his second preferred, but remember that for the signature and compression, these preferences are found in my gpg.conf instead. I prefer SHA512 as my first preference, but he doesn&#8217;t list it as suported (according to his public key), so I move down to SHA384. Again, he doesn&#8217;t list it, so I try SHA256. He lists it, so it&#8217;s used. Lastly, BZIP2 as the compression algorithm, and he lists it, thus it&#8217;s chosen. Thus, the results we got. Make sense?</p>
<p>I hope this has been informative. It&#8217;s been great discovering the details of how these algorithms were chosen, and it&#8217;s been fun playing with all sorts of encrypted emails and files to get to the guts of the GunPG process. If I&#8217;ve misrepresented any data here, or you have questions, please let me know.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2009/06/08/gnupg-up-and-close/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Using GnuPGv2</title>
		<link>http://pthree.org/2008/08/12/using-gnupgv2/</link>
		<comments>http://pthree.org/2008/08/12/using-gnupgv2/#comments</comments>
		<pubDate>Tue, 12 Aug 2008 16:15:54 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=660</guid>
		<description><![CDATA[I&#8217;ve moved to GnuPG version 2, mainly just out of curiosity. I have read the feature list between version 1 and 2. Apparently, version 2 supports the same algorithms, completely backwards-compatible with version 1, more modular and supports additional functionality. So, with that, my GPG key has been re-exported using version 2. It&#8217;s available on [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve moved to GnuPG version 2, mainly just out of curiosity.  I have read the feature list between version 1 and 2.  Apparently, version 2 supports the same algorithms, completely backwards-compatible with version 1, more modular and supports additional functionality.  So, with that, my GPG key has been re-exported using version 2.  <a href="http://aarontoponce.org/aaron.asc">It&#8217;s available on my personal site</a>.  Feel free to update as needed.  The most current version of my public key will always be found there.  Further, all my email will be signed with version 2.  If this causes any problems with verifying my emails, please let me know.</p>
<p>GnuPG version 2 is available in the Ubuntu repositories.  Pull up a terminal, and type:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">aptitude</span> <span style="color: #c20cb9; font-weight: bold;">install</span> gnupg2</div></td></tr></tbody></table></div>
<p>If you want to make version 2 the default for all applications, including Seahorse, KGPG, GPA, Enigmail, and others, then we just need to backup our currently installed binary, and create a symbolic link pointing to version 2:</p>
<div class="codecolorer-container bash twitlight" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br /></div></td><td><div class="bash codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap"><span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpg <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpg.back<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">mv</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpgv <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpgv.back<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpg2 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpg<br />
<span style="color: #c20cb9; font-weight: bold;">sudo</span> <span style="color: #c20cb9; font-weight: bold;">ln</span> <span style="color: #660033;">-s</span> <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpgv2 <span style="color: #000000; font-weight: bold;">/</span>usr<span style="color: #000000; font-weight: bold;">/</span>bin<span style="color: #000000; font-weight: bold;">/</span>gpgv</div></td></tr></tbody></table></div>
<p>If there is a better way to do this with your ~/.gnupg/gpg.conf file, I would be very interested.  The above seems &#8220;hack-ish&#8221; to me.  Removing the &#8216;gnupg&#8217; package from Ubuntu also breaks many, many packages, so that doesn&#8217;t seem to be a sane option.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2008/08/12/using-gnupgv2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Update My Public Key</title>
		<link>http://pthree.org/2008/01/22/update-my-public-key/</link>
		<comments>http://pthree.org/2008/01/22/update-my-public-key/#comments</comments>
		<pubDate>Wed, 23 Jan 2008 00:13:57 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>

		<guid isPermaLink="false">http://pthree.org/?p=539</guid>
		<description><![CDATA[At your earliest convenience, you&#8217;ll need to update my public key in your keyring. You can grab the cleaned copy from my site, or your can get an uncleaned copy from either the Ubuntu keyserver or the PGP keyserver. Please do not use the MIT PGP keyserver, until I can get straightened out why they [...]]]></description>
			<content:encoded><![CDATA[<p>At your earliest convenience, you&#8217;ll need to update my public key in your keyring.  You can grab the <a href="http://aarontoponce.org/aaron.asc">cleaned copy from my site</a>, or your can get an uncleaned copy from either the <a href="http://keyserver.ubuntu.com:11371/pks/lookup?search=0x8086060F&#038;op=vindex">Ubuntu keyserver</a> or the <a href="http://subkeys.pgp.net:11371/pks/lookup?search=0x8086060F&#038;fingerprint=on&#038;op=index">PGP keyserver</a>.  Please do not use the MIT PGP keyserver, until I can get straightened out why they won&#8217;t accept my public key (I think it is more involved than just lack of support for photo IDs in keys).</p>
<p>The update is necessary to keep you from encrypting data to me using an algorithm that is not supported by GnuPG.  At a previous job, I needed support for the IDEA algorithm, found in PGP2, so I imported that library into GPG and added support for it in my key.  As I no longer need support for that patented algorithm, I&#8217;ve removed the preference from my key, which will affect the public key that you have.</p>
<p>If you have any errors encrypting data to me, or verifying my digital signature, please email me the error, along with a screenshot, so I can troubleshoot the issue.  I believe I may have a few more cockroaches lying around, such as the IDEA algorithm.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2008/01/22/update-my-public-key/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>MIT PGP Keyserver</title>
		<link>http://pthree.org/2008/01/05/mit-pgp-keyserver/</link>
		<comments>http://pthree.org/2008/01/05/mit-pgp-keyserver/#comments</comments>
		<pubDate>Sat, 05 Jan 2008 19:53:22 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>

		<guid isPermaLink="false">http://www.pthree.org/2008/01/05/mit-pgp-keyserver/</guid>
		<description><![CDATA[I just discovered, after spending some time trying to get my public key uploaded to the MIT PGP keyserver that they do not support photos in public keys. I find this rather unfortunate, as photos add a level of security to the key. This also means that any IDs that I add to my key [...]]]></description>
			<content:encoded><![CDATA[<p>I just discovered, after spending some time trying to get my public key uploaded to the <a href="http://pgp.mit.edu">MIT PGP keyserver</a> that they do not support photos in public keys.  I find this rather unfortunate, as photos add a level of security to the key.  This also means that any IDs that I add to my key after adding the photo will also not be updated on their server.  It seems that MIT has no plans on implementing support for photos in public keys, and I have no plans on removing the photo from my key, so that places MIT and I at an impasse.  Fortunately, the <a href="http://keyserver.ubuntu.com:11371">Ubuntu PGP keyserver</a> does support photos, so as such, if grabbing my key, you will always find the <a href="http://keyserver.ubuntu.com:11371/pks/lookup?op=get&#038;search=0x22EEE0488086060F">latest version there</a>, as well as <a href="http://aarontoponce.org/aaron.asc">under my domain here</a>.  Just FYI, in case anyone else was having issues uploading their public key to the MIT server, and received an &#8220;Error decoding key block&#8221;.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2008/01/05/mit-pgp-keyserver/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GnuPG Turns 10</title>
		<link>http://pthree.org/2007/12/20/gnupg-turns-10/</link>
		<comments>http://pthree.org/2007/12/20/gnupg-turns-10/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 15:34:52 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[OSS]]></category>

		<guid isPermaLink="false">http://www.pthree.org/2007/12/20/gnupg-turns-10/</guid>
		<description><![CDATA[Happy Birthday to the GnuPG team and community. GnuPG turns 10 today! For those caught unaware, GnuPG was designed to be a Free Software implementation of PGP, removing the patented algorithms, such as RSA and IDEA, and replacing them with Free Software algorithms, such as Blowfish and ElGamal. Being a strong advocate of GnuPG and [...]]]></description>
			<content:encoded><![CDATA[<p>Happy Birthday to the GnuPG team and community.  <a href="http://gnupg.org">GnuPG</a> turns 10 today!  For those caught unaware, GnuPG was designed to be a Free Software implementation of PGP, removing the patented algorithms, such as RSA and IDEA, and replacing them with Free Software algorithms, such as Blowfish and ElGamal.  Being a strong advocate of GnuPG and cryptography in general, this is great news.  <a href="http://lists.gnupg.org/pipermail/gnupg-announce/2007q4/000268.html">Werner Koch mailed the GnuPG-Announce mailing list</a>, giving a brief history of the project.  Worth a read for anyone who uses GPG.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2007/12/20/gnupg-turns-10/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A Perfect Reason Why You Should Digitally Sign Emails</title>
		<link>http://pthree.org/2006/07/28/a-perfect-reason-why-you-should-digitally-sign-emails/</link>
		<comments>http://pthree.org/2006/07/28/a-perfect-reason-why-you-should-digitally-sign-emails/#comments</comments>
		<pubDate>Fri, 28 Jul 2006 14:36:33 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.pthree.org/2006/07/28/a-perfect-reason-why-you-should-digitally-sign-emails/</guid>
		<description><![CDATA[According to a supposed email from lead developer of PHP Jani Taskinen, he&#8217;s outta here, and not looking back. Goodbye PHP, goodbye cruel world! is the theme of his email. From: Jani Taskinen Subject: Good bye. Group: php.internals Date: Thu Jul 27 20:28:45 2006 Thank you all for the last 6 years or so. It [...]]]></description>
			<content:encoded><![CDATA[<p>According to a <a href="http://news.php.net/php.internals/25023">supposed email</a> from lead developer of PHP Jani Taskinen, he&#8217;s outta here, and not looking back.  Goodbye PHP, goodbye cruel world! is the theme of his email.</p>
<blockquote><p><strong>From:</strong> <a href="mailto:sniper+at+iki+dot+fi">Jani Taskinen</a><br />
<strong>Subject:</strong> Good bye.<br />
<strong>Group:</strong> <a href="http://news.php.net/php.internals">php.internals</a><br />
<strong>Date:</strong> Thu Jul 27 20:28:45 2006</p>
<p>Thank you all for the last 6 years or so. It has been fun (sometimes) and many times not so much fun. Unfortunately I have had enough and I don&#8217;t want to be associated with this project anymore.</p>
<p>I&#8217;m sure most people (the ones who matter) can understand why. If someone doesn&#8217;t, I could not care less. Take care.</p>
<p>Please do not reply to this email.</p>
<p>&#8211;Jani</p>
<p>p.s. Delete my CVS account. I have no use for it anymore.</p></blockquote>
<p>When I give my security presentations on cryptography, a common security flaw that I like to bring up is using 3rd party programs to send email to others which looks as though it came from a certain account; in this case, Jani&#8217;s email at iki.fi.  Heck, even a little JavaScript can do the trick.</p>
<p>Once, while giving a presentation to university class, I told the class the following scenario:</p>
<blockquote><p>If you were to receive an email in your inbox from your professors email address, would you believe it was send from him?  Of course you would.  There would be no reason not to.  At least not yet.</p>
<p>What if the email said that due to a family emergency, he would no longer be able to instruct the class, and that everyone will get an &#8216;A&#8217; for the course.  The email would say further, don&#8217;t bother attending class or responding to the email as he will be out of town taking care of the family emergency.  Also, he&#8217;ll have all the details worked out with the school.</p>
<p>Would you still believe the email is legit?</p></blockquote>
<p>Not surprisingly, everyone in the class, including the professor, said they would totally believe the email, and quit attending class.  Only a handful of students said that they would stay in contact with the school administration making sure all the details went smooth.  It is unfortunate that they would be the only ones, with the professors help, smoothing out the scam.</p>
<p>What is the point?  The point is to generate a public cryptography key-pair, and begin digitally signing all of your emails.  This way, everyone can be assured that the email did in fact come from whomever it says it came from, so long as the email validates, and the necessary steps have been taken to ensure the public key belongs to the actual owner.</p>
<p>Right now at this point, I am not believing the email.  I believe that it is scam, and the wrinkles will be smoothed out soon.  Hopefully, Jani signs his emails, and will be able to refute this nonsense.  However, if the email is legit, confusion could have been avoided if the email was just signed.  It will undoubtedly be a big loss for the PHP community.</p>
<p>I&#8217;ve said it before, and I&#8217;ll say it again: If you receive an email from me and it is not signed, or the signature fails, you should question the authenticity of the email text and whether or not it did actually come from me.  I go to great lengths to ensure that my email validates before sending, so rarely will an email from me not check out.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2006/07/28/a-perfect-reason-why-you-should-digitally-sign-emails/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Public Keyservers</title>
		<link>http://pthree.org/2006/06/25/public-keyservers/</link>
		<comments>http://pthree.org/2006/06/25/public-keyservers/#comments</comments>
		<pubDate>Mon, 26 Jun 2006 01:37:50 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>

		<guid isPermaLink="false">http://www.pthree.org/2006/06/25/public-keyservers/</guid>
		<description><![CDATA[As mentioned in my last post, I don&#8217;t generally use keyservers. I would much rather just email the key or leave it posted on my blog. However, with that said, I do have my key published to the 3 most popular keyservers on the web, with the first as my default in both Seahorse and [...]]]></description>
			<content:encoded><![CDATA[<p>As mentioned in my last post, I don&#8217;t generally use keyservers.  I would much rather just email the key or leave it posted on my blog.  However, with that said, I do have my key published to the 3 most popular keyservers on the web, with the first as my default in both Seahorse and GPA (for obvious reasons I hope).</p>
<ul>
<li><a href="http://keyserver.ubuntu.com:11371">http://keyserver.ubuntu.com:11371</a></li>
<li><a href="http://keyserver.veridis.com:11371">http://keyserver.veridis.com:11371</a></li>
<li><a href="http://pgp.mit.edu/">http://pgp.mit.edu</a></li>
</ul>
<p>The main reason I choose these are because they can handle multiple subkeys and modified UIDs whereas many keyservers cannot.  At any rate, I thought that I would share this, because they are solid, always up, great web interface and easy to use.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2006/06/25/public-keyservers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My GnuPG Public Key</title>
		<link>http://pthree.org/2006/06/24/my-gnupg-public-key/</link>
		<comments>http://pthree.org/2006/06/24/my-gnupg-public-key/#comments</comments>
		<pubDate>Sat, 24 Jun 2006 15:00:28 +0000</pubDate>
		<dc:creator>Aaron Toponce</dc:creator>
				<category><![CDATA[Cryptology]]></category>

		<guid isPermaLink="false">http://www.pthree.org/2006/06/24/my-gnupg-public-key/</guid>
		<description><![CDATA[For those of you who read my blog and wonder if I have a GPG key, well your in luck! I have had a key since Glen, a friend of mine, introduced me the world of encryption and security in September 2004, and my life hasn&#8217;t been the same since. I used to sign all [...]]]></description>
			<content:encoded><![CDATA[<p>For those of you who read my blog and wonder if I have a GPG key, well your in luck!  I have had a key since Glen, a friend of mine, introduced me the world of encryption and security in September 2004, and my life hasn&#8217;t been the same since.</p>
<p>I used to sign all of my emails, regardless.  Well lately, I have been getting lazy and haven&#8217;t been so steadfast.  However, my motivation has been renewed since <a href="http://christer.homeip.net/">Christer</a> started asking me questions about it.  So, from here on out, every email sent from me will be signed.  If the email is not signed with my key, then you should question whether or not it came from me.  If the signature fails (I will always do my best to make sure this doesn&#8217;t happen), you should also question the authenticity of the email.</p>
<p>I try and keep an updated version of my key on all the public keyservers that I can, however, you can always find the most <a href="http://www.pthree.org/author-colophon/">up-to-date key on this blog</a>.  Speaking of which, I made some edits to the key this morning, so it is recommended that you grab <a href="http://www.pthree.org/wp-content/uploads/2006/06/aaron.asc">this most updated copy</a>.</p>
<p>Being a Computer Science Major and Math Minor, I enjoy cryptology immensely.  I hope to be a cryptologist when I grow up.  I have been studying in this vast field for quite some time, and would love to speak to any Linux Users Group concerning cryptology- whether it be about its history, application, variations, or related fields.  I have a great amount of data on the subject at hand, so presenting on just about any aspect of it is no problem at all.  Just <a href="http://www.pthree.org/contact/">drop me a line</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://pthree.org/2006/06/24/my-gnupg-public-key/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

