rust-random / getrandom

A small cross-platform library for retrieving random data from (operating) system source
Apache License 2.0
264 stars 166 forks source link

rdrand: Avoid assuming `usize` is the native word size. #442

Closed briansmith closed 1 month ago

briansmith commented 1 month ago

x86_64-unknown-linux-gnux32 has target_pointer_width = "32", so usize is 32-bits. In this case, we were throwing away half of each RDRAND result and doing twice as many RDRAND invocations as necessary. This wasn't noticed because as silently does a lossy conversion.

Add x86_64-unknown-linux-gnux32 to the test matrix. [Edit: Ubuntu doesn't support x32 by policy; see https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1994516/comments/21].

briansmith commented 1 month ago

I removed the CI changes because we don't have a way of testing this on an x32 target, and the code built and ran correctly (but suboptimally) before and after this change on all these targets