|
1 /* |
|
2 * Copyright 2005-2007 Sun Microsystems, Inc. All Rights Reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Sun designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * 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 sun.security.internal.spec; |
|
27 |
|
28 import java.security.spec.AlgorithmParameterSpec; |
|
29 |
|
30 import javax.crypto.SecretKey; |
|
31 |
|
32 /** |
|
33 * Parameters for the TLS PRF (pseudo-random function). The PRF function |
|
34 * is defined in RFC 2246. |
|
35 * This class is used to initialize KeyGenerators of the type "TlsPrf". |
|
36 * |
|
37 * <p>Instances of this class are immutable. |
|
38 * |
|
39 * @since 1.6 |
|
40 * @author Andreas Sterbenz |
|
41 * @deprecated Sun JDK internal use only --- WILL BE REMOVED in Dolphin (JDK 7) |
|
42 */ |
|
43 @Deprecated |
|
44 public class TlsPrfParameterSpec implements AlgorithmParameterSpec { |
|
45 |
|
46 private final SecretKey secret; |
|
47 private final String label; |
|
48 private final byte[] seed; |
|
49 private final int outputLength; |
|
50 |
|
51 /** |
|
52 * Constructs a new TlsPrfParameterSpec. |
|
53 * |
|
54 * @param secret the secret to use in the calculation (or null) |
|
55 * @param label the label to use in the calculation |
|
56 * @param seed the random seed to use in the calculation |
|
57 * @param outputLength the length in bytes of the output key to be produced |
|
58 * |
|
59 * @throws NullPointerException if label or seed is null |
|
60 * @throws IllegalArgumentException if outputLength is negative |
|
61 */ |
|
62 public TlsPrfParameterSpec(SecretKey secret, String label, byte[] seed, int outputLength) { |
|
63 if ((label == null) || (seed == null)) { |
|
64 throw new NullPointerException("label and seed must not be null"); |
|
65 } |
|
66 if (outputLength <= 0) { |
|
67 throw new IllegalArgumentException("outputLength must be positive"); |
|
68 } |
|
69 this.secret = secret; |
|
70 this.label = label; |
|
71 this.seed = seed.clone(); |
|
72 this.outputLength = outputLength; |
|
73 } |
|
74 |
|
75 /** |
|
76 * Returns the secret to use in the PRF calculation, or null if there is no |
|
77 * secret. |
|
78 * |
|
79 * @return the secret to use in the PRF calculation, or null if there is no |
|
80 * secret. |
|
81 */ |
|
82 public SecretKey getSecret() { |
|
83 return secret; |
|
84 } |
|
85 |
|
86 /** |
|
87 * Returns the label to use in the PRF calcuation. |
|
88 * |
|
89 * @return the label to use in the PRF calcuation. |
|
90 */ |
|
91 public String getLabel() { |
|
92 return label; |
|
93 } |
|
94 |
|
95 /** |
|
96 * Returns a copy of the seed to use in the PRF calcuation. |
|
97 * |
|
98 * @return a copy of the seed to use in the PRF calcuation. |
|
99 */ |
|
100 public byte[] getSeed() { |
|
101 return seed.clone(); |
|
102 } |
|
103 |
|
104 /** |
|
105 * Returns the length in bytes of the output key to be produced. |
|
106 * |
|
107 * @return the length in bytes of the output key to be produced. |
|
108 */ |
|
109 public int getOutputLength() { |
|
110 return outputLength; |
|
111 } |
|
112 |
|
113 } |