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 type check for Arrays, stop function from producing silent and deadly result #5

Open
3nsoft opened this issue Nov 18, 2013 · 1 comment

Comments

@3nsoft
Copy link

3nsoft commented Nov 18, 2013

Use case, which brought me, a normal human developer, to js-scrypt based signin, where any passphrase would open any account.
Context:

  1. js-scrypt must be run in web-worker, for all usability concerns
  2. passing of arrays between worker and main is done by no-copy transfer of buffer
  3. it is really easy to forget that bytes are passed as buffers, rather than typed array
    Problem:
    when scrypt.crypto_scrypt(pass, salt, n, r, p, 32) is given buffers for pass and salt, it silently produced always the same output. That is, all new users get the same key, and any account may be opened with any passphrase, with no indication of a problem.
    Argument:
    Yes, javascript is lousy with types. Yes, this is a developer's problem. Yes, check is messy (5 lines, including throwing up).
    But, as Daniel J. Bernstein pointed in his talk, developers of crypto libraries should stop blaming users of these libraries (e.g. developers) for reproducing "obvious" mistakes.
    Actually, adding something like
    if (pass.BYTES_PER_ELEMENT !== 1) { throw new TypeError("bla"); }
    shall be enough. Same line for salt.
@louismullie
Copy link

+1

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

No branches or pull requests

1 participant