antelle / argon2-browser

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

Argon2i hashLen not working. #2

Closed gpalomar closed 7 years ago

gpalomar commented 7 years ago

Hi @antelle !

I'm trying to call your argon2-browser implementation in a Chrome PNaCl environment.

I'm doing this:

listener.addEventListener('load', function(e) {
    moduleEl.postMessage(
        {
            pass: key,
            salt: salt,
            type: 1,//argon2.ArgonType.Argon2i,
            time: 3, // the number of iterations
            mem: 4096, // used memory, in KiB
            hashLen: 64,
            parallelism: 1
        }
    );
}, true);

But when the listener receives the message, the hash length it's always 128. What I'm doing wrong? Is there a bug on the .pexe file?

(If I use AMD it works as expected).

Thanks!

antelle commented 7 years ago

Hi, I don't really support PNaCl, it's provided as a reference, to compare the performance. Feel free to modify and adopt, but I don't think it's necessary, when we have WASM. However, on my demo page, different hash lengths work, hashes are the same.

gpalomar commented 7 years ago

Hi again, My fault. When I put the hashLen I was thinking about the hex result, not the binary array buffer that is converted to hex. Maybe it's a bit confusing, but closing issue.

Thanks for your time ;)

ancms2600 commented 5 years ago

notice also that argon2 prefixes the salt to the hash, and that its encoded in base64. if you decode just the hash portion (appears after the last dollar ($)) then you should find the hashLen matches the byte count exactly. also note sometimes if you don't explicitly specify a salt value, one is generated randomly for you.