I feel like I'm completely missing something there. The quarter-round proceeds as follows:

b ^= (a + d) <<< 7;
c ^= (b + a) <<< 9;
d ^= (c + b) <<< 13;
a ^= (d + c) <<< 18;

So at each step, we're adding words a, b, c, d together. And at the end of 20 quarter-rounds, we add the current state matrix with the previous state.

What I don't see is how overflows are handled. If two words added exceed the value of a word, does it simply wrap around?

  • 1
    $\begingroup$ The additions are modulo $2^{32}$. $\endgroup$
    – fgrieu
    Feb 5 '19 at 22:57

Per the Salsa20 page -

Each modification involves xor'ing into one word a rotated version of the sum of two other words modulo 232.

Adding two uint32s and ignoring the carry / overflow is equivalent to performing addition modulo 232.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.