str4d/rage

Invalid scrypt work factor calculation on system with bad SystemTime precision

Rileran opened this issue · 0 comments

Environment

  • OS: Windows 7 SP1 (other OS may be affected)
  • rage version: 0.9.2

What were you trying to do

Basic encryption with age::Encryptor::with_user_passphrase(...).wrap_output(...).

What happened

thread 'main' panicked at ...\age-0.9.2\src\scrypt.rs:94:73:
...
log_n < 64: InvalidParams

The root cause is the calculation of the scrypt work factor which is based on the duration of one scrypt encryption.
On my system, this calculation is sometime faster than the precision of SystemTime, which result in a duration of 0ns, and a work factor of 63 (which is way too large).

I will open a PR shortly after to provide a fix for this issue.