Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add range check for 'N' parameter #141

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

chrisveness
Copy link

Colin Percival has a 'sanity check' that 0 < logN < 256: see
https://github.com/Tarsnap/scrypt/blob/484dc1fb/lib/scryptenc/scryptenc.c#L206.

Since the 'N' parameter in node-scrypt is the canonical scrypt logN, it is
useful to trap the canonical 'N' being passed as early as possible, and to
report it more helpfully than 'error computing derived key'.

Following this commit, if a call is erroneously made to
scrypt.kdf('abc', { N: 65536, r: 8, p: 1 })
it will immediately have a RangeError thrown.

Colin Percival has a 'sanity check' that 0 < logN < 256: see
https://github.com/Tarsnap/scrypt/blob/484dc1fb/lib/scryptenc/scryptenc.c#L206.

Since the 'N' parameter in node-scrypt is the canonical scrypt logN, it is
useful to trap the canonical 'N' being passed as early as possible, and to
report it more helpfully than 'error computing derived key'.

Following this commit, if a call is erroneously made to
    scrypt.kdf('abc', { N: 65536, r: 8, p: 1 })
it will immediately have a RangeError thrown.
@chrisveness
Copy link
Author

Addresses #128 Error on relatively large iteration counts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant