[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[ITAR/POLITICS] rsa-in-3-lines-of-perl just shrunk!!




Sorry to contribute to the simply awesome noise to signal ratio here
lately (hopefully the subject tag should help those not interested in
politics), but...

[if you don't know what I'm talking about, see

	http://www.dcs.ex.ac.uk/~aba/rsa/ 

for a combined perl hack and ITAR violation]

Due mainly to a couple of insights donated by someone who was
introduced to the code via a friends `munition' T-shirt... he started
the ball rolling again...

it shrunk from:

#!/bin/perl -s-- -export-a-crypto-system-sig -RSA-3-lines-PERL
$m=unpack(H.$w,$m."\0"x$w),$_=`echo "16do$w 2+4Oi0$d*-^1[d2%Sa
2/d0<X+d*La1=z\U$n%0]SX$k"[$m*]\EszlXx++p|dc`,s/^.|\W//g,print
pack('H*',$_)while read(STDIN,$m,($w=2*$d-1+length($n)&~1)/2)

to:

#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

(Actually it's not quite as impressive as it might look at first
glance because the old version included the comment "-export-a-
crypto-system-sig -RSA-3-lines-PERL", so the new one should really be
compared against:

#!/bin/perl -s
$m=unpack(H.$w,$m."\0"x$w),$_=`echo "16do$w 2+4Oi0$d*-^1[d2%Sa
2/d0<X+d*La1=z\U$n%0]SX$k"[$m*]\EszlXx++p|dc`,s/^.|\W//g,print
pack('H*',$_)while read(STDIN,$m,($w=2*$d-1+length($n)&~1)/2)

)

but it's still a whole 31 bytes shorter, and it now really is in 3
lines of perl rather than cheating and not counting the #!/bin/perl
line.  (Several people took me to task on that one).

I won't consume list bandwidth describing exactly how the new one
works, and the arcane perl and dc hackery that went into it, as I have
described it all in excruciating detail on:

	http://www.dcs.ex.ac.uk/~aba/rsa/story.html

I really wasn't expecting to see it shortened any further.

There goes all those T-shirts, outdated, my sincere apologies to
Richard White also, whose tattoo was featured in the April issue of
Wired (at least the UK edition, the US one too?),

Oh yeah, and if you can see any ways to shorten it, please tell me!
(Perl5 specifics not allowed, there is already a shorter p5 specific
version but it's got to be as portable as possible).

Adam

ps I now have a reasonable stock of T-shirts again after the prolonged
hiatus of my printer, who finally delivered the 2nd batch.
--
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)