Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mozilla.jss.crypto
Class PQGParams

    java.lang.Object
      |
      +--java.security.spec.DSAParameterSpec
            |
            +--org.mozilla.jss.crypto.PQGParams

All Implemented Interfaces:
  java.security.spec.AlgorithmParameterSpec, java.security.interfaces.DSAParams

public class PQGParams
extends java.security.spec.DSAParameterSpec

PQG parameters for DSA key generation, along with the seed, counter, and H values for verification.

This class has two main purposes: generating PQG parameters and verifying PQG parameters. To generate PQG parameters, call one of the static `generate` methods. They will return a new set of PQG paramters. To verify existing PQG parameters, create a new `PQGParams` object with the constructor and call `paramsAreValid` on the object.

It is necessary to call `CryptoManager.initialize` before using this class.

Constructor Summary
`PQGParams(java.math.BigInteger P, java.math.BigInteger Q, java.math.BigInteger G, java.math.BigInteger seed, int counter, java.math.BigInteger H)` Creates a PQGParams object from a set of pre-computed DSA parameters.

Method Summary
`static byte[]` | `BigIntegerToUnsignedByteArray(java.math.BigInteger big)` Produces an unsigned byte-array representation of a BigInteger.
`static PQGParams` | `generate(int keySize)` Generates P, Q, and G parameters for DSA key generation.
`static PQGParams` | `generate(int keySize, int seedBytes)` Generates P, Q, and G parameters for DSA key generation.
`int` | `getCounter()`
`java.math.BigInteger` | `getH()`
`java.math.BigInteger` | `getSeed()`
`boolean` | `paramsAreValid()` Verifies the PQG parameters using the seed, counter, and H values.

Methods inherited from class java.security.spec.DSAParameterSpec
`getG, getP, getQ`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### PQGParams

    public PQGParams(java.math.BigInteger P,
                     java.math.BigInteger Q,
                     java.math.BigInteger G,
                     java.math.BigInteger seed,
                     int counter,
                     java.math.BigInteger H)

  Creates a PQGParams object from a set of pre-computed DSA parameters.

Parameters:
  `P` - The DSA prime parameter.
  `Q` - The DSA sub-prime parameter.
  `G` - The DSA base parameter.
  `seed` - The Seed used to calculate P, Q, and G.
  `counter` - The Counter (C) used to calculate P, Q, and G.
  `H` - The H value used to generate P, Q, and G.

Method Detail

### generate

    public static PQGParams generate(int keySize)
                              throws java.security.InvalidParameterException,
                                     PQGParamGenException

  Generates P, Q, and G parameters for DSA key generation. Also provides the seed, counter, and H values for verification of the P, Q, and G. The parameters are generated and then verified before being returned. The length of the Seed will equal the length of P. It is necessary to call one of the `CryptoManager.initialize` functions before calling this method.

  Parameters:
    `keySize` - The size of P in bits. Keys generated by these P, Q, and G values will have this length. Valid key sizes are multiples of 64 in the closed interval [512,1024]. This also dictates the length of H and Seed.
  Returns:
    A new set of P, Q, and G parameters, along with the Seed, Counter, and H values used to generate them.
  Throws:
    `java.security.InvalidParameterException` - If the keySize is outside the bounds described by the DSA key pair generation algorithm.
    `PQGParamGenException` - If an error occurs during the generation process.
  See Also:
    `CryptoManager.initialize(java.lang.String)`

### generate

    public static PQGParams generate(int keySize,
                                     int seedBytes)
                              throws java.security.InvalidParameterException,
                                     PQGParamGenException

  Generates P, Q, and G parameters for DSA key generation. Also provides the seed, counter, and H values for verification of the P, Q, and G. The parameters are generated and then verified before being returned. It is necessary to call one of the `CryptoManager.initialize` functions before calling this method.

  Parameters:
    `keySize` - The size of P in bits. Keys generated by these P, Q, and G values will have this length. Valid key sizes are multiples of 64 in the closed interval [512,1024]. This also dictates the length of H.
    `seedBytes` - The number of bytes in the Seed value used to generate P, Q, and G. `seedBytes` must be from the closed interval [20,255].
  Returns:
    A new set of P, Q, and G parameters, along with the Seed, Counter, and H values used to generate them.
  Throws:
    `java.security.InvalidParameterException` - If the keySize or number of seed bytes is outside the bounds described by the DSA key pair generation algorithm.
    `PQGParamGenException` - If an error occurs during the generation process.
  See Also:
    `CryptoManager.initialize(java.lang.String)`

### BigIntegerToUnsignedByteArray

    public static byte[] BigIntegerToUnsignedByteArray(java.math.BigInteger big)

  Produces an unsigned byte-array representation of a BigInteger.

  BigInteger adds an extra sign bit to the beginning of its byte array representation. In some cases this will cause the size of the byte array to increase, which may be unacceptable for some applications. This function returns a minimal byte array representing the BigInteger without extra sign bits.

  Returns:
    An unsigned, big-endian byte array representation of a BigInteger.

### paramsAreValid

    public boolean paramsAreValid()

  Verifies the PQG parameters using the seed, counter, and H values.

  Returns:
    true if the parameters verified correctly, false if they did not verify.

### getSeed

    public java.math.BigInteger getSeed()

  Returns:
    The Seed used to generate P, Q, and G.

### getCounter

    public int getCounter()

  Returns:
    The Counter (C) used to generate P, Q, and G.

### getH

    public java.math.BigInteger getH()

  Returns:
    The H value used to generate P, Q, and G.

Overview | Package | Class | Tree | Deprecated | Index | Help
| JSS 3.3
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD