DRBG SecureRandom Strength And Reseeding

Request a DRBG SecureRandom at 256-bit strength with prediction resistance and reseeding, then read back the algorithm, provider and a HexFormat token.

JavaSecurity Boundaries

Code

snippet
import java.security.DrbgParameters;
import java.security.SecureRandom;
import java.util.HexFormat;

public class DrbgConfig {

    public static void main(String[] args) throws Exception {
        // strength=256 的 DRBG:PR_AND_RESEED 同时开启预测抗性与重播种
        SecureRandom drbg = SecureRandom.getInstance("DRBG",
                DrbgParameters.instantiation(256,
                        DrbgParameters.Capability.PR_AND_RESEED,
                        "release-pipeline".getBytes()));

        System.out.println("algorithm = " + drbg.getAlgorithm());
        System.out.println("provider  = " + drbg.getProvider().getName());

        byte[] token = new byte[16];
        drbg.nextBytes(token);
        System.out.println("token     = " + HexFormat.of().formatHex(token));

        // 降低要求重开一个实例:strength 128 + 不做重播种
        SecureRandom light = SecureRandom.getInstance("DRBG",
                DrbgParameters.instantiation(128,
                        DrbgParameters.Capability.NONE, null));
        System.out.println("light algorithm = " + light.getAlgorithm());
    }
}

How it works

The working surface is the class DrbgConfig — everything else is wiring.

Caveats

  • No external surface — every behavior comes from the standard library.

Putting it to use

Output lines are prefixed (algorithm =, provider =, token =), making what each step changes easy to notice.

Core lines under the microscope

byte[] token = new byte[16];
drbg.nextBytes(token);

Interactive Tools for This Topic

FAQ

What does DRBG SecureRandom Strength And Reseeding print when run?
Execute the whole file; each printed line is prefixed with a label like `algorithm =`, `provider =`, `token =`.