Again when the US authorities categorised robust encryption as “munitions,” RSA public key cryptography was unlawful to export. In 1995, Adam Again protested this by making a terse, obfuscated implementation of RSA in Perl code and used it as an e-mail signature.
The code was additionally printed on T-shirts. The shirt was categorised as munitions as a result of it contained supply code for robust encryption. Extra on the shirt right here.
This was the code:
#!/bin/perl -s-- -export-a-crypto-system-sig -RSA-3-lines-PERL $m=unpack(H.$w,$m." "x$w),$_=`echo "16do$w 2+4Oi0$d*-^1[d2%Sa 2/d0My initial intention was to unpack the code, explaining each piece in detail. I don’t have the time or patience for that, and I imagine many readers don’t either. For more of a blow-by-blow explanation, see this commentary from 1995.
dc
In the middle of the code is
echo ... | dcThis is the most dense and most important part of the code. Perl calls the
dccalculator to do the arbitrary precision arithmetic that RSA encryption requires.I’ve written about
bcseveral times.bc(“basic calculator”) was a originally a more user-friendly wrapper around the reverse-Polishdc(“desktop calculator”).dcis still part of every Unix and Unix-like system, but I imaginebcis far more popular.The important feature of
dcfor this post is that it is stack-based, meaning that users would push data and commands on to the stack and pop results off the stack. A sequence of commands that might be understandable when interactively usingdcwould look cryptic in a transcript. This is part of what makes the code so cryptic.I’ll parse just a tiny bit of the
dccode to give a flavor of what it does. The first four characters16doinstructsdcto push 16 on to the stack, duplicate it, and set the output radix to 16, i.e. these four characters telldcto work in hexadecimal.Believe it or not, the
dccode is computingmk mod n
using fast exponentiation, which is the key step in the RSA algorithm.
Textbook RSA
Note that Adam Back’s code is computing what we would now call textbook RSA, not RSA as it has been refined over the years and is currently implemented.
Related posts
