DHParametersGenerator (Bouncy Castle Library 1.85 API Specification)
Date: 2026-07-12

org.bouncycastle.crypto.generators

## Class DHParametersGenerator

- java.lang.Object
- - org.bouncycastle.crypto.generators.DHParametersGenerator

-     public class DHParametersGenerator
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DHParametersGenerator()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `DHParameters` | `generateParameters()` which generates the p and g values from the given parameters, returning the DHParameters object.
    `void` | `init(int size, int certainty, java.security.SecureRandom random)` Initialise the parameters generator.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### DHParametersGenerator

          public DHParametersGenerator()

  - ### Method Detail

    - #### init

          public void init(int size,
                           int certainty,
                           java.security.SecureRandom random)

      Initialise the parameters generator.
      Parameters:
        `size` - bit length for the prime p
        `certainty` - level of certainty for the prime number tests
        `random` - a source of randomness

    - #### generateParameters

          public DHParameters generateParameters()

      which generates the p and g values from the given parameters, returning the DHParameters object.

      Note: can take a while...

      Returns:
        a generated Diffie-Hellman parameters object.