Repository navigation
Conversation
In workloads/argon2-wasm/benchmark.js (added in WebKit#47), Benchmark.randomSalt() allocates a 12-byte buffer with malloc and writes three random 32-bit words into Module.HEAPU32: Module.HEAPU32[result.ptr + i] = Math.floor(Math.random() * (2 ** 32)); result.ptr is a byte offset in Wasm linear memory, while Module.HEAPU32 is a Uint32Array indexed by 4-byte words. Without dividing result.ptr by 4, the writes land at byte offset 4 * result.ptr instead of inside the allocated buffer, so argon2_hash() reads uninitialized heap memory as the salt. argon2_verify() still passes because argon2_hash() encodes whatever salt bytes it read into the output string, and argon2_verify() extracts the salt from that string. Divide the byte offset by 4 ((result.ptr >> 2) + i) when indexing Module.HEAPU32. Argon2id's work per hash (t=3, m=1 MiB, p=1) does not depend on the salt bytes, and scores do not change significantly.
✅ Deploy Preview for webkit-jetstream-preview ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In
workloads/argon2-wasm/benchmark.js(added in #47),Benchmark.randomSalt()allocates a 12-byte buffer withmallocand writes three random 32-bit words intoModule.HEAPU32:result.ptris a byte offset in Wasm linear memory, whileModule.HEAPU32is aUint32Arrayindexed by 4-byte words. Without dividingresult.ptrby 4, the writes land at byte offset4 * result.ptrinstead of inside the allocated buffer, soargon2_hash()reads uninitialized heap memory as the salt.argon2_verify()still passes becauseargon2_hash()encodes whatever salt bytes it read into the output string, andargon2_verify()extracts the salt from that string.Divide the byte offset by 4 (
(result.ptr >> 2) + i) when indexingModule.HEAPU32.Scores: Argon2id's work per hash (
t=3,m=1 MiB,p=1) does not depend on the salt bytes, and scores do not change significantly (<shell> cli.js --test=argon2-wasmon a Linux x64 workstation, 16 interleaved rounds):maind8(V8 14.6.82)jsc(JSC 306270)