Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- I cribbed the public domain TEA source from wikipedia ( http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm ), looks like this -
- <code>
- void encrypt (uint32_t* v, uint32_t* k) {
- uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
- uint32_t delta=0x9e3779b9; /* a key schedule constant */
- uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
- for (i=0; i < 32; i++) { /* basic cycle start */
- sum += delta;
- v0 += ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
- v1 += ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
- } /* end cycle */
- v[0]=v0; v[1]=v1;
- }
- </code>
- It works fine, but I am trying to understand crypto a little more so I am tweaking and exploring. I would have thought that changing the number of rounds (32 in the example) would work great as long as the decrypt function changed to use the same number. However, I bumped it to 50 on each side and now my output does not match the initial plaintext. Thinking that may be too high, I tried 20. Also broken. Then I tried 31 and 33! Both broken.
- Is the number of rounds in TEA required to be 32 for some reason? I cannot see why, but I am far from expert.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement