Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

gnu.java.security.key.dss
Class DSSKeyPairGenerator  view DSSKeyPairGenerator download DSSKeyPairGenerator.java

java.lang.Object
  extended bygnu.java.security.key.dss.DSSKeyPairGenerator
All Implemented Interfaces:
gnu.java.security.key.IKeyPairGenerator

public class DSSKeyPairGenerator
extends java.lang.Object
implements gnu.java.security.key.IKeyPairGenerator

A key-pair generator for asymetric keys to use in conjunction with the DSS (Digital Signature Standard).

References:
Digital Signature Standard (DSS), Federal Information Processing Standards Publication 186. National Institute of Standards and Technology.


Field Summary
private  java.math.BigInteger counter
           
private static boolean DEBUG
           
private static int debuglevel
           
private static int DEFAULT_ENCODING_FORMAT
          Default encoding format to use when none was specified.
static int DEFAULT_MODULUS_LENGTH
          Default value for the modulus length.
static java.lang.String DSS_PARAMETERS
          Property name of an optional java.security.spec.DSAParameterSpec instance to use for this generator's p, q, and g values.
private  java.math.BigInteger e
           
private static java.io.PrintWriter err
           
private  java.math.BigInteger g
           
static java.security.spec.DSAParameterSpec KEY_PARAMS_1024
           
static java.security.spec.DSAParameterSpec KEY_PARAMS_512
           
static java.security.spec.DSAParameterSpec KEY_PARAMS_768
           
private  int L
          The length of the modulus of DSS keys generated by this instance.
static java.lang.String MODULUS_LENGTH
          Property name of the length (Integer) of the modulus (p) of a DSS key.
private static java.lang.String NAME
           
private  java.math.BigInteger p
           
static java.lang.String PREFERRED_ENCODING_FORMAT
          Property name of the preferred encoding format to use when externalizing generated instance of key-pairs from this generator.
private  int preferredFormat
          Preferred encoding format of generated keys.
private  gnu.java.security.util.PRNG prng
          Our default source of randomness.
private  java.math.BigInteger q
           
private  java.security.SecureRandom rnd
          The optional java.security.SecureRandom instance to use.
private  java.math.BigInteger seed
           
static java.lang.String SOURCE_OF_RANDOMNESS
          Property name of an optional java.security.SecureRandom instance to use.
static java.lang.String STRICT_DEFAULTS
          Property name of the Boolean indicating wether or not to generate new parameters, even if the modulus length L is not one of the pre- computed defaults (value Boolean.FALSE>Boolean.FALSE 55 ), or throw an exception (value Boolean.TRUE>Boolean.TRUE 55 ) -- the exception in this case is an java.lang.IllegalArgumentException.
private static int[] T_SHS
          Initial SHS context.
private static java.math.BigInteger TWO
          The BigInteger constant 2.
private static java.math.BigInteger TWO_POW_160
           
static java.lang.String USE_DEFAULTS
          Property name of the Boolean indicating wether or not to use default pre- computed values of p, q and g for a given modulus length.
private  java.math.BigInteger XKEY
           
 
Constructor Summary
DSSKeyPairGenerator()
           
 
Method Summary
private static void debug(java.lang.String s)
           
 java.security.KeyPair generate()
          Generates a new keypair based on the attributes used to configure the instance.
private  gnu.java.security.util.PRNG getDefaultPRNG()
           
 java.lang.String name()
          Returns the canonical name of this keypair generator.
private  void nextRandomBytes(byte[] buffer)
          Fills the designated byte array with random data.
private  java.math.BigInteger nextX()
          This method applies the following algorithm described in 3.1 of FIPS-186:
 void setup(java.util.Map attributes)
          Configures this instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NAME

private static final java.lang.String NAME
See Also:
Constant Field Values

DEBUG

private static final boolean DEBUG
See Also:
Constant Field Values

debuglevel

private static final int debuglevel
See Also:
Constant Field Values

err

private static final java.io.PrintWriter err

TWO

private static final java.math.BigInteger TWO
The BigInteger constant 2.


MODULUS_LENGTH

public static final java.lang.String MODULUS_LENGTH
Property name of the length (Integer) of the modulus (p) of a DSS key.

See Also:
Constant Field Values

USE_DEFAULTS

public static final java.lang.String USE_DEFAULTS
Property name of the Boolean indicating wether or not to use default pre- computed values of p, q and g for a given modulus length. The ultimate behaviour of this generator with regard to using pre-computed parameter sets will depend on the value of this property and of the following one STRICT_DEFAULTS 55 :
  1. If this property is Boolean.FALSE>Boolean.FALSE 55 then this generator will accept being setup for generating parameters for any modulus length provided the modulus length is between 512 and 1024, and is of the form 512 + 64 * n. In addition, a new paramter set will always be generated; i.e. no pre- computed values are used.
  2. If this property is Boolean.TRUE>Boolean.TRUE 55 and the value of STRICT_DEFAULTS 55 is also Boolean.TRUE>Boolean.TRUE 55 then this generator will only accept being setup for generating parameters for modulus lengths of 512, 768 and 1024. Any other value, of the modulus length, even if between 512 and 1024, and of the form 512 + 64 * n, will cause an java.lang.IllegalArgumentException to be thrown. When those modulus length (512, 768, and 1024) are specified, the paramter set is always the same.
  3. Finally, if this property is Boolean.TRUE>Boolean.TRUE 55 and the value of STRICT_DEFAULTS 55 is Boolean.FALSE>Boolean.FALSE 55 then this generator will behave as in point 1 above, except that it will use pre-computed values when possible; i.e. the modulus length is one of 512, 768, or 1024.
