Advertisement
Guest User

Untitled

a guest
Dec 27th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. I cribbed the public domain TEA source from wikipedia ( http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm ), looks like this -
  2.  
  3. <code>
  4. void encrypt (uint32_t* v, uint32_t* k) {
  5. uint32_t v0=v[0], v1=v[1], sum=0, i; /* set up */
  6. uint32_t delta=0x9e3779b9; /* a key schedule constant */
  7. uint32_t k0=k[0], k1=k[1], k2=k[2], k3=k[3]; /* cache key */
  8. for (i=0; i < 32; i++) { /* basic cycle start */
  9. sum += delta;
  10. v0 += ((v1<<4) + k0) ^ (v1 + sum) ^ ((v1>>5) + k1);
  11. v1 += ((v0<<4) + k2) ^ (v0 + sum) ^ ((v0>>5) + k3);
  12. } /* end cycle */
  13. v[0]=v0; v[1]=v1;
  14. }
  15. </code>
  16.  
  17. 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.
  18.  
  19. 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