01 /*
02 * Copyright 1997-2005 Sun Microsystems, Inc. All Rights Reserved.
03 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
04 *
05 * This code is free software; you can redistribute it and/or modify it
06 * under the terms of the GNU General Public License version 2 only, as
07 * published by the Free Software Foundation. Sun designates this
08 * particular file as subject to the "Classpath" exception as provided
09 * by Sun in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22 * CA 95054 USA or visit www.sun.com if you need additional information or
23 * have any questions.
24 */
25
26 package java.security.spec;
27
28 /**
29 * This class represents the ASN.1 encoding of a private key,
30 * encoded according to the ASN.1 type <code>PrivateKeyInfo</code>.
31 * The <code>PrivateKeyInfo</code> syntax is defined in the PKCS#8 standard
32 * as follows:
33 *
34 * <pre>
35 * PrivateKeyInfo ::= SEQUENCE {
36 * version Version,
37 * privateKeyAlgorithm PrivateKeyAlgorithmIdentifier,
38 * privateKey PrivateKey,
39 * attributes [0] IMPLICIT Attributes OPTIONAL }
40 *
41 * Version ::= INTEGER
42 *
43 * PrivateKeyAlgorithmIdentifier ::= AlgorithmIdentifier
44 *
45 * PrivateKey ::= OCTET STRING
46 *
47 * Attributes ::= SET OF Attribute
48 * </pre>
49 *
50 * @author Jan Luehe
51 *
52 * @version 1.28, 05/05/07
53 *
54 * @see java.security.Key
55 * @see java.security.KeyFactory
56 * @see KeySpec
57 * @see EncodedKeySpec
58 * @see X509EncodedKeySpec
59 *
60 * @since 1.2
61 */
62
63 public class PKCS8EncodedKeySpec extends EncodedKeySpec {
64
65 /**
66 * Creates a new PKCS8EncodedKeySpec with the given encoded key.
67 *
68 * @param encodedKey the key, which is assumed to be
69 * encoded according to the PKCS #8 standard. The contents of
70 * the array are copied to protect against subsequent modification.
71 * @exception NullPointerException if <code>encodedKey</code>
72 * is null.
73 */
74 public PKCS8EncodedKeySpec(byte[] encodedKey) {
75 super (encodedKey);
76 }
77
78 /**
79 * Returns the key bytes, encoded according to the PKCS #8 standard.
80 *
81 * @return the PKCS #8 encoding of the key. Returns a new array
82 * each time this method is called.
83 */
84 public byte[] getEncoded() {
85 return super .getEncoded();
86 }
87
88 /**
89 * Returns the name of the encoding format associated with this
90 * key specification.
91 *
92 * @return the string <code>"PKCS#8"</code>.
93 */
94 public final String getFormat() {
95 return "PKCS#8";
96 }
97 }
|