The default value of this property is Boolean.TRUE>Boolean.TRUE 55 .

See Also:
Constant Field Values

STRICT_DEFAULTS

public static final java.lang.String STRICT_DEFAULTS
Property name of the Boolean indicating wether or not to generate new parameters, even if the modulus length L is not one of the pre- computed defaults (value Boolean.FALSE>Boolean.FALSE 55 ), or throw an exception (value Boolean.TRUE>Boolean.TRUE 55 ) -- the exception in this case is an java.lang.IllegalArgumentException. The default value for this property is Boolean.FALSE>Boolean.FALSE 55 . The ultimate behaviour of this generator will depend on the values of this and USE_DEFAULTS 55 properties -- see USE_DEFAULTS 55 for more information.

See Also:
Constant Field Values

SOURCE_OF_RANDOMNESS

public static final java.lang.String SOURCE_OF_RANDOMNESS
Property name of an optional java.security.SecureRandom instance to use. The default is to use a classloader singleton from gnu.java.security.util.PRNG.

See Also:
Constant Field Values

DSS_PARAMETERS

public static final java.lang.String DSS_PARAMETERS
Property name of an optional java.security.spec.DSAParameterSpec instance to use for this generator's p, q, and g values. The default is to generate these values or use pre-computed ones, depending on the value of the USE_DEFAULTS attribute.

See Also:
Constant Field Values

PREFERRED_ENCODING_FORMAT

public static final java.lang.String PREFERRED_ENCODING_FORMAT
Property name of the preferred encoding format to use when externalizing generated instance of key-pairs from this generator. The property is taken to be an java.lang.Integer that encapsulates an encoding format identifier.

See Also:
Constant Field Values

DEFAULT_MODULUS_LENGTH

public static final int DEFAULT_MODULUS_LENGTH
Default value for the modulus length.

See Also:
Constant Field Values

DEFAULT_ENCODING_FORMAT

private static final int DEFAULT_ENCODING_FORMAT
Default encoding format to use when none was specified.

See Also:
Constant Field Values

T_SHS

private static final int[] T_SHS
Initial SHS context.


KEY_PARAMS_512

public static final java.security.spec.DSAParameterSpec KEY_PARAMS_512

KEY_PARAMS_768

public static final java.security.spec.DSAParameterSpec KEY_PARAMS_768

KEY_PARAMS_1024

public static final java.security.spec.DSAParameterSpec KEY_PARAMS_1024

TWO_POW_160

private static final java.math.BigInteger TWO_POW_160

L

private int L
The length of the modulus of DSS keys generated by this instance.


rnd

private java.security.SecureRandom rnd
The optional java.security.SecureRandom instance to use.


seed

private java.math.BigInteger seed

counter

private java.math.BigInteger counter

p

private java.math.BigInteger p

q

private java.math.BigInteger q

e

private java.math.BigInteger e

g

private java.math.BigInteger g

XKEY

private java.math.BigInteger XKEY

prng

private gnu.java.security.util.PRNG prng
Our default source of randomness.


preferredFormat

private int preferredFormat
Preferred encoding format of generated keys.

Constructor Detail

DSSKeyPairGenerator

public DSSKeyPairGenerator()
Method Detail

debug

private static void debug(java.lang.String s)

name

public java.lang.String name()
Description copied from interface: gnu.java.security.key.IKeyPairGenerator
Returns the canonical name of this keypair generator.

Specified by:
name in interface gnu.java.security.key.IKeyPairGenerator

setup

public void setup(java.util.Map attributes)

Configures this instance.

Specified by:
setup in interface gnu.java.security.key.IKeyPairGenerator

generate

public java.security.KeyPair generate()
Description copied from interface: gnu.java.security.key.IKeyPairGenerator
Generates a new keypair based on the attributes used to configure the instance.

Specified by:
generate in interface gnu.java.security.key.IKeyPairGenerator

nextX

private java.math.BigInteger nextX()

This method applies the following algorithm described in 3.1 of FIPS-186:

  1. XSEED = optional user input.
  2. XVAL = (XKEY + XSEED) mod 2b.
  3. x = G(t, XVAL) mod q.
  4. XKEY = (1 + XKEY + x) mod 2b.

Where b is the length of a secret b-bit seed-key (XKEY).

Note that in this implementation, XSEED, the optional user input, is always zero.


nextRandomBytes

private void nextRandomBytes(byte[] buffer)

Fills the designated byte array with random data.


getDefaultPRNG

private gnu.java.security.util.PRNG getDefaultPRNG()