Hi:
I've been tasked with coming up with a Java implementation of Twofish. We've
been using the optimized C version of Twofish. I've downloaded the Cryptix
Java version and it encrypts and decrypts fine (with itself). However, the
encrypted output is different between the C and Java versions. Attempting to
decrypt something encrypted with the Java version using the C version
produces garbage. We need to be able to encrypt/decrypt bidirectionally
between the two implementations.
I'm definitely not a cryptology expert and prefer not trying to completely
reimplement the C into Java.
Has anyone else run into this issue?
Thanks,
Rick
Roedy Green - 30 Oct 2003 00:19 GMT
>I'm definitely not a cryptology expert and prefer not trying to completely
>reimplement the C into Java.
the things to look for are places where:
1. endianness matters.
2. that fact that bytes are signed matters.
Perhaps the solution is to see if someone else has a Java twofish
implementation.
--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Michael Amling - 30 Oct 2003 03:32 GMT
> I've been tasked with coming up with a Java implementation of Twofish. We've
> been using the optimized C version of Twofish. I've downloaded the Cryptix
[quoted text clipped - 6 lines]
> I'm definitely not a cryptology expert and prefer not trying to completely
> reimplement the C into Java.
Are you testing using ECB mode?
To check for endian issues, use endian-independent key and plaintext,
such as all zeros or all ones, and see if the resulting ciphertexts
differ only by an endian permutation.
There are test vectors for TwoFish, from its submission as an AES
candidate. If you look around enough at http://www.nist.gov/aes, you
should be able to find them. Both implementations should be able to
match the test cases.
--Mike Amling