1. /*
  2. * @(#)MGF1ParameterSpec.java 1.3 04/01/27
  3. *
  4. * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package java.security.spec;
  8. import java.security.spec.AlgorithmParameterSpec;
  9. /**
  10. * This class specifies the set of parameters used with mask generation
  11. * function MGF1 in OAEP Padding and RSA-PSS signature scheme, as
  12. * defined in the
  13. * <a href="http://www.rsa.com/rsalabs/pubs/PKCS/html/pkcs-1.html">
  14. * PKCS #1 v2.1</a> standard.
  15. *
  16. * <p>Its ASN.1 definition in PKCS#1 standard is described below:
  17. * <pre>
  18. * MGF1Parameters ::= OAEP-PSSDigestAlgorthms
  19. * </pre>
  20. * where
  21. * <pre>
  22. * OAEP-PSSDigestAlgorithms ALGORITHM-IDENTIFIER ::= {
  23. * { OID id-sha1 PARAMETERS NULL }|
  24. * { OID id-sha256 PARAMETERS NULL }|
  25. * { OID id-sha384 PARAMETERS NULL }|
  26. * { OID id-sha512 PARAMETERS NULL },
  27. * ... -- Allows for future expansion --
  28. * }
  29. * </pre>
  30. * @see PSSParameterSpec
  31. * @see javax.crypto.spec.OAEPParameterSpec
  32. *
  33. * @author Valerie Peng
  34. *
  35. * @version 1.3, 01/27/04
  36. * @since 1.5
  37. */
  38. public class MGF1ParameterSpec implements AlgorithmParameterSpec {
  39. /**
  40. * The MGF1ParameterSpec which uses "SHA-1" message digest.
  41. */
  42. public static final MGF1ParameterSpec SHA1 =
  43. new MGF1ParameterSpec("SHA-1");
  44. /**
  45. * The MGF1ParameterSpec which uses "SHA-256" message digest.
  46. */
  47. public static final MGF1ParameterSpec SHA256 =
  48. new MGF1ParameterSpec("SHA-256");
  49. /**
  50. * The MGF1ParameterSpec which uses "SHA-384" message digest.
  51. */
  52. public static final MGF1ParameterSpec SHA384 =
  53. new MGF1ParameterSpec("SHA-384");
  54. /**
  55. * The MGF1ParameterSpec which uses SHA-512 message digest.
  56. */
  57. public static final MGF1ParameterSpec SHA512 =
  58. new MGF1ParameterSpec("SHA-512");
  59. private String mdName;
  60. /**
  61. * Constructs a parameter set for mask generation function MGF1
  62. * as defined in the PKCS #1 standard.
  63. *
  64. * @param mdName the algorithm name for the message digest
  65. * used in this mask generation function MGF1.
  66. * @exception NullPointerException if <code>mdName</code> is null.
  67. */
  68. public MGF1ParameterSpec(String mdName) {
  69. if (mdName == null) {
  70. throw new NullPointerException("digest algorithm is null");
  71. }
  72. this.mdName = mdName;
  73. }
  74. /**
  75. * Returns the algorithm name of the message digest used by the mask
  76. * generation function.
  77. *
  78. * @return the algorithm name of the message digest.
  79. */
  80. public String getDigestAlgorithm() {
  81. return mdName;
  82. }
  83. }