Skip to content

widen r * p to u64 in scrypt params bounds check#908

Open
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:scrypt-params-rp-u64
Open

widen r * p to u64 in scrypt params bounds check#908
dxbjavid wants to merge 1 commit into
RustCrypto:masterfrom
dxbjavid:scrypt-params-rp-u64

Conversation

@dxbjavid
Copy link
Copy Markdown

@dxbjavid dxbjavid commented Jun 2, 2026

Noticed the final guard in Params::new computes r * p in u32, but both come from a parsed PHC hash string and the earlier checked_mul guards only bound the usize products. On 64-bit, r=65536 p=65536 reaches this line: the u32 multiply wraps to 0, so r * p >= 0x4000_0000 is false and scrypt accepts params it must reject (debug builds panic on the overflow instead). Widen both operands to u64 before the compare.

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

Successfully merging this pull request may close these issues.

1 participant