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