1. /*
  2. * @(#)RSAPrivateCrtKeySpec.java 1.10 03/01/23
  3. *
  4. * Copyright 2003 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.10 03/01/23
  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 BigInteger modulus;
  27. private BigInteger publicExponent;
  28. private BigInteger privateExponent;
  29. private BigInteger primeP;
  30. private BigInteger primeQ;
  31. private BigInteger primeExponentP;
  32. private BigInteger primeExponentQ;
  33. private BigInteger crtCoefficient;
  34. /**
  35. * Creates a new <code>RSAPrivateCrtKeySpec</code>
  36. * given the modulus, publicExponent, privateExponent,
  37. * primeP, primeQ, primeExponentP, primeExponentQ, and
  38. * crtCoefficient as defined in PKCS#1.
  39. *
  40. * @param modulus the modulus n
  41. * @param publicExponent the public exponent e
  42. * @param privateExponent the private exponent d
  43. * @param primeP the prime factor p of n
  44. * @param primeQ the prime factor q of n
  45. * @param primeExponentP this is d mod (p-1)
  46. * @param primeExponentQ this is d mod (q-1)
  47. * @param crtCoefficient the Chinese Remainder Theorem
  48. * coefficient q-1 mod p
  49. */
  50. public RSAPrivateCrtKeySpec(BigInteger modulus,
  51. BigInteger publicExponent,
  52. BigInteger privateExponent,
  53. BigInteger primeP,
  54. BigInteger primeQ,
  55. BigInteger primeExponentP,
  56. BigInteger primeExponentQ,
  57. BigInteger crtCoefficient) {
  58. super(modulus, privateExponent);
  59. this.publicExponent = publicExponent;
  60. this.primeP = primeP;
  61. this.primeQ = primeQ;
  62. this.primeExponentP = primeExponentP;
  63. this.primeExponentQ = primeExponentQ;
  64. this.crtCoefficient = crtCoefficient;
  65. }
  66. /**
  67. * Returns the public exponent.
  68. *
  69. * @return the public exponent
  70. */
  71. public BigInteger getPublicExponent() {
  72. return this.publicExponent;
  73. }
  74. /**
  75. * Returns the primeP.
  76. * @return the primeP
  77. */
  78. public BigInteger getPrimeP() {
  79. return this.primeP;
  80. }
  81. /**
  82. * Returns the primeQ.
  83. *
  84. * @return the primeQ
  85. */
  86. public BigInteger getPrimeQ() {
  87. return this.primeQ;
  88. }
  89. /**
  90. * Returns the primeExponentP.
  91. *
  92. * @return the primeExponentP
  93. */
  94. public BigInteger getPrimeExponentP() {
  95. return this.primeExponentP;
  96. }
  97. /**
  98. * Returns the primeExponentQ.
  99. *
  100. * @return the primeExponentQ
  101. */
  102. public BigInteger getPrimeExponentQ() {
  103. return this.primeExponentQ;
  104. }
  105. /**
  106. * Returns the crtCoefficient.
  107. *
  108. * @return the crtCoefficient
  109. */
  110. public BigInteger getCrtCoefficient() {
  111. return this.crtCoefficient;
  112. }
  113. }