fix(hashing): bad SHAKE length crashes the page #32

Open
opened 2026-10-28 21:52:10 +00:00 by flopana · 0 comments
Owner

Part of #30

Branch: feature/improve-hashing

Bugs

  1. HashingGenComp.tsx passes Number(e.target.value) from the SHAKE length inputs to shake128 and shake256. Inputs -1 and 1.5 throw "outputLen" expected integer >= 0 during render. src/ has no ErrorBoundary, so the page goes blank. Input 999999999 asks for about 1 GB and freezes the tab.
  2. Each keystroke in a SHAKE field hashes the input again with all 19 algorithms. A large file makes the tab slow.

Verification: the review agent reproduced the throw in node. The freeze and the slow rehash are not measured.

Red tests

  • SHAKE length -1, 1.5 and 999999999 do not crash and do not freeze.
  • A keystroke in a SHAKE field does not hash the input again with the other algorithms.

Fix

  • Clamp the length to a whole number in 1..MAX_SHAKE_LEN. Add min and max to the input.
  • Use useMemo keyed on the input bytes and the two lengths.
Part of #30 Branch: `feature/improve-hashing` ## Bugs 1. `HashingGenComp.tsx` passes `Number(e.target.value)` from the SHAKE length inputs to `shake128` and `shake256`. Inputs `-1` and `1.5` throw `"outputLen" expected integer >= 0` during render. `src/` has no ErrorBoundary, so the page goes blank. Input `999999999` asks for about 1 GB and freezes the tab. 2. Each keystroke in a SHAKE field hashes the input again with all 19 algorithms. A large file makes the tab slow. Verification: the review agent reproduced the throw in node. The freeze and the slow rehash are not measured. ## Red tests - SHAKE length `-1`, `1.5` and `999999999` do not crash and do not freeze. - A keystroke in a SHAKE field does not hash the input again with the other algorithms. ## Fix - Clamp the length to a whole number in 1..`MAX_SHAKE_LEN`. Add `min` and `max` to the input. - Use `useMemo` keyed on the input bytes and the two lengths.
Sign in to join this conversation.
No description provided.