# How to change TEA round count? [closed]

I cribbed the public domain TEA source from wikipedia ( http://en.wikipedia.org/wiki/Tiny_Encryption_Algorithm ), looks like this -

``````uint32_t v0=v, v1=v, sum=0, i;           /* set up */

uint32_t delta=0x9e3779b9;                     /* a key schedule constant */

uint32_t k0=k, k1=k, k2=k, k3=k;   /* 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 = v0;
v = v1;
}
``````

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; no dice. Then I thought to try very close, set it to 31 then 33, and neither worked.

Is the number of rounds in TEA required to be 32 for some reason? I cannot see why, but I am far from expert.

## closed as off-topic by Adi, Gilles, Xander, Steve, TildalWaveDec 27 '13 at 20:54

• This question does not appear to be about Information security within the scope defined in the help center.
If this question can be reworded to fit the rules in the help center, please edit the question.

• There's probably something else you didn't change that's still assuming 32 rounds are used and that's throwing decryption off. – Thomas Dec 27 '13 at 14:38
• This question appears to be off-topic. It's more suited at Crypto.SE. – Adi Dec 27 '13 at 15:00
• @Adnan feel free to move, not sure how or if I have privs. There sure are a lot of stack exchanges. – blah44 Dec 27 '13 at 15:08