dchest / scrypt-async-js

Fast "async" scrypt implementation in JavaScript
http://dchest.github.io/scrypt-async-js/
BSD 2-Clause "Simplified" License
139 stars 26 forks source link

Scrypt throws error if the key.length > 64 when the data structure does not support .push #42

Closed TotalTechGeek closed 6 years ago

TotalTechGeek commented 6 years ago

Steps to reproduce -

1) Create a key greater than length 64. 2) Use a structure that doesn't support .push (like Buffer), ex.

let key = Buffer.from('0'.repeat(65))

3) run scrypt


The short term fix is to convert to a structure that does support the .push operation.

I will be submitting a PR

TotalTechGeek commented 6 years ago

You're in good company though: ricmoo's scrypt-js also has the same bug.

dchest commented 6 years ago

You're right, thanks! The error is here: https://github.com/dchest/scrypt-async-js/blob/master/scrypt-async.js#L157 SHA256(password) expects password to be an Array, but if password is Uint8Array, it obviously won't work. I'll wait for you PR.