-3

I am looking for a implementation of Twofish without using the large tables, without precomputing the round keys.

I need a clean code example showing all that in the mathematical/bitwise way. I mean I want to understand the operations. Most examples are too complex for me due a lot of functions and work done regard of things like testing the number and version of compiler, the machine architecture etc. I need it as clean as possible. I just can't deal with all the extra work done in examples because I am not a C programmer. I can read it if its simple, but I'm not a C coder. Like the AES code examples in the official reference.

Maybe I need some pseudo code example.

yhw42
  • 3,334
  • 2
  • 27
  • 24
mimini
  • 19
  • 2

1 Answers1

0

Try the pedagogical reference implementation. It's the first implementation on the Twofish web site. Hint: use an IDE with a good debugger. Getting some code to compile should be a skill you should have to do cryptography, at least for code that is not too dependent on other libraries.

Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
  • Thank you! I did a good google search before asking and get that code example, but exactly that one is very hard for me to understand. – mimini Aug 07 '13 at 03:44
  • @mimini Well, one other way to do it is to implement the algorithm directly in your favorite language. I did this for Skein, which contains the Threefish cipher as underlying Pseudo Random Permutation. The big problem with that is that you won't see where you go wrong if you compare it with the test vectors. To get around this, print out the state within the reference implementation by adding copious logging. Note that I got it work by just looking at the paper. I send the test vectors for the second version to the Skein team before they were finished fixing their bug :) – Maarten Bodewes Aug 07 '13 at 10:37
  • WOW! You must be a good coder! I am good only in NASM. I just desperate with all that higher level languages. And I don't like at all OOP. I still use OOP in ASM, calling and reusing code, but I don't like it the way people use it with classes, attributes etc in higher level languages. Weird, no? ASM coder that cant manage C and higher hihi BTW, I will try to use a debugger somehow. Thanks! – mimini Aug 07 '13 at 13:01
  • I'll call myself a good coder when I can come up with an optimized unrolled loop implementation for a limited hardware platform that is impervious to side channel attacks :) – Maarten Bodewes Aug 07 '13 at 13:28
  • but optimizing is like painting. Da Vinci said art is never finished, only abandoned. It is hard for me to abandon code chunks optimized 90%, but I have to do so, an it is still hard for me to find that exact moment when it is enough to optimize, and have to go and program forward. 10 times faster is sometimes not enough optimized for good coders, but we have to just let it that way cuz it's still awesome that way and go forward. – mimini Aug 07 '13 at 13:51