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