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

@dxbjavid dxbjavid commented Jun 2, 2026

Copy link
Copy Markdown

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.

@dxbjavid

dxbjavid commented Jun 21, 2026

Copy link
Copy Markdown
Author

Hi team,

Just checking in on this PR. I wanted to see if there are any updates regarding review or next steps.

Please let me know if any further changes are required from my side.

Thank you!

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