1. /*
  2. * @(#)DSAKeyPairGenerator.java 1.9 01/11/29
  3. *
  4. * Copyright 2002 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.interfaces;
  8. import java.security.*;
  9. /**
  10. * An interface to an object capable of generating DSA key pairs.
  11. *
  12. * <p>The <code>initialize</code> methods may each be called any number
  13. * of times. If no <code>initialize</code> method is called on a
  14. * DSAKeyPairGenerator, the default is to generate 1024-bit keys, using
  15. * precomputed p, q and g parameters and an instance of SecureRandom as
  16. * the random bit source.
  17. *
  18. * <p>Users wishing to indicate DSA-specific parameters, and to generate a key
  19. * pair suitable for use with the DSA algorithm typically
  20. *
  21. * <ol>
  22. *
  23. * <li>Get a key pair generator for the DSA algorithm by calling the
  24. * KeyPairGenerator <code>getInstance</code> method with "DSA"
  25. * as its argument.<p>
  26. *
  27. * <li>Initialize the generator by casting the result to a DSAKeyPairGenerator
  28. * and calling one of the
  29. * <code>initialize</code> methods from this DSAKeyPairGenerator interface.<p>
  30. *
  31. * <li>Generate a key pair by calling the <code>generateKeyPair</code>
  32. * method from the KeyPairGenerator class.
  33. *
  34. * </ol>
  35. *
  36. * <p>Note: it is not always necessary to do do algorithm-specific
  37. * initialization for a DSA key pair generator. That is, it is not always
  38. * necessary to call an <code>initialize</code> method in this interface.
  39. * Algorithm-independent initialization using the <code>initialize</code> method
  40. * in the KeyPairGenerator
  41. * interface is all that is needed when you accept defaults for algorithm-specific
  42. * parameters.
  43. *
  44. * @see java.security.KeyPairGenerator
  45. */
  46. public interface DSAKeyPairGenerator {
  47. /**
  48. * Initializes the key pair generator using p, q and g, the DSA
  49. * family parameters.
  50. *
  51. * @param params the parameters to use to generate the keys.
  52. *
  53. * @param random the random bit source to use to generate
  54. * key bits.
  55. *
  56. * @exception InvalidParameterException if the parameters passed are
  57. * invalid or null.
  58. */
  59. public void initialize(DSAParams params, SecureRandom random)
  60. throws InvalidParameterException;
  61. /**
  62. * Initializes the key pair generator for a given modulus length,
  63. * without parameters.
  64. *
  65. * <p>If <code>genParams</code> is true, this method will generate new
  66. * p, q and g parameters. If it is false, the method will use precomputed
  67. * parameters for the modulus length requested. If there are no
  68. * precomputed parameters for that modulus length, an exception will be
  69. * thrown. It is guaranteed that there will always be
  70. * default parameters for modulus lengths of 512 and 1024 bits.
  71. *
  72. * @param modlen the modulus length, in bits. Valid values are any
  73. * multiple of 8 between 512 and 1024, inclusive.
  74. *
  75. * @param random the random bit source to use to generate
  76. * key bits.
  77. *
  78. * @param genParams whether or not to generate new parameters for
  79. * the modulus length requested.
  80. *
  81. * @exception InvalidParameterException if the modulus length is not
  82. * between 512 and 1024, or if genParams is false and there are
  83. * not precomputed parameters for the modulus length requested.
  84. */
  85. public void initialize(int modlen, boolean genParams, SecureRandom random)
  86. throws InvalidParameterException;
  87. }