author | chegar |
Thu, 17 Oct 2019 20:54:25 +0100 | |
branch | datagramsocketimpl-branch |
changeset 58679 | 9c3209ff7550 |
parent 58678 | 9cf78a70fa4f |
parent 58519 | 6e017b301287 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2005, 2019, Oracle and/or its affiliates. All rights reserved. |
2 | 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 |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 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 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package sun.security.internal.spec; |
|
27 |
||
28 |
import java.security.spec.KeySpec; |
|
29 |
||
30 |
import javax.crypto.SecretKey; |
|
31 |
import javax.crypto.spec.IvParameterSpec; |
|
32 |
||
33 |
/** |
|
34 |
* KeySpec class for SSL/TLS key material. |
|
35 |
* |
|
36 |
* <p>Instances of this class are returned by the <code>generateKey()</code> |
|
37 |
* method of KeyGenerators of the type "TlsKeyMaterial". |
|
38 |
* Instances of this class are immutable. |
|
39 |
* |
|
40 |
* @since 1.6 |
|
41 |
* @author Andreas Sterbenz |
|
7043 | 42 |
* @deprecated Sun JDK internal use only --- WILL BE REMOVED in a future |
43 |
* release. |
|
2 | 44 |
*/ |
45 |
@Deprecated |
|
46 |
public class TlsKeyMaterialSpec implements KeySpec, SecretKey { |
|
47 |
||
57950
4612a3cfb927
8229999: Apply java.io.Serial annotations to security types in java.base
darcy
parents:
47216
diff
changeset
|
48 |
@java.io.Serial |
2 | 49 |
static final long serialVersionUID = 812912859129525028L; |
50 |
||
51 |
private final SecretKey clientMacKey, serverMacKey; |
|
52 |
private final SecretKey clientCipherKey, serverCipherKey; |
|
58519
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
53 |
|
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
54 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
55 |
private final IvParameterSpec clientIv; |
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
56 |
@SuppressWarnings("serial") // Not statically typed as Serializable |
6e017b301287
8231262: Suppress warnings on non-serializable instance fields in security libs serializable classes
darcy
parents:
57950
diff
changeset
|
57 |
private final IvParameterSpec serverIv; |
2 | 58 |
|
59 |
/** |
|
60 |
* Constructs a new TlsKeymaterialSpec from the client and server MAC |
|
61 |
* keys. |
|
62 |
* This call is equivalent to |
|
63 |
* <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey, |
|
64 |
* null, null, null, null)</code>. |
|
65 |
* |
|
16913 | 66 |
* @param clientMacKey the client MAC key (or null) |
67 |
* @param serverMacKey the server MAC key (or null) |
|
2 | 68 |
*/ |
69 |
public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey) { |
|
70 |
this(clientMacKey, serverMacKey, null, null, null, null); |
|
71 |
} |
|
72 |
||
73 |
/** |
|
74 |
* Constructs a new TlsKeymaterialSpec from the client and server MAC |
|
75 |
* keys and client and server cipher keys. |
|
76 |
* This call is equivalent to |
|
77 |
* <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey, |
|
78 |
* clientCipherKey, serverCipherKey, null, null)</code>. |
|
79 |
* |
|
16913 | 80 |
* @param clientMacKey the client MAC key (or null) |
81 |
* @param serverMacKey the server MAC key (or null) |
|
2 | 82 |
* @param clientCipherKey the client cipher key (or null) |
83 |
* @param serverCipherKey the server cipher key (or null) |
|
84 |
*/ |
|
85 |
public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey, |
|
86 |
SecretKey clientCipherKey, SecretKey serverCipherKey) { |
|
7043 | 87 |
this(clientMacKey, serverMacKey, clientCipherKey, null, |
88 |
serverCipherKey, null); |
|
2 | 89 |
} |
90 |
||
91 |
/** |
|
92 |
* Constructs a new TlsKeymaterialSpec from the client and server MAC |
|
93 |
* keys, client and server cipher keys, and client and server |
|
94 |
* initialization vectors. |
|
95 |
* |
|
16913 | 96 |
* @param clientMacKey the client MAC key (or null) |
97 |
* @param serverMacKey the server MAC key (or null) |
|
2 | 98 |
* @param clientCipherKey the client cipher key (or null) |
99 |
* @param clientIv the client initialization vector (or null) |
|
100 |
* @param serverCipherKey the server cipher key (or null) |
|
101 |
* @param serverIv the server initialization vector (or null) |
|
102 |
*/ |
|
103 |
public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey, |
|
104 |
SecretKey clientCipherKey, IvParameterSpec clientIv, |
|
105 |
SecretKey serverCipherKey, IvParameterSpec serverIv) { |
|
16913 | 106 |
|
2 | 107 |
this.clientMacKey = clientMacKey; |
108 |
this.serverMacKey = serverMacKey; |
|
109 |
this.clientCipherKey = clientCipherKey; |
|
110 |
this.serverCipherKey = serverCipherKey; |
|
111 |
this.clientIv = clientIv; |
|
112 |
this.serverIv = serverIv; |
|
113 |
} |
|
114 |
||
115 |
/** |
|
116 |
* Returns <code>TlsKeyMaterial</code>. |
|
117 |
* |
|
118 |
* @return <code>TlsKeyMaterial</code>. |
|
119 |
*/ |
|
120 |
public String getAlgorithm() { |
|
121 |
return "TlsKeyMaterial"; |
|
122 |
} |
|
123 |
||
124 |
/** |
|
125 |
* Returns <code>null</code> because keys of this type have no encoding. |
|
126 |
* |
|
127 |
* @return <code>null</code> because keys of this type have no encoding. |
|
128 |
*/ |
|
129 |
public String getFormat() { |
|
130 |
return null; |
|
131 |
} |
|
132 |
||
133 |
/** |
|
134 |
* Returns <code>null</code> because keys of this type have no encoding. |
|
135 |
* |
|
136 |
* @return <code>null</code> because keys of this type have no encoding. |
|
137 |
*/ |
|
138 |
public byte[] getEncoded() { |
|
139 |
return null; |
|
140 |
} |
|
141 |
||
142 |
/** |
|
143 |
* Returns the client MAC key. |
|
144 |
* |
|
16913 | 145 |
* @return the client MAC key (or null). |
2 | 146 |
*/ |
147 |
public SecretKey getClientMacKey() { |
|
148 |
return clientMacKey; |
|
149 |
} |
|
150 |
||
151 |
/** |
|
152 |
* Return the server MAC key. |
|
153 |
* |
|
16913 | 154 |
* @return the server MAC key (or null). |
2 | 155 |
*/ |
156 |
public SecretKey getServerMacKey() { |
|
157 |
return serverMacKey; |
|
158 |
} |
|
159 |
||
160 |
/** |
|
161 |
* Return the client cipher key (or null). |
|
162 |
* |
|
163 |
* @return the client cipher key (or null). |
|
164 |
*/ |
|
165 |
public SecretKey getClientCipherKey() { |
|
166 |
return clientCipherKey; |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Return the client initialization vector (or null). |
|
171 |
* |
|
172 |
* @return the client initialization vector (or null). |
|
173 |
*/ |
|
174 |
public IvParameterSpec getClientIv() { |
|
175 |
return clientIv; |
|
176 |
} |
|
177 |
||
178 |
/** |
|
179 |
* Return the server cipher key (or null). |
|
180 |
* |
|
181 |
* @return the server cipher key (or null). |
|
182 |
*/ |
|
183 |
public SecretKey getServerCipherKey() { |
|
184 |
return serverCipherKey; |
|
185 |
} |
|
186 |
||
187 |
/** |
|
188 |
* Return the server initialization vector (or null). |
|
189 |
* |
|
190 |
* @return the server initialization vector (or null). |
|
191 |
*/ |
|
192 |
public IvParameterSpec getServerIv() { |
|
193 |
return serverIv; |
|
194 |
} |
|
195 |
||
196 |
} |