DES encryption algorithm

Joshua Muskovitz joshm at taconic.net
Sun Jan 20 01:18:44 EST 2002


"Carey Evans" <careye at spamcop.net> wrote in message
news:878zatk8mv.fsf at psyche.dnsalias.org...
>  1. Function call in Python is relatively expensive, and there are a
>     lot of right shifts in DES.

Yep.  Luckily, my implementation wasn't used for particularly high traffic
situations, so performance wasn't an issue.

>  2. At least in the DES implementation I ported, all the right shifts
>     were by constant amounts, so I could expand them inline to
>     something like ((t >> 18) & 0x3fff).

You were probably very lucky to have started with a decent implementation.
Sadly, I was forced to port one which left *much* to be desired.  Many have
asked why I didn't just use a proper implementation.  This was because my
code had to interoperate with the previous version.  I wasn't convinced that
they had implemented DES properly, and the requirement that my version work
the same was higher than the requirement that it work *correctly*.  :-/

>  3. A good bit of the code was right-shifting 28-bit numbers, where
>     the top bit was always zero, so no change was needed.

I only used my rshift() function in places where I wasn't able to prove that
the value to be shifted was less than 2^31.  I also substantially removed
many of the function calls in the original implementation through
refactoring.  It actually performed quite well for what it needed to do.

--
# Joshua Muskovitz
# joshm at taconic.net
def lyyrs(sig): return '-'.join(sig.split()+["ly y'rs"])
lyyrs('Hire me!  I need the work!')




-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----



More information about the Python-list mailing list