<?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</title>
	<atom:link href="http://noa.resare.com/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>0</slash:comments>
		</item>
		<item>
		<title>D-Link DWL-G510 in CentOS 5</title>
		<link>http://noa.resare.com/2009/12/dwl-g510-centos/</link>
		<comments>http://noa.resare.com/2009/12/dwl-g510-centos/#comments</comments>
		<pubDate>Sat, 26 Dec 2009 15:48:11 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[System administration]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[AirPlus G]]></category>
		<category><![CDATA[D-Link]]></category>
		<category><![CDATA[DWL-G510]]></category>
		<category><![CDATA[PCI]]></category>
		<category><![CDATA[WiFi]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=281</guid>
		<description><![CDATA[Some days ago I spent some time getting a PCI WiFi 802.11G network card to work in CentOS 5.4. My card identifies itself as a "D-Link System Inc AirPlus G DWL-G510" (PCI id 1186:3c09) and uses the "RaLink RT2561/RT61 rev B 802.11g" chipset (PCI id 1814:0302)
A driver for this card is included in the standard [...]]]></description>
			<content:encoded><![CDATA[<p>Some days ago I spent some time getting a PCI WiFi 802.11G network card to work in CentOS 5.4. My card identifies itself as a "D-Link System Inc AirPlus G DWL-G510" (PCI id 1186:3c09) and uses the "RaLink RT2561/RT61 rev B 802.11g" chipset (PCI id 1814:0302)<img class="alignleft size-full wp-image-284" title="DWL-G510" src="http://noa.resare.com/wp-content/uploads/2009/12/Satellite.jpg" alt="DWL-G510" width="180" height="120" /></p>
<p>A driver for this card is included in the standard CentOS 5 kernel (tested with kernel-2.6.18-164.9.1.el5) under the name rt61pci, however to be able to function a binary firmware is needed. Some searching revealed that the firmware is available in Fedora's 	rt61pci-firmware package. I rebuilt the package and put it in my <a href="http://rpm.resare.com/centos5-playground/">CentOS playground</a> repository.</p>
<p>So, if you have such a card and want to make it work in CentOS5 you might want to try running <tt>rpm -ivh http://rpm.resare.com/centos5-playground/i386/rt61pci-firmware-1.2-6.el5.noarch.rpm</tt> as root. Once that is done, running <tt>modprobe rt61pci</tt> should do the trick.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/12/dwl-g510-centos/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>Video problems on svt.se or svd.se? Blame qbrick.com</title>
		<link>http://noa.resare.com/2009/11/qbrick-dns-fail/</link>
		<comments>http://noa.resare.com/2009/11/qbrick-dns-fail/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 14:13:06 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[System administration]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=255</guid>
		<description><![CDATA[The Swedish public broadcasting corporation offers lots of content online on SVTPlay. Unfortunately have not worked for a while for me, and today I decided to track down the problems. It turns out to be a rather non-obvious interaction between a new feature in my resolving name server and the nameservers of the streaming provider [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://svt.se">Swedish public broadcasting corporation</a> offers lots of content online on <a href="http://svtplay.se">SVTPlay</a>. Unfortunately have not worked for a while for me, and today I decided to track down the problems. It turns out to be a rather non-obvious interaction between a new feature in my resolving name server and the nameservers of the streaming provider <a href="http://qbrick.com/">Qbrick</a> not following the DNS Specification.</p>
<p>Unlike most of the internet i use <a href="http://unbound.net/">Unbound</a> instead of <a href="https://www.isc.org/software/bind">bind</a> as my nameserver. It offers great DNSSEC support as well as a well maintained code base. One recent feature is the use of mixed case labels when sending queries to other nameservers, as outlined in the <a href="http://tools.ietf.org/html/draft-vixie-dnsext-dns0x20">DNS0x20</a> document. This is one countermeasure to the DNS Spoofing attacks that is an increasing problem on the internet these days, and it depends on the fact that name servers should treat queries that only differs in the case as if they were equals. In other words, mobizoft.qbrick.com and MobiZoft.Qbrick.com should be treated as the same.</p>
<p>The exact wording of the specification can be found in <a href="http://www.dns.net/dnsrd/rfc/rfc1035/rfc1035.html#2.3.1.">RFC1035 section 2.3.1</a>:</p>
<pre>Note that while upper and lower case letters are allowed in domain
names, no significance is attached to the case.  That is, two names with
the same spelling but different case are to be treated as if identical.</pre>
<p>Unfortunately, Qbrick's nameservers fail to implement this specification, and mixed case questions gets answered with the NXDOMAIN reply code, which means that there is no data for the given domain name. I hope that Qbrick will get their act together and fix this soon, but in the meantime it can be a good idea to use the <tt>use-caps-for-id: no</tt> directive if you are using unbound.</p>
<p>In summary it is a bit annoying that errors like these are so hard to find and correct. Most video displaying flash plugins will not report a meaningful error, and the fact that SVT uses an external provider for their streaming video solution puts the problem even further away from the end user.</p>
<p><strong>Update 091104</strong>: I have now gotten in contact with Qbrick. They recognize the problem but state that they have an ongoing project to replace the DNS solution and they will not address this issue until the new solution is in place.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/11/qbrick-dns-fail/feed/</wfw:commentRss>
		<slash:comments>5</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>Moving to proper UTF-8 in MySQL for bugzilla on CentOS 5</title>
		<link>http://noa.resare.com/2009/10/bugzilla/</link>
		<comments>http://noa.resare.com/2009/10/bugzilla/#comments</comments>
		<pubDate>Fri, 02 Oct 2009 20:34:07 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[System administration]]></category>
		<category><![CDATA[bugzilla]]></category>
		<category><![CDATA[centos]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[perl]]></category>
		<category><![CDATA[perl-DBD-MySQL]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=246</guid>
		<description><![CDATA[I have an old bugzilla instance that has been live for some years, with lots of text in it with the Swedish non-ascii characters å, ä and ö. When I set it up I didn't think about what character encoding I used for the data, I just added data and it worked. A few days [...]]]></description>
			<content:encoded><![CDATA[<p>I have an old <a href="http://bugzilla.org/">bugzilla</a> instance that has been live for some years, with lots of text in it with the Swedish non-ascii characters å, ä and ö. When I set it up I didn't think about what character encoding I used for the data, I just added data and it worked. A few days back it was time to migrate the instance to a new bugzilla version, on a <a href="http://centos.org/">CentOS</a> 5 box. It seemed like a good idea to move the data to properly <a href="http://en.wikipedia.org/wiki/UTF-8">UTF-8</a> encoded data in the database while I was in the process of moving it. It turned out to be more difficult than I anticipated. Here is a sort list of discoveries:</p>
<ol>
<li>The text was encoded in UTF-8 in the old database, but mysql thought that it was what it calls latin1. What I had entered as å the database perceived as Ã¥, but the transformation was applied on both write to and read from the database, so the characters turned out to be correct when displayed in bugzilla again.</li>
<li>The default behavior of mysqldump is to treat data it knows to be latin1 into UTF-8 in the output file. Since my data was really UTF-8, but mysql was under the impression that it was latin1, it encoded the UTF-8 into UTF-8 once more.</li>
<li>To make matters even more complicated, what mysql calls 'latin1' is not actually ISO-8859-1 but rather a slightly modified variant of the <a href="http://en.wikipedia.org/wiki/Windows-1252">Windows-1252</a> character encoding. A result of this is that in some instances the double application of the UTF-8 transformation a single input character results in 5 output characters.</li>
<li>The solution to this mess is a curiously named option to <code>mysqldump</code> named <code>--default-character-set</code>. It can be used to override the default behavior of encoding strings marked as latin1 into UTF-8. <code>mysqldump --default-character-set latin1</code> outputs my UTF-8 correctly. Once the database is in a file, just search and replace <code>default charset=latin1</code> with <code>default charset=utf8</code> and import the data.</li>
<li>At this point, the data that was UTF-8 all along is now correctly understood by mysql to be UTF-8.</li>
<li>Next problem: when starting up bugzilla with UTF-8 settings the characters still gets mangled.</li>
<li>It turns out that the bridge between mysql and perl in CentOS 5, the perl-DBD-MySQL package, is too old to support the mysql_enable_utf8 connection parameter. As a result, strings coming out of perl-DBD-MySQL containing non-ascii is not marked as utf8 strings.</li>
<li>So, why didn't checksetup.pl tell me this when I ran it? It turns out that there is a patch in the bugzilla shipped with EPEL to remove the check for the proper perl-DBD-MySQL version to make it runnable on CentOS 5. Perhaps a reasonable tradeoff, but a bit annoying when trying to find out what fails.</li>
<li>So I compiled a recent perl-DBD-MySQL and put it in my <a href="http://rpm.resare.com/centos5-playground/">playground repository</a> and now my bugzilla displays all sorts of strange characters correctly.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/10/bugzilla/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>The joy of unnecessary optimizations</title>
		<link>http://noa.resare.com/2009/09/optimizations/</link>
		<comments>http://noa.resare.com/2009/09/optimizations/#comments</comments>
		<pubDate>Sun, 20 Sep 2009 13:13:34 +0000</pubDate>
		<dc:creator>noa</dc:creator>
				<category><![CDATA[Geeky]]></category>
		<category><![CDATA[recreational programming]]></category>

		<guid isPermaLink="false">http://noa.resare.com/?p=237</guid>
		<description><![CDATA[The overwhelming majority of all professional programming is about solving a large number of simple problems. The intellectually challenging problems are rare and in many situations solving a problem with a complicated but efficient solution is hard to justify. It is much cheaper to buy a faster computer with more memory to run your program [...]]]></description>
			<content:encoded><![CDATA[<p>The overwhelming majority of all professional programming is about solving a large number of simple problems. The intellectually challenging problems are rare and in many situations solving a problem with a complicated but efficient solution is hard to justify. It is much cheaper to buy a faster computer with more memory to run your program than it is to write a smarter program that uses less resources.</p>
<p>However, I really enjoy the challenge of writing efficient and elegant code that solve a particular problem, so sometimes when I get a bit of free time and want to do something relaxing I spend time writing solutions to small programming puzzles that I run across in my day job working for <a href="http://voxbiblia.com">Voxbiblia</a>.</p>
<p>The next post contains the solution to one such puzzle and the solution I just wrote. It might be interesting to some.</p>
]]></content:encoded>
			<wfw:commentRss>http://noa.resare.com/2009/09/optimizations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
