Skip to content

Bad source of random and bugs #3

@Sc00bz

Description

@Sc00bz

I found these problems with the code:

  • Math.random is a bad source of random.
  • rawprng() can return NaN.
  • random.done() can cause use after free type bugs.
  • In random.random(), Number.MAX_VALUE is not what you think it is.
  • random(), random.range(), random.intBetween(), and random.random() are not evenly distributed.
  • This is clearly not a CSPRNG. You should remove the "UHEPRNG" code and replace it with Node's crypto.randomBytes and if a seed is given just do something like key = H(seed); counter = 0; for seeding, key = H(key + "-" + entropy) for adding entropy, and key = H(key + counter++); return H(key); for random data. H() being a cryptographic hash function like SHA256 or a KDF like HKDF. This will be vastly superior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions