Skip to content

Performance of SP800SecureRandom reseed #2255

@winfriedgerlach

Description

@winfriedgerlach

We used SP800SecureRandom in our application with "security strength" 256 (=default) , a personalization string of 32 bytes (=256 bits) and SHA256Digest, nonce null, predictionResistant=true for build hash.

Our application used this secure random to generate 12 random bytes for every request received. We observed that from that point on, our CPU workload was completely dominated by SP800SecureRandom.nextBytes():

Image

This doesn't change (significantly) when setting security strength to 128.
For a comparison, here a similar application situation using JDK's built-in SecureRandom.getInstance("DRBG", "SUN"):

Image (all tests performed on Windows, JDK 25, BC 1.83, modern Meteor Lake laptop)

When using SP800SecureRandom again, but setting predictionResistant=false, the hotspot also reduces to 0%!
Is the reseeding really supposed to be soooo slow? If so, it may possibly be worth a warning in the JavaDoc...

Metadata

Metadata

Assignees

No one assigned

    Labels

    support requestCommunity assistance requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions