1. /*
  2. * @(#)RSAPrivateCrtKeySpec.java 1.12 03/12/19
  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.math.BigInteger;
  9. /**
  10. * This class specifies an RSA private key, as defined in the PKCS#1
  11. * standard, using the Chinese Remainder Theorem (CRT) information values for
  12. * efficiency.
  13. *
  14. * @author Jan Luehe
  15. *
  16. * @version 1.12 03/12/19
  17. *
  18. * @see java.security.Key
  19. * @see java.security.KeyFactory
  20. * @see KeySpec
  21. * @see PKCS8EncodedKeySpec
  22. * @see RSAPrivateKeySpec
  23. * @see RSAPublicKeySpec
  24. */
  25. public class RSAPrivateCrtKeySpec extends RSAPrivateKeySpec {
  26. private final BigInteger publicExponent;
  27. private final BigInteger primeP;
  28. private final BigInteger primeQ;
  29. private final BigInteger primeExponentP;
  30. private final BigInteger primeExponentQ;
  31. private final BigInteger crtCoefficient;
  32. /**
  33. * Creates a new <code>RSAPrivateCrtKeySpec</code>
  34. * given the modulus, publicExponent, privateExponent,
  35. * primeP, primeQ, primeExponentP, primeExponentQ, and
  36. * crtCoefficient as defined in PKCS#1.
  37. *
  38. * @param modulus the modulus n
  39. * @param publicExponent the public exponent e
  40. * @param privateExponent the private exponent d
  41. * @param primeP the prime factor p of n
  42. * @param primeQ the prime factor q of n
  43. * @param primeExponentP this is d mod (p-1)
  44. * @param primeExponentQ this is d mod (q-1)
  45. * @param crtCoefficient the Chinese Remainder Theorem
  46. * coefficient q-1 mod p
  47. */
  48. public RSAPrivateCrtKeySpec(BigInteger modulus,
  49. BigInteger publicExponent,
  50. BigInteger privateExponent,
  51. BigInteger primeP,
  52. BigInteger primeQ,
  53. BigInteger primeExponentP,
  54. BigInteger primeExponentQ,
  55. BigInteger crtCoefficient) {
  56. super(modulus, privateExponent);
  57. this.publicExponent = publicExponent;
  58. this.primeP = primeP;
  59. this.primeQ = primeQ;
  60. this.primeExponentP = primeExponentP;
  61. this.primeExponentQ = primeExponentQ;
  62. this.crtCoefficient = crtCoefficient;
  63. }
  64. /**
  65. * Returns the public exponent.
  66. *
  67. * @return the public exponent
  68. */
  69. public BigInteger getPublicExponent() {
  70. return this.publicExponent;
  71. }
  72. /**
  73. * Returns the primeP.
  74. * @return the primeP
  75. */
  76. public BigInteger getPrimeP() {
  77. return this.primeP;
  78. }
  79. /**
  80. * Returns the primeQ.
  81. *
  82. * @return the primeQ
  83. */
  84. public BigInteger getPrimeQ() {
  85. return this.primeQ;
  86. }
  87. /**
  88. * Returns the primeExponentP.
  89. *
  90. * @return the primeExponentP
  91. */
  92. public BigInteger getPrimeExponentP() {
  93. return this.primeExponentP;
  94. }
  95. /**
  96. * Returns the primeExponentQ.
  97. *
  98. * @return the primeExponentQ
  99. */
  100. public BigInteger getPrimeExponentQ() {
  101. return this.primeExponentQ;
  102. }
  103. /**
  104. * Returns the crtCoefficient.
  105. *
  106. * @return the crtCoefficient
  107. */
  108. public BigInteger getCrtCoefficient() {
  109. return this.crtCoefficient;
  110. }
  111. }