1. /*
  2. * @(#)PKCS8EncodedKeySpec.java 1.17 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. /**
  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.17, 01/23/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.
  48. */
  49. public PKCS8EncodedKeySpec(byte[] encodedKey) {
  50. super(encodedKey);
  51. }
  52. /**
  53. * Returns the key bytes, encoded according to the PKCS #8 standard.
  54. *
  55. * @return the PKCS #8 encoding of the key.
  56. */
  57. public byte[] getEncoded() {
  58. return super.getEncoded();
  59. }
  60. /**
  61. * Returns the name of the encoding format associated with this
  62. * key specification.
  63. *
  64. * @return the string <code>"PKCS#8"</code>.
  65. */
  66. public final String getFormat() {
  67. return "PKCS#8";
  68. }
  69. }