DaGenix / rust-crypto

A (mostly) pure-Rust implementation of various cryptographic algorithms.
Apache License 2.0
1.39k stars 295 forks source link

Seeking in Salsa20/ChaCha #156

Open passcod opened 9 years ago

passcod commented 9 years ago

The wikipedia page states it is possible to "efficiently seek to any position in the output stream in constant time." This SO answer seems to indicate that the eSTREAM code uses an IV which contains both the nonce and the offset. The Salsa20 struct in rust-crypto has an offset field, but it is not accessible through normal functions (although I suppose one could initialise the struct oneself with a custom offset).

Am I missing something or is seeking not directly/easily possible when using this library?

DaGenix commented 9 years ago

Its not currently possible, although I believe that constructing a new Salsa20 struct with a different offset would work. I'd certainly be happy to accept a patch to add this functionality - no one has gotten around to doing it quite yet, though.

the8472 commented 7 years ago

Seeking is also very useful for parallel processing

the8472 commented 7 years ago

I've found that https://peterreid.github.io/chacha/chacha/index.html provides some desirable features: