1. /*
  2. * @(#)AlgorithmParameterGeneratorSpi.java 1.7 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;
  8. import java.security.spec.AlgorithmParameterSpec;
  9. /**
  10. * This class defines the <i>Service Provider Interface</i> (<b>SPI</b>)
  11. * for the <code>AlgorithmParameterGenerator</code> class, which
  12. * is used to generate a set of parameters to be used with a certain algorithm.
  13. *
  14. * <p> All the abstract methods in this class must be implemented by each
  15. * cryptographic service provider who wishes to supply the implementation
  16. * of a parameter generator for a particular algorithm.
  17. *
  18. * <p> In case the client does not explicitly initialize the
  19. * AlgorithmParameterGenerator (via a call to an <code>engineInit</code>
  20. * method), each provider must supply (and document) a default initialization.
  21. * For example, the Sun provider uses a default modulus prime size of 1024
  22. * bits for the generation of DSA parameters.
  23. *
  24. * @author Jan Luehe
  25. *
  26. * @version 1.7 01/11/29
  27. *
  28. * @see AlgorithmParameterGenerator
  29. * @see AlgorithmParameters
  30. * @see java.security.spec.AlgorithmParameterSpec
  31. *
  32. * @since JDK1.2
  33. */
  34. public abstract class AlgorithmParameterGeneratorSpi {
  35. /**
  36. * Initializes this parameter generator for a certain size
  37. * and source of randomness.
  38. *
  39. * @param size the size (number of bits).
  40. * @param random the source of randomness.
  41. */
  42. protected abstract void engineInit(int size, SecureRandom random);
  43. /**
  44. * Initializes this parameter generator with a set of
  45. * algorithm-specific parameter generation values.
  46. *
  47. * @param params the set of algorithm-specific parameter generation values.
  48. * @param random the source of randomness.
  49. *
  50. * @exception InvalidAlgorithmParameterException if the given parameter
  51. * generation values are inappropriate for this parameter generator.
  52. */
  53. protected abstract void engineInit(AlgorithmParameterSpec genParamSpec,
  54. SecureRandom random)
  55. throws InvalidAlgorithmParameterException;
  56. /**
  57. * Generates the parameters.
  58. *
  59. * @return the new AlgorithmParameters object.
  60. */
  61. protected abstract AlgorithmParameters engineGenerateParameters();
  62. }