antelle / argon2-browser

Argon2 library compiled for browser runtime
https://antelle.net/argon2-browser
MIT License
367 stars 79 forks source link

Verify function could/probably should detect Argon2 type (i, d, id) #18

Closed Nantris closed 5 years ago

Nantris commented 5 years ago

Thanks again @antelle for all your hard work! I noticed two issues trying out the verify functionality and the solutions aren't immediately apparent to me or I'd submit a PR.

  1. Argon2 type should be determined from encoded string when available, I think. I'm not sure what's going on in the lines above where the params are being encoded, but it doesn't seem to cover getting the Argon2 type. Without passing the type manually you'll get: Uncaught (in promise) {message: "Decoding failed", code: -32}

Is the best way to correct this to simply search the front of the string for the type identifier? (argon2i, argon2d, argon2id)

2. When I do pass a type into the params for verify I get undefined as the result. The point where things seem to be going awry as best as I can tell is here, where nothing is being returned https://github.com/antelle/argon2-browser/blob/master/lib/argon2.js#L155

Not sure what I did wrong the first time, but this definitely works now.

antelle commented 5 years ago

Hm, good question, I don't know why it's implemented this way in the library. I've changed the js, so that it reads types from params.encoded, unless it's specified explicitly.

Nantris commented 5 years ago

Awesome!