Mailing List Archive

Twofish patch
Hi,

I propose a little but usefull patch to twofish.c.

The patch allow gcc to compile twofish.c with -O2 without having to
wait forever and a day. As a side effect, this patch also reduce the
text size by more than 100 KB (!).
It's rather simple : I moved all CALC_SB() and CALC_SB256() macro
calls to a loop and put all hex arguments into a static table.
Here's the result with gcc 2.7.2.3 on my 486/100 :

1) un-patched, compiled with -DTEST but without any optimization level :

compilation time : 52.7s
text size : 137.5 KB
execution time : 22.9s

2) patched, compiled with -O2 -DTEST :

compilation time : 58.5s
text size : 33.0 KB
execution time : 15.7s

--
RĂ©mi <rguyom@mail.dotcom.fr> | Don't waste your computer's time :
PGP-encrypt anything important: | http://www.distributed.net/
www.gnupg.org - KeyID:0x85BD8B1B | http://www.distributed.net/cores/
Re: Twofish patch [ In reply to ]
Remi Guyomarch <rguyom@mail.dotcom.fr> writes:

> It's rather simple : I moved all CALC_SB() and CALC_SB256() macro
> calls to a loop and put all hex arguments into a static table.

I think this is a Good Thing and I implemented it this morning.
Because it only affects the key setup, the actual encryption time does
not change at all. The size and type of the cache has a lot of
consequenses when optimizing some code and we should delegate that
task to the compiler which knows more about different CPUs.

Thanks.

Werner

> execution time : 15.7s

10.6 on a P-100 with -O3


BTW, Twofish will be the default cipher in the next version. But while
implementing that, we noticed some inconsistencies in rfc2440 regarding
128 bit blocksize ciphers. We have to agree on an interpretation
before Twofish is actually used. Hope this happens soon.


--
Werner Koch at guug.de www.gnupg.org keyid 621CC013
Re: Twofish patch [ In reply to ]
> BTW, Twofish will be the default cipher in the next version.

Ugh. Why not pick one of the ciphers that performed better at the
AES conference?
Re: Twofish patch [ In reply to ]
Anonymous <nobody@replay.com> writes:

> > BTW, Twofish will be the default cipher in the next version.
>
> Ugh. Why not pick one of the ciphers that performed better at the
> AES conference?

I considered to use Magenta because it is a German Product :-))

RC6 is patented and frankly I don't like to support RSA Inc.

TWofish is really one of the fastest. IF you have attended that
AES conference in Rome, you probaly know that everyone gets a
perfomrance rank lits which makes his cipher look best.

We agreed at the OpenPGP WG to add Twofish as an optional cipher.
PGP 6 or whatever will use Twofish too.


--
Werner Koch at guug.de www.gnupg.org keyid 621CC013