Skip to content

crypto: fix randomInt bias

@puzpuzpuz found this issue in https://github.com/nodejs/node/pull/35110#discussion_r551034065. Opening a separate PR to make sure this fix can land and be backported quickly, if necessary.

This patch also changes a few comments and definitions to make the necessary conditions easier to understand.

The actual effect of this bias is small, but the mere existence of bias defeats the purpose of this function.

Refs: https://github.com/nodejs/node/pull/34600

Merge request reports

Loading