History

My first initial commit with all of mine experimental changes.

Dmitry Kabak (userdima committed 13 years ago

Commit d37b88d1 parent 3f5b46618352 files · +2598093 −-8690Browse files

Showing the changes to java/pkg/sun/security/internal/spec/TlsKeyMaterialSpec.java (1 of 18352 files). Show all

Unified · Split

java/pkg/sun/security/internal/spec/TlsKeyMaterialSpec.java+197−0
@@ -0,0 +1,197 @@
1/*
2 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. 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. Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle 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 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.
24 */
25
26package sun.security.internal.spec;
27
28import java.security.spec.KeySpec;
29
30import javax.crypto.SecretKey;
31import 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
42 * @deprecated Sun JDK internal use only --- WILL BE REMOVED in a future
43 * release.
44 */
45@Deprecated
46public class TlsKeyMaterialSpec implements KeySpec, SecretKey {
47
48 static final long serialVersionUID = 812912859129525028L;
49
50 private final SecretKey clientMacKey, serverMacKey;
51 private final SecretKey clientCipherKey, serverCipherKey;
52 private final IvParameterSpec clientIv, serverIv;
53
54 /**
55 * Constructs a new TlsKeymaterialSpec from the client and server MAC
56 * keys.
57 * This call is equivalent to
58 * <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,
59 * null, null, null, null)</code>.
60 *
61 * @param clientMacKey the client MAC key
62 * @param serverMacKey the server MAC key
63 * @throws NullPointerException if clientMacKey or serverMacKey is null
64 */
65 public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey) {
66 this(clientMacKey, serverMacKey, null, null, null, null);
67 }
68
69 /**
70 * Constructs a new TlsKeymaterialSpec from the client and server MAC
71 * keys and client and server cipher keys.
72 * This call is equivalent to
73 * <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,
74 * clientCipherKey, serverCipherKey, null, null)</code>.
75 *
76 * @param clientMacKey the client MAC key
77 * @param serverMacKey the server MAC key
78 * @param clientCipherKey the client cipher key (or null)
79 * @param serverCipherKey the server cipher key (or null)
80 * @throws NullPointerException if clientMacKey or serverMacKey is null
81 */
82 public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,
83 SecretKey clientCipherKey, SecretKey serverCipherKey) {
84 this(clientMacKey, serverMacKey, clientCipherKey, null,
85 serverCipherKey, null);
86 }
87
88 /**
89 * Constructs a new TlsKeymaterialSpec from the client and server MAC
90 * keys, client and server cipher keys, and client and server
91 * initialization vectors.
92 *
93 * @param clientMacKey the client MAC key
94 * @param serverMacKey the server MAC key
95 * @param clientCipherKey the client cipher key (or null)
96 * @param clientIv the client initialization vector (or null)
97 * @param serverCipherKey the server cipher key (or null)
98 * @param serverIv the server initialization vector (or null)
99 *
100 * @throws NullPointerException if clientMacKey or serverMacKey is null
101 */
102 public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,
103 SecretKey clientCipherKey, IvParameterSpec clientIv,
104 SecretKey serverCipherKey, IvParameterSpec serverIv) {
105 if ((clientMacKey == null) || (serverMacKey == null)) {
106 throw new NullPointerException("MAC keys must not be null");
107 }
108 this.clientMacKey = clientMacKey;
109 this.serverMacKey = serverMacKey;
110 this.clientCipherKey = clientCipherKey;
111 this.serverCipherKey = serverCipherKey;
112 this.clientIv = clientIv;
113 this.serverIv = serverIv;
114 }
115
116 /**
117 * Returns <code>TlsKeyMaterial</code>.
118 *
119 * @return <code>TlsKeyMaterial</code>.
120 */
121 public String getAlgorithm() {
122 return "TlsKeyMaterial";
123 }
124
125 /**
126 * Returns <code>null</code> because keys of this type have no encoding.
127 *
128 * @return <code>null</code> because keys of this type have no encoding.
129 */
130 public String getFormat() {
131 return null;
132 }
133
134 /**
135 * Returns <code>null</code> because keys of this type have no encoding.
136 *
137 * @return <code>null</code> because keys of this type have no encoding.
138 */
139 public byte[] getEncoded() {
140 return null;
141 }
142
143 /**
144 * Returns the client MAC key.
145 *
146 * @return the client MAC key.
147 */
148 public SecretKey getClientMacKey() {
149 return clientMacKey;
150 }
151
152 /**
153 * Return the server MAC key.
154 *
155 * @return the server MAC key.
156 */
157 public SecretKey getServerMacKey() {
158 return serverMacKey;
159 }
160
161 /**
162 * Return the client cipher key (or null).
163 *
164 * @return the client cipher key (or null).
165 */
166 public SecretKey getClientCipherKey() {
167 return clientCipherKey;
168 }
169
170 /**
171 * Return the client initialization vector (or null).
172 *
173 * @return the client initialization vector (or null).
174 */
175 public IvParameterSpec getClientIv() {
176 return clientIv;
177 }
178
179 /**
180 * Return the server cipher key (or null).
181 *
182 * @return the server cipher key (or null).
183 */
184 public SecretKey getServerCipherKey() {
185 return serverCipherKey;
186 }
187
188 /**
189 * Return the server initialization vector (or null).
190 *
191 * @return the server initialization vector (or null).
192 */
193 public IvParameterSpec getServerIv() {
194 return serverIv;
195 }
196
197}