StableLib / stablelib

A stable library of useful TypeScript/JavaScript code
https://www.stablelib.com
Other
175 stars 36 forks source link

salsaXOR() unnecessarily increments the counter in steps of 2 #5

Closed palant closed 7 years ago

palant commented 7 years ago

Here the loop implementing Salsa20 algorithm looks like this:

 for (let i = 0; i < 8; i += 2) {

Given that the loop index isn't used, there are really only four loop iterations and the following code is equivalent:

for (let i = 0; i < 4; i++) {

Unless I'm somehow mistaken, that should be simplified to avoid confusion (it definitely confused me).

dchest commented 7 years ago

It's like this just to show that the number of Salsa20 rounds is 8. Pretty typical of Salsa20 implementations, e.g. see https://cr.yp.to/salsa20.html (20 rounds, each iteration is 2 rounds).