1. /*
  2. * @(#)PKCS8EncodedKeySpec.java 1.19 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. /**
  9. * This class represents the ASN.1 encoding of a private key,
  10. * encoded according to the ASN.1 type <code>PrivateKeyInfo</code>.
  11. * The <code>PrivateKeyInfo</code> syntax is defined in the PKCS#8 standard
  12. * as follows:
  13. *
  14. * <pre>
  15. * PrivateKeyInfo ::= SEQUENCE {
  16. * version Version,
  17. * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
  18. * privateKey PrivateKey,
  19. * attributes [0] IMPLICIT Attributes OPTIONAL }
  20. *
  21. * Version ::= INTEGER
  22. *
  23. * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
  24. *
  25. * PrivateKey ::= OCTET STRING
  26. *
  27. * Attributes ::= SET OF Attribute
  28. * </pre>
  29. *
  30. * @author Jan Luehe
  31. *
  32. * @version 1.19, 12/19/03
  33. *
  34. * @see java.security.Key
  35. * @see java.security.KeyFactory
  36. * @see KeySpec
  37. * @see EncodedKeySpec
  38. * @see X509EncodedKeySpec
  39. *
  40. * @since 1.2
  41. */
  42. public class PKCS8EncodedKeySpec extends EncodedKeySpec {
  43. /**
  44. * Creates a new PKCS8EncodedKeySpec with the given encoded key.
  45. *
  46. * @param encodedKey the key, which is assumed to be
  47. * encoded according to the PKCS #8 standard. The contents of
  48. * the array are copied to protect against subsequent modification.
  49. */
  50. public PKCS8EncodedKeySpec(byte[] encodedKey) {
  51. super(encodedKey);
  52. }
  53. /**
  54. * Returns the key bytes, encoded according to the PKCS #8 standard.
  55. *
  56. * @return the PKCS #8 encoding of the key. Returns a new array
  57. * each time this method is called.
  58. */
  59. public byte[] getEncoded() {
  60. return super.getEncoded();
  61. }
  62. /**
  63. * Returns the name of the encoding format associated with this
  64. * key specification.
  65. *
  66. * @return the string <code>"PKCS#8"</code>.
  67. */
  68. public final String getFormat() {
  69. return "PKCS#8";
  70. }
  71. }