I am intrigued by what is arguably a pointless problem.
Looking at the tiny encryption algorithm aka XXTEA it seemed easy enough to implement in Erlang. I have an implementation (attached with source and all references inside the module) which encodes and decodes successfully... BUT the cipher text doesn't match the test vectors...
What makes this pointless is that I should "just make it a NIF" etc. But it's likely that I am misunderstanding some aspect of either Erlang or C, however I am confounded as to what that problem is... why does the attached implementation not generate the same ciphertext as in the test vectors from the C implementation? Can anyone spot my error?
This looks as endianness problem. You have to keep in-mind that binaries is big-endian by default, which contrasts with C memory. You have to be very careful of C algorithms mapping.
I've made a small fixes to int32list_xxx routines (see bold text):
> I am intrigued by what is arguably a pointless problem.
> Looking at the tiny encryption algorithm aka XXTEA it seemed easy enough to implement in Erlang. I have an implementation (attached with source and all references inside the module) which encodes and decodes successfully... BUT the cipher text doesn't match the test vectors...
> What makes this pointless is that I should "just make it a NIF" etc. But it's likely that I am misunderstanding some aspect of either Erlang or C, however I am confounded as to what that problem is... why does the attached implementation not generate the same ciphertext as in the test vectors from the C implementation? Can anyone spot my error?
On Sat, Nov 17, 2012 at 6:02 PM, Steve Davis <steven.charles.da...@gmail.com
> wrote:
> I am intrigued by what is arguably a pointless problem.
Not really
> Looking at the tiny encryption algorithm aka XXTEA it seemed easy enough
> to implement in Erlang. I have an implementation (attached with source and
> all references inside the module) which encodes and decodes successfully...
> BUT the cipher text doesn't match the test vectors...
I had exactly the same problem with tea a few years ago ...
I'd really like to see:
a) an algebraic spec
b) reference implementations in more than one language that I can reproduce
I'm more interested in inter-operability than performance - (think client
in Javascript
backend in C / Erlang) - so compliance with the spec is more important than
performance.
(which is why I like RSA implemented in erlang bignums - no chance of
backdoors in the code)
> What makes this pointless is that I should "just make it a NIF" etc. But
> it's likely that I am misunderstanding some aspect of either Erlang or C,
> however I am confounded as to what that problem is... why does the attached
> implementation not generate the same ciphertext as in the test vectors from
> the C implementation? Can anyone spot my error?
Before you ask this you might ask "can the test vectors be reproduced in
any other
language/implementation than the reference implementation?"
> This looks as endianness problem. You have to keep in-mind that binaries is big-endian by default, which contrasts with C memory. You have to be very careful of C algorithms mapping.
> I've made a small fixes to int32list_xxx routines (see bold text):
>> I am intrigued by what is arguably a pointless problem.
>> Looking at the tiny encryption algorithm aka XXTEA it seemed easy enough to implement in Erlang. I have an implementation (attached with source and all references inside the module) which encodes and decodes successfully... BUT the cipher text doesn't match the test vectors...
>> What makes this pointless is that I should "just make it a NIF" etc. But it's likely that I am misunderstanding some aspect of either Erlang or C, however I am confounded as to what that problem is... why does the attached implementation not generate the same ciphertext as in the test vectors from the C implementation? Can anyone spot my error?
> This looks as endianness problem. You have to keep in-mind that binaries is big-endian by default, which contrasts with C memory. You have to be very careful of C algorithms mapping.
> I've made a small fixes to int32list_xxx routines (see bold text):
>> I am intrigued by what is arguably a pointless problem.
>> Looking at the tiny encryption algorithm aka XXTEA it seemed easy enough to implement in Erlang. I have an implementation (attached with source and all references inside the module) which encodes and decodes successfully... BUT the cipher text doesn't match the test vectors...
>> What makes this pointless is that I should "just make it a NIF" etc. But it's likely that I am misunderstanding some aspect of either Erlang or C, however I am confounded as to what that problem is... why does the attached implementation not generate the same ciphertext as in the test vectors from the C implementation? Can anyone spot my error?