<?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>Noa&#039;s blog &#187; Programming</title>
	<atom:link href="http://noa.resare.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://noa.resare.com</link>
	<description>moderately interesting words about things going through my mind</description>
	<lastBuildDate>Fri, 29 Jan 2010 23:56:06 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>My password generator</title>
		<link>http://noa.resare.com/2010/01/password-generator/</link>
		<comments>http://noa.resare.com/2010/01/password-generator/#comments</comments>
		<pubDate>Fri, 29 Jan 2010 23:55:08 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[passwords]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[security]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=288</guid>
		<description><![CDATA[How do you create a really good password that you don't need to remember but that you might occasionally need to write on paper or type into a keyboard? These days modern operating system provide really good sources of randomness, and one method that is often used is to read some randomness from the operating [...]]]></description>
			<content:encoded><![CDATA[<p>How do you create a really good password that you don't need to remember but that you might occasionally need to write on paper or type into a keyboard? These days modern operating system provide really good sources of randomness, and one method that is often used is to read some randomness from the operating system <a href="http://en.wikipedia.org/wiki/PRNG">PRNG</a> located at /dev/random and run the data through the base64 encoding to get letters, numbers, + (plus) and / (slash). However, those passwords are not that conveinent and sometimes when I write them down people mistake my zeroes for capital o and things like that.</p>
<p>What I wanted was a password generator that could output a configurable length password using only easily distinguishable letters and numbers, so I wrote one. As usual I place this code in the public domain, feel free to use it any way you want.</p>
<p>Features:</p>
<ol>
<li>The entropy of the password is as good as the underlying operating system. If you use a recent Linux or OSX version, the data returned from /dev/random is quite good.</li>
<li>The code is simple and it is easy to verify that the program actually uses the entropy that it reads.</li>
<li>The resulting passwords are easy to type on keyboards and write on paper without confusing the reader with similar characters such as 1 (one) and l (lower case l).</li>
<li>The length of the password is configurable.</li>
</ol>
<pre class="python"><span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># alphanumeric chars minus l, I, O, 0, 1</span>
alphabet = <span style="color: #483d8b;">&quot;abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789&quot;</span>
<span style="color: #808080; font-style: italic;"># Some expeimentation told me that 2 ** 5.8 = 55.7</span>
BITS_PER_CHAR = <span style="color: #ff4500;">5.8</span>
&nbsp;
<span style="color: #808080; font-style: italic;"># The default password length has the capacity of a bit more</span>
<span style="color: #808080; font-style: italic;"># than 64 bits of entropy.</span>
DEFAULT_LEN = <span style="color: #ff4500;">12</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> main<span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span>:
	count = DEFAULT_LEN
	<span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span> &amp;gt; <span style="color: #ff4500;">1</span>:
		<span style="color: #ff7700;font-weight:bold;">if</span> args<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">'-h'</span>:
			usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
			<span style="color: #ff7700;font-weight:bold;">return</span>
		<span style="color: #ff7700;font-weight:bold;">elif</span> args<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> == <span style="color: #483d8b;">'-c'</span> <span style="color: #ff7700;font-weight:bold;">and</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>args<span style="color: black;">&#41;</span> &amp;gt; <span style="color: #ff4500;">2</span>:
			count = <span style="color: #008000;">int</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;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">else</span>:
			usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
			<span style="color: #ff7700;font-weight:bold;">return</span>
	<span style="color: #ff7700;font-weight:bold;">print</span><span style="color: black;">&#40;</span>create_password<span style="color: black;">&#40;</span>count<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> string_to_bignum<span style="color: black;">&#40;</span>s<span style="color: black;">&#41;</span>:
	num = <span style="color: #ff4500;">0</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> c <span style="color: #ff7700;font-weight:bold;">in</span> s:
		num = <span style="color: #008000;">ord</span><span style="color: black;">&#40;</span>c<span style="color: black;">&#41;</span> + <span style="color: black;">&#40;</span>num &amp;lt;&amp;lt; <span style="color: #ff4500;">8</span><span style="color: black;">&#41;</span>;
	<span style="color: #ff7700;font-weight:bold;">return</span> num
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> create_password<span style="color: black;">&#40;</span>length<span style="color: black;">&#41;</span>:
	<span style="color: #dc143c;">random</span> = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;/dev/random&quot;</span>, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
	needed_bytes = <span style="color: black;">&#40;</span><span style="color: #008000;">int</span><span style="color: black;">&#41;</span><span style="color: black;">&#40;</span>length * BITS_PER_CHAR<span style="color: black;">&#41;</span> / <span style="color: #ff4500;">8</span> + <span style="color: #ff4500;">1</span>
	n = string_to_bignum<span style="color: black;">&#40;</span><span style="color: #dc143c;">random</span>.<span style="color: black;">read</span><span style="color: black;">&#40;</span>needed_bytes<span style="color: black;">&#41;</span><span style="color: black;">&#41;</span>
	<span style="color: #dc143c;">random</span>.<span style="color: black;">close</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	s = <span style="color: #483d8b;">&quot;&quot;</span>
	<span style="color: #ff7700;font-weight:bold;">for</span> i <span style="color: #ff7700;font-weight:bold;">in</span> <span style="color: #008000;">xrange</span><span style="color: black;">&#40;</span>length<span style="color: black;">&#41;</span>:
		s = s + alphabet<span style="color: black;">&#91;</span>n % <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>alphabet<span style="color: black;">&#41;</span><span style="color: black;">&#93;</span>
		n = n / <span style="color: #008000;">len</span><span style="color: black;">&#40;</span>alphabet<span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">return</span> s
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
	<span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;&quot;</span><span style="color: #483d8b;">&quot;mkpasswd [-h] [-c COUNT]
Create a random password using the operating system's entropy pool
using a 57 character alphabet of letters and numbers. The characters
in the alphabet excludes characters and letters easily confusable such
as I and 1. 
&nbsp;
Each password character holds about 5.8 bits of entropy, so the
standard 12 character password can hold a theroretical maximum of
69 bits of entropy.
&nbsp;
The actual entropy present in any generated password is a function
of the entropy gathering algortihm present in the kernel of your
operating system.
&nbsp;
  -h        display this help text
  -c COUNT  create a password with COUNT characters.&quot;</span><span style="color: #483d8b;">&quot;&quot;</span>  
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
	main<span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span></pre>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2010/01/password-generator/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>rjmailer in the real world</title>
		<link>http://noa.resare.com/2009/11/rjmailer/</link>
		<comments>http://noa.resare.com/2009/11/rjmailer/#comments</comments>
		<pubDate>Sat, 28 Nov 2009 12:56:58 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[rjmailer]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=274</guid>
		<description><![CDATA[One of my little pet projects is the rjmailer java email sending library. It does one specific thing, sending email, but does it with a twist: it actually tells you a lot about how the delivery went compared to other email sending solutions.
This is useful for example when you are about to sign up to [...]]]></description>
			<content:encoded><![CDATA[<p>One of my little pet projects is the <a href="http://rjmailer.org/">rjmailer</a> java email sending library. It does one specific thing<em>, sending email, </em>but does it with a twist: it actually tells you a lot about how the delivery went compared to other email sending solutions.</p>
<p>This is useful for example when you are about to sign up to an online service that requires your email to be validated by sending an email  message with a link for you to click to activate your account. If you spell your email address incorrectly the registration will fail, but you will not typically get any feedback that the email delivery failed.<img class="alignright size-full wp-image-199" title="Mr Postman" src="/wp-content/uploads/2009/04/rj-mailman.png" alt="Mr Postman" width="107" height="252" /></p>
<p>With rjmailer it is possible to build an online service that tells the users if an email delivery failed right away in the web form that was used to register. Having this information can help the user to correct a spelling error or remove messages from a full inbox.</p>
<p>I released the initial public version of this piece of software back in april, but I haven't really had any time to start using it at work until now. This past week I spent a few hours modifying one of our projects, <a href="http://biblesearch.org">http://biblesearch.org</a>, to use rjmailer when sending out account activation links and report back to the user if there was an issue sending out the mail. Feel free to try it out if you want, registering is free. Just fill out the form at the new user <a href="http://biblesearch.org/newuser">registration page</a>.</p>
<p>While adding this feature I found a few small issues in rjmailer, so there is a new version available for <a href="http://rjmailer.org/">download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/11/rjmailer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>My DNSSEC validator</title>
		<link>http://noa.resare.com/2009/11/dnssec/</link>
		<comments>http://noa.resare.com/2009/11/dnssec/#comments</comments>
		<pubDate>Sun, 08 Nov 2009 19:14:08 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[System administration]]></category>
		<category><![CDATA[DNSSEC]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=267</guid>
		<description><![CDATA[As readers of this blog might have noticed I started to experiment with DNSSEC a few months ago. DNSSEC is basically a way of adding cryptographic keys and signatures to your DNS data that gives resolvers the ability to cryptographically verify the correctness of your DNS records using a series of cryptographic operations.
DNSSEC protects the [...]]]></description>
			<content:encoded><![CDATA[<p>As readers of this blog might have noticed I started to experiment with <a href="http://dnssec.net/">DNSSEC</a> a few months ago. DNSSEC is basically a way of adding cryptographic keys and signatures to your DNS data that gives resolvers the ability to cryptographically verify the correctness of your DNS records using a series of cryptographic operations.</p>
<p>DNSSEC protects the DNS system against a certain group of security problems such as the <a href="http://kaminskybug.se">kaminskybug</a>, where an attacker tricks a DNS server to return the wrong data to end users. If an attack against the DNS system is successful that means serious trouble, since we depend on it to work reliably in a vast number of online activities. An attacker that controls the DNS system can trick people to for example supply their account information to their online bank and use that to steal money. Whenever there is the potential for large scale fraud you can pretty much be sure that someone will try to break it, and that is why DNSSEC is important.</p>
<p>So, we need DNSSEC. What's stopping us from using it? A few things, but the most important obstacle in my opinion is that it is a complex set of standards and that it is difficult to understand. There are some <a href="http://alan.clegg.com/files/DNSSEC_in_6_minutes.pdf">presentations</a> and <a href="http://www.nlnetlabs.nl/publications/dnssec_howto/">HOWTO documents</a> online that attempts to explain and help people get started, but the learning curve is steep. One thing that I ran into when experimenting with my own zones was that somehow I managed to corrupt the signatures of one zone and I couldn't easily pinpoint what the problem was.</p>
<p>When confronted with this I got the idea to build an online service that tries to answer a simple question.<em> What data was used and what cryptographic operations was performed to actually verify one specific DNS record?</em> The answer to that question can be thought of as a chain of operations and records where one link connects to the other from all the way from the record being verified down to the <a href="https://dlv.isc.org/">DLV</a> root key.</p>
<p>I decided to write the service in Python and it was one of the most fun programming projects that I have worked on in years. In a way it was basic research but with a clear application and an end result that I think could be a useful contribution. I even wrote my own <a href="http://en.wikipedia.org/wiki/RSA">RSA</a> signature verification functionality, with a lots of help from Python's excellent large integer support.</p>
<p>The service can be found at <a href="http://dnssec.resare.com">http://dnssec.resare.com</a> Feel free to give it a spin. There are no doubt bugs and errors that will be fixed and other modifications that will be made, but the basic functionality is in place.</p>
<p>Thanks to Alex for the beautiful HTML design,  to the python dns library <a href="http://www.dnspython.org/">dnspython</a> that I use extensively and the <a href="http://dev.sanityinc.com/airspeed/">airspeed</a> templating library.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/11/dnssec/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>sha1sum rewritten in python using openssl</title>
		<link>http://noa.resare.com/2009/11/sha1sum/</link>
		<comments>http://noa.resare.com/2009/11/sha1sum/#comments</comments>
		<pubDate>Thu, 05 Nov 2009 18:44:59 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[System administration]]></category>
		<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[OSX]]></category>
		<category><![CDATA[sha1sum]]></category>
		<category><![CDATA[Terminal]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=261</guid>
		<description><![CDATA[I like how I can use the sha1sum tool on my Linux boxes to create a file with checksums of a collection of files and then use the tool again to verify the files against the checksums.
I've been missing that functionality on my Mac, so I wrote a small wrapper to the openssl command that [...]]]></description>
			<content:encoded><![CDATA[<p>I like how I can use the <tt>sha1sum</tt> tool on my Linux boxes to create a file with checksums of a collection of files and then use the tool again to verify the files against the checksums.</p>
<p>I've been missing that functionality on my Mac, so I wrote a small wrapper to the openssl command that provide the same basic functionality using Python. Python is really handy when it comes to writing small scripts like that does some string handling and calls other programs and since the basic checksumming functionality already is available in the openssl package it simple, short and neat.</p>
<p>As usual, feel free to use this any way you want.</p>
<pre class="python">&nbsp;
<span style="color: #808080; font-style: italic;">#!/usr/bin/python</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">subprocess</span>
<span style="color: #ff7700;font-weight:bold;">import</span> <span style="color: #dc143c;">sys</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> checksum_file<span style="color: black;">&#40;</span>filename<span style="color: black;">&#41;</span>:
    sp = <span style="color: #dc143c;">subprocess</span>.<span style="color: black;">Popen</span><span style="color: black;">&#40;</span><span style="color: black;">&#91;</span><span style="color: #483d8b;">&quot;/usr/bin/openssl&quot;</span>, <span style="color: #483d8b;">&quot;sha1&quot;</span>, filename<span style="color: black;">&#93;</span>,
                          stdout=<span style="color: #dc143c;">subprocess</span>.<span style="color: black;">PIPE</span><span style="color: black;">&#41;</span>
    retval = sp.<span style="color: black;">communicate</span><span style="color: black;">&#40;</span><span style="color: black;">&#41;</span><span style="color: black;">&#91;</span><span style="color: #ff4500;">0</span><span style="color: black;">&#93;</span>
    <span style="color: #ff7700;font-weight:bold;">return</span> retval<span style="color: black;">&#91;</span>retval.<span style="color: black;">find</span><span style="color: black;">&#40;</span><span style="color: #483d8b;">&quot;= &quot;</span><span style="color: black;">&#41;</span> + <span style="color: #ff4500;">2</span>:<span style="color: #ff4500;">-1</span><span style="color: black;">&#93;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> verify<span style="color: black;">&#40;</span>checksumfile<span style="color: black;">&#41;</span>:
    f = <span style="color: #008000;">open</span><span style="color: black;">&#40;</span>checksumfile, <span style="color: #483d8b;">&quot;r&quot;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">for</span> line <span style="color: #ff7700;font-weight:bold;">in</span> f:
        line = line<span style="color: black;">&#91;</span>:<span style="color: #ff4500;">-1</span><span style="color: black;">&#93;</span>
		<span style="color: black;">&#40;</span>sha1, fn<span style="color: black;">&#41;</span> = line.<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>
		calc = checksum_file<span style="color: black;">&#40;</span>fn<span style="color: black;">&#41;</span>
		<span style="color: #ff7700;font-weight:bold;">if</span> calc != sha1:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s: FAILED&quot;</span> % fn
            <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
        <span style="color: #ff7700;font-weight:bold;">else</span>:
            <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s: OK&quot;</span> % fn
&nbsp;
<span style="color: #ff7700;font-weight:bold;">def</span> usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>:
    <span style="color: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;Usage: sha1sum [-c CHECKSUM_FILE] [FILE]...&quot;</span>
    <span style="color: #dc143c;">sys</span>.<span style="color: black;">exit</span><span style="color: black;">&#40;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#41;</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">if</span> __name__ == <span style="color: #483d8b;">'__main__'</span>:
    <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> == <span style="color: #ff4500;">1</span>:
        usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
	<span style="color: #ff7700;font-weight:bold;">if</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: #483d8b;">'-c'</span>:
        <span style="color: #ff7700;font-weight:bold;">if</span> <span style="color: #008000;">len</span><span style="color: black;">&#40;</span><span style="color: #dc143c;">sys</span>.<span style="color: black;">argv</span><span style="color: black;">&#41;</span> != <span style="color: #ff4500;">3</span>:
            usage<span style="color: black;">&#40;</span><span style="color: black;">&#41;</span>
        verify<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;">2</span><span style="color: black;">&#93;</span><span style="color: black;">&#41;</span>
    <span style="color: #ff7700;font-weight:bold;">else</span>:
        <span style="color: #ff7700;font-weight:bold;">for</span> f <span style="color: #ff7700;font-weight:bold;">in</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: #ff7700;font-weight:bold;">print</span> <span style="color: #483d8b;">&quot;%s  %s&quot;</span> % <span style="color: black;">&#40;</span>checksum_file<span style="color: black;">&#40;</span>f<span style="color: black;">&#41;</span>, f<span style="color: black;">&#41;</span>
&nbsp;</pre>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/11/sha1sum/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DIGEST-MD5 implemented in python</title>
		<link>http://noa.resare.com/2009/10/digest-md5/</link>
		<comments>http://noa.resare.com/2009/10/digest-md5/#comments</comments>
		<pubDate>Thu, 08 Oct 2009 15:16:47 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[DIGEST-MD5]]></category>
		<category><![CDATA[MD5]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[SASL]]></category>
		<category><![CDATA[XMPP]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=249</guid>
		<description><![CDATA[I set up an XMPP server a while ago, and yesterday I noticed that the Psi client could not connect to my server. A quick look in the logs indicated that something went wrong during authentication. Unfortunately the authentication method used, something called DIGEST-MD5, isn't easily debuggable by hand, so I dug up the specification [...]]]></description>
			<content:encoded><![CDATA[<p>I set up an <a href="http://xmpp.org/">XMPP</a> server a while ago, and yesterday I noticed that the <a href="http://psi-im.org/">Psi</a> client could not connect to my server. A quick look in the logs indicated that something went wrong during authentication. Unfortunately the authentication method used, something called DIGEST-MD5, isn't easily debuggable by hand, so I dug up the specification of the method in <a href="http://www.ietf.org/rfc/rfc2831.txt">RFC2831</a> and wrote a small utility in python that generates a response to a DIGEST-MD5 challenge. It is available from here: <a href="http://resare.com/noa/ref/digest-md5.py">digest-md5.py</a>.</p>
<p>I have tested it with the XMPP and SMTP protocols and should run on python 2 variants from 2.3  onwards. Feel free to use it any way you want. Comments and suggestions for improvements are welcome, as always.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/10/digest-md5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A java list randomizer</title>
		<link>http://noa.resare.com/2009/09/randomizer/</link>
		<comments>http://noa.resare.com/2009/09/randomizer/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 13:14:05 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[list]]></category>
		<category><![CDATA[random order]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=239</guid>
		<description><![CDATA[This week I came across what seemed like a simple programming problem. From a large list of items I wanted to create a smaller list with random items copied from the larger list. The real world equivalent of would be something like bring me four random records from your CD collection.  Sounds simple? Well, there [...]]]></description>
			<content:encoded><![CDATA[<p>This week I came across what seemed like a simple programming problem. From a large list of items I wanted to create a smaller list with random items copied from the larger list. The real world equivalent of would be something like <em>bring me four random records from your CD collection</em>.  Sounds simple? Well, there was an additional requirement on that I put on the solution, and that was that the smaller list should contain no duplicates.</p>
<p>There is a <a href="http://java.sun.com/javase/6/docs/api/java/util/Random.html">Random</a> class in java that returns pseudorandom numbers. However, there is no guarantee that when calling Random.nextInt() a number of times the same number will not be returned twice.  In other words, the simple strategy filling a small list with elements from the large list picked at random with the help of Random.nextInt() will probably produce a result list when the same element is added twice. Not good enough.</p>
<p>One defense against that problem could be to keep track of which numbers the random generator has returned and simply discard any duplicates. For most cases that strategy is probably efficient, but sometimes it could lead to having to discard a whole bunch of random numbers. Moreover, execution times of such a solution would differ a lot depending on which numbers Random.nextInt() returned.</p>
<p>Another solution would be to copy all of the large list to a temporary list and remove each element taken to the smaller list from the temporary list. That way, no item would be added twice to the result list. However, if the source list is long, say a million entries, creating a temporary list to fetch holding all the million entries just to extract 100 random entries would be inefficient.</p>
<p>The elegant solution to this problem in my mind would instead be to create a list of offsets into the large list as long as the small list. The list of offsets would then be modified to emulate the effect of having a copy of the large list and removing entries from it. If the first entry of the offset list is offset 1, and the second offset also is 1, modify that to 2 instead, the element that would have been at position 1 if the original element at that position was removed.</p>
<p>I wrote a class implementing this solution, <a href="http://resare.com/noa/ref/Randomizer.java">Randomizer.java</a>. Feel free to use it or modify it anyway you wish.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/09/randomizer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Random summer stuff. New jresolver, with DNSSEC support</title>
		<link>http://noa.resare.com/2009/08/jresolver/</link>
		<comments>http://noa.resare.com/2009/08/jresolver/#comments</comments>
		<pubDate>Wed, 12 Aug 2009 15:48:21 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[DNSSEC]]></category>
		<category><![CDATA[jresolver]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=220</guid>
		<description><![CDATA[After a sort of long summer break I'm slowly feeling like it would be fun to blog a bit again. After an intense election campaign for the European Parliament in June, we actually did get a Pirate party representatitive elected, which feels like a milestone for the geeks in politics. Congratulations Christian!

I have spent most [...]]]></description>
			<content:encoded><![CDATA[<p>After a sort of long summer break I'm slowly feeling like it would be fun to blog a bit again. After an intense election campaign for the European Parliament in June, we actually did get a Pirate party representatitive elected, which feels like a milestone for the geeks in politics. Congratulations <a href="http://en.wikipedia.org/wiki/Christian_Engstr%C3%B6m">Christian</a>!<br />
<img src="/wp-content/uploads/2009/08/dnssec-1.jpg" alt="dnssec-1" title="dnssec-1" width="200" height="224" class="alignright size-full wp-image-224" /><br />
I have spent most of the summer doing <a href="http://voxbiblia.com/">work</a> <a href="http://biblesearch.org/">programming</a> but I have also managed to go to Rome with <a href="http://sangkraft.org/">Sångkraft</a> and  <a href="http://www.interkultur.com/fileadmin/pdf_data/results/roma_2009.pdf">win</a> a choir competition and update one of my free software projects, the jresolver Java stub resolver.</p>
<p>The new version of jresolver adds some autoconfig abilities as well as some awareness of DNSSEC. Now the resolver can query the recursive nameserver about weather a specific result is cryptographically verified or not. Perhaps not a terribly useful feature, but I think that anything that brings awareness to the effort to get people to use DNSSEC is a good thing. Anyway, the new version, 0.3.1, can be found over at <a href="http://fs.voxbiblia.com/jresolver">fs.voxbiblia.com</a>. Now, at least everyone that has a .se domain, run over to <a href="http://iis.se/">iis.se</a> and read up on how to sign your zones.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/08/jresolver/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Introducing rjmailer</title>
		<link>http://noa.resare.com/2009/04/introducing-rjmailer/</link>
		<comments>http://noa.resare.com/2009/04/introducing-rjmailer/#comments</comments>
		<pubDate>Thu, 02 Apr 2009 19:20:43 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[rjmailer]]></category>
		<category><![CDATA[Free Software]]></category>
		<category><![CDATA[SMTP]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=198</guid>
		<description><![CDATA[Today I have decided that it is time to publish rjmailer, a programming project that I have worked with on spare time for the last two years or so. In my own view, rjmailer is the most useful piece of software I have written yet, and I have some faith that in time others will [...]]]></description>
			<content:encoded><![CDATA[<p>Today I have decided that it is time to publish rjmailer, a programming project that <img class="alignright size-full wp-image-199" title="rj-mailman" src="http://noa.resare.com/wp-content/uploads/2009/04/rj-mailman.png" alt="rj-mailman" width="107" height="252" />I have worked with on spare time for the last two years or so. In my own view, rjmailer is the most useful piece of software I have written yet, and I have some faith that in time others will find it useful as well. Thanks to my amazing partner Alex, it even has it's own mascot and webpage to go with the release. I love you man!</p>
<p>rjmailer is a programming library that sends mail. There are some other pieces of software that does that, but they usually hand off their messages to the mail system and don't give much feedback to the user. rjmailer is not like that. It goes out of it's way to provide as much information as possible about the mail delivery and can in many cases give detailed and quick information about failures such as misspelled usernames or domain names.</p>
<p>Lets say you run a web based service that require people to register with some email address. You want to verify that the address is valid, so you send an email to the address that the user provided when signing up and require her to click a link in that message to activate your account. We're all used to this, but there are lots of things that can go wrong. The user can misspell her email address, or there can be some problem with her email server that causes the activation message to bounce. If you are unlucky you lose a member or even someone that can later be converted to a paying customer.</p>
<p>If that sounds interesting, please have a look at <a href="http://rjmailer.org/">rjmailer.org</a>. However, please be warned: this is beta software. It is not yet fully tested, has bugs and will probably lose your mail for the moment.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/04/introducing-rjmailer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>pwhash in Ruby</title>
		<link>http://noa.resare.com/2009/03/pwhash-in-ruby/</link>
		<comments>http://noa.resare.com/2009/03/pwhash-in-ruby/#comments</comments>
		<pubDate>Sun, 29 Mar 2009 14:46:57 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Cryptography]]></category>
		<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[password hashing]]></category>
		<category><![CDATA[pwhash]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=191</guid>
		<description><![CDATA[I spent some time this weekend re-implementing my pwhash functionality in ruby. I don't have much experience with ruby. I got some exposure to it when doing some work for johnlook a while back, but when writing this code it became apparent that I had some gaps in my knowledge.
Learning new programming languages is an [...]]]></description>
			<content:encoded><![CDATA[<p>I spent some time this weekend re-implementing my pwhash functionality in <a href="http://ruby-lang.org/">ruby</a>. I don't have much experience with ruby. I got some exposure to it when doing some work for <a href="http://johnlook.com/">johnlook</a> a while back, but when writing this code it became apparent that I had some gaps in my knowledge.</p>
<p>Learning new programming languages is an interesting thing to do. I've done it a few times now and if the language is good it gives you a few new perspectives and new ideas on how to be a better programmer. I must say that ruby is a nice acquaintance. The learning curve is a bit steeper than with languages like python (or maybe I'm just getting old) but many things are elegant and I hope to get to work more with it in the future.</p>
<p>Anyway, without any further ado I give you <a href="http://fs.voxbiblia.com/pwhash/dist/pwhash.rb">pwhash.rb</a>. Feel free to use it in any way that is compatible with GPL3. I'm fully aware that I have yet to master the style and details of ruby, so if you have any criticisms or ideas on how to improve upon it, feel free to drop me a line.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/03/pwhash-in-ruby/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>pwhash, password hashing in java</title>
		<link>http://noa.resare.com/2009/03/pwhash/</link>
		<comments>http://noa.resare.com/2009/03/pwhash/#comments</comments>
		<pubDate>Sat, 28 Mar 2009 14:54:19 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Geeky]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Base 64]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[password hashing]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=187</guid>
		<description><![CDATA[As promised, here is the code to a Java implementation of the principles of password hashing that I outlined in my previous post. I'll put it on a proper project page later on, but for now the full distribution can be downladed as pwhash-0.9.zip, the binary jar can be found as pwhash-0.9.jar and the source [...]]]></description>
			<content:encoded><![CDATA[<p>As promised, here is the code to a Java implementation of the principles of password hashing that I outlined in my <a href="http://noa.resare.com/2009/03/protect-passwords/">previous post</a>. I'll put it on a proper project page later on, but for now the full distribution can be downladed as <a href="http://fs.voxbiblia.com/pwhash/dist/pwhash-0.9.zip">pwhash-0.9.zip</a>, the binary jar can be found as <a href="http://fs.voxbiblia.com/pwhash/dist/pwhash-0.9.jar">pwhash-0.9.jar</a> and the source code with documentation can be found at <a href="http://fs.voxbiblia.com/pwhash/dist/PasswordHasher.java">PasswordHasher.java.</a></p>
<p>Included in the distribution is also a Base64 implementation, <a href="http://fs.voxbiblia.com/pwhash/dist/Base64.java">Base64.java</a>, that I wrote. The fact that Sun hasn't included it in Java from version from the very beginning is a mystery to me. My implementation might not be the fastest or the most robust one around but it is quite readable and preforms okay.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/03/pwhash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
