<?xml version='1.0' encoding='UTF-8' ?>
<feed xmlns='http://www.w3.org/2005/Atom'>
<title type='text'>KHJK</title>
<subtitle type='text'>Karl Hans Janke Kollaborativ</subtitle>
<id>http://www.khjk.org/</id>
<link href='http://www.khjk.org/' rel='alternate' type='text/html'/>
<link href='http://www.khjk.org/atom.xml' rel='self' type='application/atom+xml'/>
<author>
    <name>Sven Moritz Hallberg</name>
    <email>sm@khjk.org</email>
</author>
<updated>2010-02-12T18:50:00Z</updated>
<entry>
<title type='html'>Really simple distributed DNS</title>
<link href='http://www.khjk.org/log/2010/feb/rsddns.html'/>
<id>http://www.khjk.org/log/2010/feb/rsddns.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2010-02-12T18:50:00Z</updated>
<content type='html'>
&#60;p /&#62;There is a project, originating within the CCC, to link hackerspaces around the
world into a &#60;a href=&#34;http://media.ccc.de/foo/bar&#34;&#62;common VPN&#60;/a
&#62;.
Within this,
we would like to provide DNS; probably under a fake TLD, say &#60;span style=&#34;font-family:monospace&#34;&#62;.hack&#60;/span
&#62;.
&#60;p /&#62;Well, you know, we like decentralized systems&#38;#8230;
&#60;p /&#62;This post is about a prototype distributed system that,
give or take a few design iterations,
could actually be useful for decentralized name resolution.
&#60;p /&#62;Desirable properties:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;require only a minimum of local knowledge to configure the peers
&#60;/li
&#62;&#60;li&#62;distributed self-organization instead of central administration
&#60;/li
&#62;&#60;li&#62;avoid central points of failure
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;At the conceptual level, the network's &#60;em&#62;nodes&#60;/em
&#62;
represent any kind of communications medium.
I.e. anything that messages can be sent &#60;q&#62;onto&#60;/q
&#62; with the expectation
that all entities also &#60;q&#62;on the medium&#60;/q
&#62; will receive them.
&#60;p /&#62;Concretely there are two kinds of nodes:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Low-level network links.
IP-port pairs or other kinds of peer-to-peer addresses.
The idea is that these could also be Ethernet interfaces and thelike.
They carry no global name and are thought of as only locally known to a
specific station (host system).
&#60;/li
&#62;&#60;li&#62;&#60;q&#62;Mesh&#60;/q
&#62; nodes (for lack of a better name).
Formed by connecting stations in a mesh.
Has a globally unique ID.
For each node it participates in,
a station knows how to reach its neighbors within that node.
Any other node known to the station can act as the medium
for these connections.
Putting other meshes in this list effectively creates a tunnel.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;Messages also come in two flavors:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Payload. In the example code, these consist of a single &#60;span style=&#34;font-family:monospace&#34;&#62;String&#60;/span
&#62; containing
a message to be printed.
&#60;/li
&#62;&#60;li&#62;Tunnel messages.
When a message is sent onto a mesh node,
the station wraps it with the ID of that node before sending it
down the neighbor links (i.e. nodes).
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;When a station receives a message on a low-level link,
it starts &#60;q&#62;unwrapping&#60;/q
&#62; the tunneling headers
and propagates the message to any neighbors it has within the
respective nodes.
&#60;p /&#62;Given the above behaviour, it is possible to construct networks of
nodes interconnected in rather arbitrary ways. For the purpose of emulating
DNS, and probably many others, it is useful to think of nodes as either
representing hosts or being formed by joining (&#60;q&#62;federating&#60;/q
&#62;) a number of
subnodes. The federations would correspond to DNS domains.
&#60;p /&#62;Determining how each station's table of node neighbor connections should look
is left as an exercise to the reader. ;)
The attached code contains a number of such &#60;em&#62;context tables&#60;/em
&#62;
for an example network, pictured below.
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;log/2010/feb/rsddns-proto.medium.jpg&#34;&#62;&#60;img src=&#34;log/2010/feb/rsddns-proto.klein.jpg&#34; alt=&#34;rsddns-proto.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;Diagram of a hypothetical network showing
federations (circles with green labels), hosts (squares), and
low-level links (lines).
Shown in red is the path of an example message
from within a hamburg subnode to a host in cologne.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;To watch the example in action, run each of the following commands in a
separate terminal:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ ghc rsddns-proto.hs -e 'mainloop 2001 laptop_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2002 daddel_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2003 router_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2004 turing_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2005 b1_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2006 b2_ct'
$ ghc rsddns-proto.hs -e 'mainloop 2007 k1_ct'
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Then inject the test message from an interpreter prompt:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ ghci rsddns-proto.hs
&#38;#62; s &#38;#60;- testsocket 5555
&#38;#62; testsend s &#34;127.0.0.1&#34; 2001 $ Mtun &#34;pesco.hh.ccc.hack&#34; $
      Mtun &#34;hh.ccc.hack&#34; $ Mtun &#34;ccc.hack&#34; $ Mtun &#34;koeln.ccc.hack&#34; $
      Mtun &#34;k1.koeln.ccc.hack&#34; $ Mstr &#34;hello world!&#34;
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Note the DNS-like hierarchical node IDs and how the nesting of messages
reflects the path through this hierarchy from &#60;span style=&#34;font-family:monospace&#34;&#62;pesco.hh.ccc.hack&#60;/span
&#62; to
&#60;span style=&#34;font-family:monospace&#34;&#62;k1.koeln.ccc.hack&#60;/span
&#62;.
&#60;p /&#62;There is a 1s delay after each line of output so it's easy to watch the messages
propagate.
The destination node only prints out the message in this instance, but it would
be trivial to include a return address and have it send back a
useful answer (e.g. the station's IP address).
&#60;p /&#62;You will see a lot of backscatter of messages.
This is due to the fact that the stations only perform a minimal check
whether they have already seen a particular message.
A proper implementation should avoid more.
&#60;p /&#62;&#60;b&#62;Appendix:&#60;/b
&#62;
 implementation prototype (Haskell):
&#60;a href=&#34;log/2010/feb/rsddns-proto.hs&#34;&#62;rsddns-proto.hs&#60;/a
&#62;
</content>
</entry>
<entry>
<title type='html'>Closed algebraic data types for Ruby</title>
<link href='http://www.khjk.org/log/2009/dec/ruby-adt.html'/>
<id>http://www.khjk.org/log/2009/dec/ruby-adt.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-12-11T13:37:00Z</updated>
<content type='html'>
&#60;p /&#62;Today, a little detour off the path to world domination.
Or maybe not; who knows.
&#60;p /&#62;I use &#60;a href=&#34;http://www.rubylang.org&#34;&#62;Ruby&#60;/a
&#62; at work
and I guess it's pointless to deny that I regularly
cringe at it for its &#60;em&#62;rude&#60;/em
&#62; failure at being just like Haskell.
Even though, I have to admit that it is rather flexible:
&#60;p /&#62;Algebraic data types in Haskell look like this:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;data Expr = Lam String Expr
          | App Expr Expr
          | Var String
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;It says that there are three kinds of expressions, called lambdas,
applications and variables, consisting of the given data fields
(e.g. a variable name and a body for lambdas, and so on).
Operations on such a type are defined by giving cases for each
kind of argument.
&#60;p /&#62;Off the shelf, there are no algebraic data types in Ruby.
Google didn't find anything, so I thought about it.
With the right plumbing, it's possible to do the following:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;class Expr
    ctor :lam, :var =&#38;#62; String, :body =&#38;#62; Expr
    ctor :app, :op =&#38;#62; Expr, :arg =&#38;#62; Expr
    ctor :var, :name =&#38;#62; String
end
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Not much longer and only slightly uglier! \o/
And with type checks, too.
&#60;p /&#62;The result is a class &#60;span style=&#34;font-family:monospace&#34;&#62;Expr&#60;/span
&#62; with three singleton constructor methods,
similar to the usual &#60;span style=&#34;font-family:monospace&#34;&#62;new&#60;/span
&#62;.
Each takes a single hash as its argument that assigns
values to the relevant fields.
All fields must be provided and their types must match the definition.
For example:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;id = Expr.lam(:var=&#38;#62;&#34;x&#34;, :body=&#38;#62;Expr.var(:name=&#38;#62;&#34;x&#34;))   # (\x.x)
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The &#60;span style=&#34;font-family:monospace&#34;&#62;ctor&#60;/span
&#62; method defines accessors to the constructor &#60;q&#62;tag&#60;/q
&#62; and each field.
A typical method definition on &#60;span style=&#34;font-family:monospace&#34;&#62;Expr&#60;/span
&#62;s would look like this:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;class Expr
    def eval(env={})
        if is_lam? then
            self
        elsif is_app? then
            f = op.eval(env)
            if f.is_lam?
                x = arg.eval(env)
                f.body.subst(f.var,x).eval
            else
                raise &#34;operator is not a function&#34;
            end
        elsif is_var? then
            env[name] || self
        end
    end
end
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Obviously, this is in contrast to the &#60;q&#62;object-oriented&#60;/q
&#62; way of distributing
operations on different kinds of things over respective (sub-) class
definitions.
Aside from being a matter of taste,
I prefer the above in this case,
because the definitions of evaluation for different kinds of expressions have
to fit together.
Their interaction is easier to view when the definition is in one place instead
of scattered across multiple classes.
&#60;p /&#62;To the plumbing:
Everything happens in &#60;span style=&#34;font-family:monospace&#34;&#62;ctor&#60;/span
&#62;, which is singleton method of &#60;span style=&#34;font-family:monospace&#34;&#62;Class&#60;/span
&#62;,
so it can be used in a class definition
(similar to convenience methods like &#60;span style=&#34;font-family:monospace&#34;&#62;attr_reader&#60;/span
&#62; and such).
The routine looks like this:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;class Class
    def ctor(ctorname, argtypes)
        # add singleton constructor method to self
        self_ = (class &#38;#60;&#38;#60; self; self; end)
        self_.module_eval do
            define_method(ctorname) do |argvalues|
                x = allocate

                # check argument types
                # [...]

                # fill instance variables of x
                x.instance_eval do
                    @ctor = ctorname
                    @args = argvalues
                end

                x
            end # constructor
        end # singleton methods of our ADT

        # inspection methods
        attr_reader :ctor
        attr_reader :args

        # define accessors and convenience methods on self
        # [...]
    end
end
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The full source code along with a complete lambda evaluator is in the
file attached below.
The evaluator also supports destructive in-place updates,
effectively yielding graph reduction.
&#60;p /&#62;Note: The copyright notice states
&#60;a href=&#34;http://opensource.org/licenses/isc-license.txt&#34;&#62;&#60;q&#62;isc license&#60;/q
&#62;&#60;/a
&#62;,
meaning do whatever you want as long as you leave the notice intact.
&#60;p /&#62;&#60;b&#62;Attachment:&#60;/b
&#62;
 &#60;a href=&#34;log/2009/dec/adt.rb&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;adt.rb&#60;/span
&#62;&#60;/a
&#62;
&#60;p /&#62;&#60;b&#62;PS.&#60;/b
&#62;
 Happy Birthday, you know who you are.
</content>
</entry>
<entry>
<title type='html'>Do &#60;em&#62;you&#60;/em
&#62; have a MUA ready to follow &#60;span style=&#34;font-family:monospace&#34;&#62;mailto:&#60;/span
&#62; links?</title>
<link href='http://www.khjk.org/log/2009/nov/email-comments.html'/>
<id>http://www.khjk.org/log/2009/nov/email-comments.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-11-22T11:22:00Z</updated>
<content type='html'>
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/stift-uhr.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/stift-uhr.klein.jpg&#34; alt=&#34;stift-uhr.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Just wondering, because if you do, you can now leave comments on posts on this
site. Of course, my solution is unusual and specifically excludes HTML forms,
CGI scripts or any other webcrap. Honestly though, I think it's kind of elegant
like this:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Follow the &#60;q&#62;reply&#60;/q
&#62; link on one of the blog entries. Or copy and paste
the address. It has the form:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;comment-&#38;#60;path.to.post&#38;#62;@khjk.org
&#60;/code
&#62;&#60;/pre
&#62;&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Put your comment text into the body of the email. The subject is
ignored. You can use email-style &#60;q&#62;ASCII art markup&#60;/q
&#62; like &#60;span style=&#34;font-family:monospace&#34;&#62;*asterisks*&#60;/span
&#62;
for &#60;strong&#62;bold face&#60;/strong
&#62;, &#60;span style=&#34;font-family:monospace&#34;&#62;/slashes/&#60;/span
&#62; for &#60;em&#62;emphasis&#60;/em
&#62;, &#60;span style=&#34;font-family:monospace&#34;&#62;&#38;#62;&#60;/span
&#62;-style quotes, etc.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;A &#60;q&#62;little&#60;/q
&#62; &#60;a href=&#34;submitcomment.hs&#34;&#62;script&#60;/a
&#62; (actually, it got partly
hideous with all the &#60;a href=&#34;Email.hs&#34;&#62;email parsing&#60;/a
&#62; and whatnot)
receives the message via &#60;span style=&#34;font-family:monospace&#34;&#62;procmail&#60;/span
&#62; and decides to forward it for
moderation.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;I read the email like all the others (i.e: on my phone or whatever)
and if it's ok simply forward it back to the comment address. This
leaves my PGP signature on it.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;The little script does a few checks, recognizes the signature, and
stores the included message somewhere the &#60;a href=&#34;generate.hs&#34;&#62;site generator&#60;/a
&#62;
will find it.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;The site's HTML content is regenerated. If the &#60;span style=&#34;font-family:monospace&#34;&#62;From:&#60;/span
&#62; address
contained a name, that will be shown as the comment's author.
To remain anonymous, leave out your name (that's a slogan).
The address itself will never be revealed, of course.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;To post a reaction to a comment, I can reply to the OP's email, leaving
the comment address in &#60;span style=&#34;font-family:monospace&#34;&#62;Cc&#60;/span
&#62; (group reply).
&#60;p /&#62;In theory, the reply will already carry my signature and go directly
through the little script and appear as a comment on the site.
Unfortunately, this doesn't work in the current reality: Little
script needs the signature over the &#60;em&#62;entire&#60;/em
&#62; comment message (a
mime part of type &#60;span style=&#34;font-family:monospace&#34;&#62;message/rfc822&#60;/span
&#62;) to check the metadata for
consistency.
This is the case with forwarded messages,
but in a &#60;q&#62;regular&#60;/q
&#62; signed email, the signature only extends
across the &#60;span style=&#34;font-family:monospace&#34;&#62;text/plain&#60;/span
&#62; body.
&#60;p /&#62;So, if you want to do me a great favour, add an option to &#60;span style=&#34;font-family:monospace&#34;&#62;mutt&#60;/span
&#62; to
sign headers by using a &#60;span style=&#34;font-family:monospace&#34;&#62;message/rfc822&#60;/span
&#62; part:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;multipart/signed
    application/pgp-signature
    message/rfc822              -- includes headers AND body
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;&#60;em&#62;vs.&#60;/em
&#62;
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;multipart/signed
    application/pgp-signature
    text/plain                  -- only the message body :(
&#60;/code
&#62;&#60;/pre
&#62;&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Obviously, this game can go on through the entire thread of discussion
by just keeping the comment address in &#60;span style=&#34;font-family:monospace&#34;&#62;Cc&#60;/span
&#62; at all times.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;Anyway, with this yak now out of the way, back to important work. I've got a
few crazy ideas on which I'd very much appreciate feedback. Stay tuned.
</content>
</entry>
<entry>
<title type='html'>&#60;q&#62;telnetd an&#60;/q
&#62;</title>
<link href='http://www.khjk.org/log/2009/nov/telnetd.html'/>
<id>http://www.khjk.org/log/2009/nov/telnetd.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-11-01T00:00:00Z</updated>
<content type='html'>
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/kabelstraenge.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/kabelstraenge.klein.jpg&#34; alt=&#34;kabelstraenge.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;random foto: elaborately wired contraption (Technikmuseum Berlin)
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;I bought a Fritz!Box 7050 for cheap on eBay the other day.
It's a home router with built-in DSL modem, WLAN, and a POTS interface.
The reason I got it was that I'd like to ditch my aging, bulky, and
increasingly flaky ISDN phone in favour of using my mobile as a VOIP
handset for the Fritz!Box.
&#60;p /&#62;The device itself works very well, including my old phone, WLAN, and ADSL2+.
Unfortunately, as it turns out, the 7050 doesn't support VOIP handsets in the
stock firmware.
Google says, however, that you can actually run full-blown Asterisk on it.
Now, the reason for this post is my amusement over the method to get a shell on
the thing. Connect a phone, dial &#60;span style=&#34;font-family:monospace&#34;&#62;#96*7*&#60;/span
&#62;, et voila:
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;img src=&#34;img/2009/telnetd.klein.jpg&#34; alt=&#34;telnetd.klein.jpg&#34; /&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;Well, thanks! :)
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;A lot of frustrating &#60;em&#62;frickel&#60;/em
&#62; later, however, I've decided to give up for today.
I got Asterisk to run, dialing out from the PC via X-Lite actually worked,
but SIP registration fails on my Nokia E51, for unknown reasons.
&#60;p /&#62;For later reference, here's the list of the relevant links I found:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;&#60;a href=&#34;http://www.avm.de/de/Service/Service-Portale/Service-Portal/index.php?portal=FRITZ!Box_Fon_WLAN_7050&#34;&#62;http://www.avm.de/de/Service/Service-Portale/Service-Portal/index.php?portal=FRITZ!Box_Fon_WLAN_7050&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://www.juerging.net/projekte/Fritzbox-Asterisk/&#34;&#62;http://www.juerging.net/projekte/Fritzbox-Asterisk/&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://www.wehavemorefun.de/fritzbox/Hilfsprogramme_/_Tipps_&#38;#38;_Tricks#Asterisk_.28capi_intern.2Bextern.2Fiax2.2Fsip.29_auf_der_7050_.28ohne_Firmware-Mod.29&#34;&#62;http://www.wehavemorefun.de/fritzbox/Hilfsprogramme_/_Tipps_&#38;#38;_Tricks#Asterisk_.28capi_intern.2Bextern.2Fiax2.2Fsip.29_auf_der_7050_.28ohne_Firmware-Mod.29&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://www.asterisk-kompakt.de/artikel/45-asterisk-auf-fritzbox-phone.html&#34;&#62;http://www.asterisk-kompakt.de/artikel/45-asterisk-auf-fritzbox-phone.html&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://www.spblinux.de/fbox/info/asterisk/sip.conf.default&#34;&#62;http://www.spblinux.de/fbox/info/asterisk/sip.conf.default&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://nuxx.net/blog/2008/10/24/sip-via-asterisk-on-nokia-e51/&#34;&#62;http://nuxx.net/blog/2008/10/24/sip-via-asterisk-on-nokia-e51/&#60;/a
&#62;
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;http://www.ip-phone-forum.de/showthread.php?t=161714&#34;&#62;http://www.ip-phone-forum.de/showthread.php?t=161714&#60;/a
&#62;
&#60;/li
&#62;&#60;/ul
&#62;</content>
</entry>
<entry>
<title type='html'>Semiautomating Accountancy for Fun and Profit</title>
<link href='http://www.khjk.org/log/2009/oct/ledger.html'/>
<id>http://www.khjk.org/log/2009/oct/ledger.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-10-05T21:40:00Z</updated>
<content type='html'>
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/z23.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/z23.klein.jpg&#34; alt=&#34;z23.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;Zuse Z23 @ Technikmuseum Berlin &#38;#8212; &#60;em&#62;definately a semiautomatic accountant!&#60;/em
&#62;
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Is anybody out there using &#60;a href=&#34;http://wiki.github.com/jwiegley/ledger&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;ledger&#60;/span
&#62;&#60;/a
&#62;
or one of its &#60;a href=&#34;http://wiki.github.com/jwiegley/ledger/ports&#34;&#62;siblings&#60;/a
&#62; for their
personal accounting? If not, take this as a recommendation. It's a command-line
tool to generate various financial reports from a plain text listing of account
transactions. If you happen to have access to your bank transactions in csv
format, the script I wrote yesterday may be useful to you. It reads
comma-separated values from stdin and writes &#60;span style=&#34;font-family:monospace&#34;&#62;ledger&#60;/span
&#62; entries to stdout.
&#60;p /&#62;If you're German, your likely way to get csv files from your bank is via HBCI.
The right tool for the job appears to be
&#60;a href=&#34;http://www.aquamaniac.de/sites/aqbanking/&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;aqbanking&#60;/span
&#62;&#60;/a
&#62;. Hooking it up to the
bank is a bit of fiddling, so I'll reproduce the quick how-to here. This is
assuming authentication via PIN/TAN:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ aqhbci-tool4 adduser -t pintan --context=1 --hbciversion=300 \
        -b BLZ -u NUTZERKENNUNG -c KUNDENKENNUNG \
        -s SERVERURL \
        -N &#34;Real Name&#34;
$ aqhbci-tool4 getsysid -c KUNDENKENNUNG
$ aqhbci-tool4 getaccounts -c KUNDENKENNUNG
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;To fetch transactions from all accounts and print them in csv format:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;$ aqbanking-cli request -c /tmp/foo.ctx --transactions
$ aqbanking-cli listtrans -c /tmp/foo.ctx
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The &#60;span style=&#34;font-family:monospace&#34;&#62;csv2ledger&#60;/span
&#62; script is tailored to the default output format of the above.
I also have made a small shell script to drive these two commands and pipe the
result through the converter. It accepts an optional date range to which to
restrict the output.
&#60;p /&#62;&#60;b&#62;Appendix:&#60;/b
&#62;
&#60;ul&#62;&#60;li&#62;&#60;a href=&#34;log/2009/oct/csv2ledger.hs&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;csv2ledger.hs&#60;/span
&#62;&#60;/a
&#62; converts comma-separated values
to &#60;span style=&#34;font-family:monospace&#34;&#62;ledger&#60;/span
&#62; entries. &#60;br /&#62;There are a few configuration settings at the top of the script to tell it
about account names and the input format.
&#60;/li
&#62;&#60;li&#62;&#60;a href=&#34;log/2009/oct/buchungen.sh&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;buchungen.sh&#60;/span
&#62;&#60;/a
&#62; fetches transactions with
&#60;span style=&#34;font-family:monospace&#34;&#62;aqbanking&#60;/span
&#62; and shows them via &#60;span style=&#34;font-family:monospace&#34;&#62;csv2ledger&#60;/span
&#62;. &#60;br /&#62; Usage:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;buchungen.sh [startdate [enddate]]  # date format: YYYYMMDD
&#60;/code
&#62;&#60;/pre
&#62;&#60;/li
&#62;&#60;/ul
&#62;</content>
</entry>
<entry>
<title type='html'>The &#60;q&#62;Skein&#60;/q
&#62; hash function in 256 lines of C</title>
<link href='http://www.khjk.org/log/2009/sep/skein512.html'/>
<id>http://www.khjk.org/log/2009/sep/skein512.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-09-26T15:40:00Z</updated>
<content type='html'>
&#60;p /&#62;&#60;b&#62;Note:&#60;/b
&#62;
 I'm going to switch this thing over to English now, because I expect
to ask some non-Germans for feedback in the future. I might also translate some
old posts.
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/teichufer.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/teichufer.klein.jpg&#34; alt=&#34;teichufer.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;A view across the lake at HAR 2009 towards the CCC's geodesic party tent. Me
and friends camped just about outside the right edge of the picture.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;So here's the latest installment of my exploits into the forbidden realm of
implementing cryptographic primitives.
&#60;p /&#62;After building my little crypto chat experiment last month, one thing sorely
missing was message authentication (from &#60;span style=&#34;font-family:monospace&#34;&#62;p2p.c&#60;/span
&#62;):
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;printf(&#34;receiving packets on port %d\n&#34;, LOCALPORT);
printf(&#34;CAUTION: Message senders can be spoofed.\n&#34;);
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;The obvious solution to this problem are message authentication codes,
particularly because the diffie-hellman setup already yields shared secrets
between any two parties. A typical way to construct MACs is to take a
cryptographic hash function and compute its value over a combination of the
message and the secret (the standard construction of this kind is called HMAC).
So I set out to find a nice little hash function which could be easily and
elegantly implemented. Unfortunately, the obvious candidates didn't quite
satisfy me. I kept looking and eventually ended up with the promising
description of &#60;a href=&#34;http://www.skein-hash.info/&#34;&#62;Skein&#60;/a
&#62;:
&#60;p /&#62;&#60;blockquote&#62;Skein is a new family of cryptographic hash functions. Its design combines
speed, security, simplicity, and a great deal of flexibility in a modular
package that is easy to analyze.
&#60;/blockquote
&#62;&#60;p /&#62;Without much regret, I commited the next step up on the ladder of serious
crimes in the construction of crypto systems: I set out to use an unproven
algorithm. Hooray! &#38;#62;:)
&#60;p /&#62;Incidentally, one very nice feature of Skein is that it already offers a
mechanism to turn it into a keyed hash function. If my understanding is
correct, this is essentially due to the fact that Skein is actually derived
from a block cipher (actually called &#60;q&#62;Threefish&#60;/q
&#62; ;)). I have yet to implement
this MAC mode, but it's basically a detail once the rest is set up.
&#60;p /&#62;As of yesterday, the code finally produces the correct output on the official
one-byte test vector. Feel free to try it on the longer ones. What took me so
long? First, there was &#60;a href=&#34;http://www.har2009.nl&#34;&#62;HAR&#60;/a
&#62;. I had it pretty much
complete at that point, except for one of those nasty segfault bugs. When I
took a good hard look at things again this week, it turned out to be an
overlong &#60;span style=&#34;font-family:monospace&#34;&#62;memset()&#60;/span
&#62; corrupting my stack. God, I love those! ;)
&#60;p /&#62;There are some limitations to the code at this point:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Only the 512-bit variant of Skein is implemented. However, the &#60;span style=&#34;font-family:monospace&#34;&#62;threefish&#60;/span
&#62;
function is already generalized to any block size, so the others should be
easy to add.
&#60;/li
&#62;&#60;li&#62;The supplied &#60;span style=&#34;font-family:monospace&#34;&#62;main&#60;/span
&#62; routine simply hashes the test vector, prints the result
and exits. Anything more useful basically needs to wait for the next point:
&#60;/li
&#62;&#60;li&#62;No support for directly slurping input from &#60;span style=&#34;font-family:monospace&#34;&#62;FILE&#60;/span
&#62; handles. I've already
prepared the code for it, just need to write the actual routine.
&#60;/li
&#62;&#60;li&#62;As stated above, no MAC mode, yet. None of the other fancy stuff
(personalization, tree hashing, &#38;#8230;) either. Just plain and simple hashing.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;b&#62;Appendix:&#60;/b
&#62;
 &#60;a href=&#34;log/2009/sep/skein.c&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;skein.c&#60;/span
&#62;&#60;/a
&#62;
</content>
</entry>
<entry>
<title type='html'>Peer-to-Peer Kryptochat</title>
<link href='http://www.khjk.org/log/2009/aug/p2p.html'/>
<id>http://www.khjk.org/log/2009/aug/p2p.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-08-07T21:19:00Z</updated>
<content type='html'>
&#60;p /&#62;Meine Kryptoexperimente schreiten weiter fort. Am vergangenen Wochenende habe
ich mir meinen &#60;a href=&#34;log/2009/jul/elgamal.html&#34;&#62;ElGamal&#60;/a
&#62;-Code nochmal vorgenommen und
daraus ein kleines anonymes Peer-to-Peer-Netz gebaut. Man erwarte jetzt bitte
nichts weltbewegendes, es handelt sich nach wie vor um kaum mehr als eine
Fallstudie zu Montgomery-Multiplikation. Allerdings eine, ueber die man
verschluesselte Kurznachrichten austauschen kann. ;)
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/serviette.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/serviette.klein.jpg&#34; alt=&#34;serviette.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;&#60;em&#62;That's the way we do it.&#60;/em
&#62;
Meine Serviette aus der Hotelbar in Berlin vor ein paar Wochen.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Das ganze ist ein einfaches Broadcast-Netz: Jeder Knoten sendet eingehende
Nachrichten, die nicht an ihn selbst addressiert sind, weiter an jeden seiner
Nachbarn. Wenn er eine Nachricht schonmal gesehen hat, wird sie verworfen.
Erwaehnenswert:
&#60;p /&#62;&#60;ul&#62;&#60;li&#62;Jeder Knoten im Netzwerk besitzt ein Schluesselpaar. Der public key
ist seine Netzwerkadresse.
&#60;/li
&#62;&#60;li&#62;Pakete bestehen komplett aus Chiffretext, keine weiteren Header. Der
Empfaenger erkennt seine Nachrichten daran, dass er sie erfolgreich
entschluesseln kann.
&#60;/li
&#62;&#60;li&#62;Eigentlich klar, aber trotzdem toll: Das Netz ist unabhaengig vom Internet.
Ich habe es fuer UDP implementiert, aber das ist willkuerlich. Amateurfunk,
rohes Ethernet oder carrier pidgeons gingen auch. Insbesondere ist mir NAT
egal, sobald ich das Ding fuer meinen OpenWRT-Router kompiliert habe.
&#60;/li
&#62;&#60;li&#62;Es gibt vorerst keine Nachrichtenauthentisierung. D.h. keine Sicherheit,
dass Nachrichten wirklich vom angebenen Absender stammen.
&#60;/li
&#62;&#60;/ul
&#62;&#60;p /&#62;&#60;b&#62; Anlage:&#60;/b
&#62;
&#60;a href=&#34;log/2009/aug/p2p.tgz&#34;&#62;Source&#60;/a
&#62; (jetzt auch Linux-kompatibel),
&#60;a href=&#34;log/2009/aug/README.p2p&#34;&#62;README&#60;/a
&#62;
&#60;p /&#62;&#60;b&#62; PS.&#60;/b
&#62;
Neues Cleartext-Feature: Stichpunktlisten.
</content>
</entry>
<entry>
<title type='html'>Night of Work. Das ElGamal-Kryptosystem</title>
<link href='http://www.khjk.org/log/2009/jul/elgamal.html'/>
<id>http://www.khjk.org/log/2009/jul/elgamal.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-07-25T02:40:00Z</updated>
<content type='html'>
&#60;p /&#62;Heute war &#60;q&#62;night of work&#60;/q
&#62; beim CCCHH. Aus der
&#60;a href=&#34;http://wiki.hamburg.ccc.de/index.php/Night_of_work&#34;&#62;Beschreibung&#60;/a
&#62;:
&#60;p /&#62;&#60;blockquote&#62;Im wesentlichen sagt der Name es: Die Idee ist, eine Nacht lang gemeinsam
fokussierte Arbyte zu betreiben. Natuerlich soll der Austausch nicht zu kurz
kommen, sonst wuerde man es nicht gemeinsam machen. Am Ende haben idealerweise
alle selbst was geschafft und von anderen noch was neues mitgenommen.
&#60;/blockquote
&#62;&#60;p /&#62;Wir haben das zum ersten Mal gemacht und ich muss sagen, es hat sehr schoen geklappt.
Eine angenehme Runde von Leuten hat sich eingefunden,
um die Nacht durch diverse persoenliche Projekte voranzutreiben.
Diensteschreiben fuer das &#60;a href=&#34;http://en.wikipedia.org/wiki/Capture_the_flag#Computer_security&#34;&#62;CTF&#60;/a
&#62;
auf der &#60;a href=&#34;http://www.har2009.org/&#34;&#62;HAR&#60;/a
&#62;, Software-updates der Club-Webseiten,
Compilerbau, P2P-Netzwerktechnik, etc.
&#60;p /&#62;Nach der Vorarbeit aus dem vorangegangenen Eintrag gab es fuer mich einen
naheliegenden naechsten Schritt:
Diffie-Hellman zu ElGamal-Verschluesselung umstricken.
Das &#60;a href=&#34;log/2009/jul/dh/elgamal.c&#34;&#62;Beispielprogramm&#60;/a
&#62; ist sehr einfach,
an den Ecken rau und hat seinen Zweck perfekt erfuellt.
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/elgamal.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/elgamal.klein.jpg&#34; alt=&#34;elgamal.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Es war erstaunlich cool,
die Zahlen per cut&#38;#38;paste hin- und herzuschieben,
zu wissen, was sie bedeuten
und am Ende den gewuenschten Klartext zu sehen. :)
&#60;p /&#62;Das ganze ist im Vergleich zu &#60;q&#62;richtigen&#60;/q
&#62; Implementationen insofern vereinfacht,
als dass Modulus und Erzeuger festgeschrieben sind.
Diese werden im allgemeinen als Teil des public keys erzeugt.
Sofern mein Wissen mich nicht truegt, haengt die unmittelbare Sicherheit des
Systems davon aber nicht ab.
</content>
</entry>
<entry>
<title type='html'>Diffie-Hellman in 200 Zeilen C</title>
<link href='http://www.khjk.org/log/2009/jul/dh.html'/>
<id>http://www.khjk.org/log/2009/jul/dh.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-07-24T21:30:00Z</updated>
<content type='html'>
&#60;p /&#62;Das hat man dann davon. Und dabei hatte alles so harmlos angefangen.
Ich stand auf dieser Einweihungsparty herum und trank Bier.
Nebenbei betrieb ich die wundervollste Sache neben Sex: Nerdtalk.
Krypto-Nerdtalk, mind you.
&#60;a href=&#34;http://kbfr.livejournal.com/&#34;&#62;kb&#60;/a
&#62; of &#60;a href=&#34;http://www.farb-rausch.de/&#34;&#62;farbrausch&#60;/a
&#62;
fame wollte Datenpakete authentisieren. Hauptsache billig (zu coden).
Spieleindustrie &#60;strong&#62;shrug&#60;/strong
&#62;.
Nach kurzer Eroerterung sagte ich irgendwann:
&#60;p /&#62;&#60;blockquote&#62;&#60;q&#62;Da kannst Du doch (wait for it&#38;#8230;) &#60;em&#62;einfach&#60;/em
&#62; Diffie-Hellman machen.&#60;/q
&#62;
&#60;/blockquote
&#62;&#60;p /&#62;Ah, die Dummheit des Theoretikers.
&#60;a href=&#34;http://de.wikipedia.org/wiki/Diffie-Hellman&#34;&#62;Diffie-Hellman&#60;/a
&#62;
ist natuerlich wirklich ganz einfach. Fuenf Zeilen.
Man braucht nur Exponentiation. Kein Problem. Dafuer gibts ja
&#60;a href=&#34;http://de.wikipedia.org/wiki/Bin%C3%A4re_Exponentiation&#34;&#62;Square-and-Multiply&#60;/a
&#62;.
Easy peasy, solange man multiplizieren kann. &#38;#8230;Modulo grosser Primzahlen.
&#60;p /&#62;Ach&#38;#8230; aeh. Tja, zu diesem Zeitpunkt war schon eine Nacht vergangen.
The damage had been done. Erstens kann man sowas nicht auf sich sitzen lassen.
Zweitens, und das ist noch gravierender, brennt einem unerbittlich die Frage
unter den Naegeln, ob es nicht &#60;em&#62;tatsaechlich&#60;/em
&#62; ganz einfach ist, wenn man nur
weiss, wie's geht. Die gute Nachricht vorweg: Isses. :)
&#60;p /&#62;Der Haken ist offensichtlich: Herauszufinden &#60;em&#62;wie&#60;/em
&#62; es geht, ist nicht so
leicht. Einfach normal multiplizieren und danach durch den Modulus dividieren
ist in der Groessenordnung von ein paar tausend Bits naemlich
schon schmerzhaft. Immerhin besteht die Exponentiation
ihrerseits aus ein paar tausend Multiplikationen. Ausserdem ist Division
grosser Zahlen nicht mehr huebsch, sondern ein ziemlicher Schandfleck im bis
dahin sehr uebersichtlichen, wenn auch noch hypothetischen, angeblich einfachen
Code.
&#60;p /&#62;Die elegante Antwort lautet
&#60;a href=&#34;http://en.wikipedia.org/wiki/Montgomery_reduction&#34;&#62;Montgomery-Multiplikation&#60;/a
&#62;.
Ein wundervoller mathematischer Trick,
mithilfe dessen man sich um die ganzen Divisionen druecken kann.
Leider kann mein Blogmarkup noch keine Formeln,
deswegen verzichte ich vorerst auf die sexy Details
und poste nur den &#60;a href=&#34;log/2009/jul/dh&#34;&#62;Code&#60;/a
&#62;.
Der ganze Spass passiert dort in &#60;a href=&#34;log/2009/jul/dh/monty.c&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;monty.c&#60;/span
&#62;&#60;/a
&#62;.
Ein Beispiel-Programm zum Ausprobieren per cut&#38;#38;paste ist
&#60;a href=&#34;log/2009/jul/dh/dh.c&#34;&#62;&#60;span style=&#34;font-family:monospace&#34;&#62;dh.c&#60;/span
&#62;&#60;/a
&#62;.
Dort findet sich auch der Diffie-Hellman-Fuenfzeiler:
&#60;p /&#62;&#60;pre&#62;&#60;code&#62;/* diffie-hellman: */
mrand(n, N, a);                   /* generate random number modulo N */
monty_exp(n, N, R, gaR, gR, a);   /* compute g^a */
send(n, gaR);                     /* send g^a to bob */
recv(n, gbR);                     /* receive g^b from bob */
monty_exp(n, N, R, gabR, gbR, a); /* compute (g^a)^b = g^(ab) */
&#60;/code
&#62;&#60;/pre
&#62;&#60;p /&#62;Easy peasy. Right? :-)
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;a href=&#34;img/2009/telegraphus.medium.jpg&#34;&#62;&#60;img src=&#34;img/2009/telegraphus.klein.jpg&#34; alt=&#34;telegraphus.klein.jpg&#34; /&#62;&#60;/a
&#62;&#60;/div
&#62;&#60;div class=&#34;floatcaption&#34;&#62;Kein Blogpost ohne Bild.
Aufgenommen im &#60;a href=&#34;http://www.sdtb.de/&#34;&#62;Deutschen Technikmuseum&#60;/a
&#62; in Berlin.
Er hat einen Telegraphenmasten in der Hand
und der Adler haelt Blitze in den Krallen.
&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;&#60;b&#62;PS.&#60;/b
&#62;
 Der Code laeuft unter BSD. Linux-Fanbois und Verwandte muessen selber
wissen, wo sie ihre Zufallszahlen herkriegen. ;)
&#60;p /&#62;&#60;b&#62;Update.&#60;/b
&#62;
 Da ich &#60;em&#62;irgendwo&#60;/em
&#62; ja auch noch eins habe, ist der Code
jetzt doch Linux-kompatibel.
</content>
</entry>
<entry>
<title type='html'>Behoerdenkennzahl</title>
<link href='http://www.khjk.org/log/2009/may/1337.html'/>
<id>http://www.khjk.org/log/2009/may/1337.html</id>
<author>
    <name>pesco</name>
    <email>pesco@khjk.org</email>
</author>
<updated>2009-05-13T13:23:00Z</updated>
<content type='html'>
&#60;p /&#62;&#60;div class=&#34;float&#34; style=&#34;float:left&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;div class=&#34;float&#34; style=&#34;float:none&#34;&#62;&#60;div class=&#34;floatcontent&#34;&#62;&#60;img src=&#34;img/2009/1337.klein.png&#34; alt=&#34;1337.klein.png&#34; /&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;/div
&#62;&#60;p /&#62;Bundesbehoerdlich beurkundet: Ich bin offiziell leet.
</content>
</entry>
</feed>
