Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/sun/security/internal/spec/TlsKeyMaterialSpec.java
38922 views
/*1* Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.security.internal.spec;2627import java.security.spec.KeySpec;2829import javax.crypto.SecretKey;30import javax.crypto.spec.IvParameterSpec;3132/**33* KeySpec class for SSL/TLS key material.34*35* <p>Instances of this class are returned by the <code>generateKey()</code>36* method of KeyGenerators of the type "TlsKeyMaterial".37* Instances of this class are immutable.38*39* @since 1.640* @author Andreas Sterbenz41* @deprecated Sun JDK internal use only --- WILL BE REMOVED in a future42* release.43*/44@Deprecated45public class TlsKeyMaterialSpec implements KeySpec, SecretKey {4647static final long serialVersionUID = 812912859129525028L;4849private final SecretKey clientMacKey, serverMacKey;50private final SecretKey clientCipherKey, serverCipherKey;51private final IvParameterSpec clientIv, serverIv;5253/**54* Constructs a new TlsKeymaterialSpec from the client and server MAC55* keys.56* This call is equivalent to57* <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,58* null, null, null, null)</code>.59*60* @param clientMacKey the client MAC key (or null)61* @param serverMacKey the server MAC key (or null)62*/63public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey) {64this(clientMacKey, serverMacKey, null, null, null, null);65}6667/**68* Constructs a new TlsKeymaterialSpec from the client and server MAC69* keys and client and server cipher keys.70* This call is equivalent to71* <code>new TlsKeymaterialSpec(clientMacKey, serverMacKey,72* clientCipherKey, serverCipherKey, null, null)</code>.73*74* @param clientMacKey the client MAC key (or null)75* @param serverMacKey the server MAC key (or null)76* @param clientCipherKey the client cipher key (or null)77* @param serverCipherKey the server cipher key (or null)78*/79public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,80SecretKey clientCipherKey, SecretKey serverCipherKey) {81this(clientMacKey, serverMacKey, clientCipherKey, null,82serverCipherKey, null);83}8485/**86* Constructs a new TlsKeymaterialSpec from the client and server MAC87* keys, client and server cipher keys, and client and server88* initialization vectors.89*90* @param clientMacKey the client MAC key (or null)91* @param serverMacKey the server MAC key (or null)92* @param clientCipherKey the client cipher key (or null)93* @param clientIv the client initialization vector (or null)94* @param serverCipherKey the server cipher key (or null)95* @param serverIv the server initialization vector (or null)96*/97public TlsKeyMaterialSpec(SecretKey clientMacKey, SecretKey serverMacKey,98SecretKey clientCipherKey, IvParameterSpec clientIv,99SecretKey serverCipherKey, IvParameterSpec serverIv) {100101this.clientMacKey = clientMacKey;102this.serverMacKey = serverMacKey;103this.clientCipherKey = clientCipherKey;104this.serverCipherKey = serverCipherKey;105this.clientIv = clientIv;106this.serverIv = serverIv;107}108109/**110* Returns <code>TlsKeyMaterial</code>.111*112* @return <code>TlsKeyMaterial</code>.113*/114public String getAlgorithm() {115return "TlsKeyMaterial";116}117118/**119* Returns <code>null</code> because keys of this type have no encoding.120*121* @return <code>null</code> because keys of this type have no encoding.122*/123public String getFormat() {124return null;125}126127/**128* Returns <code>null</code> because keys of this type have no encoding.129*130* @return <code>null</code> because keys of this type have no encoding.131*/132public byte[] getEncoded() {133return null;134}135136/**137* Returns the client MAC key.138*139* @return the client MAC key (or null).140*/141public SecretKey getClientMacKey() {142return clientMacKey;143}144145/**146* Return the server MAC key.147*148* @return the server MAC key (or null).149*/150public SecretKey getServerMacKey() {151return serverMacKey;152}153154/**155* Return the client cipher key (or null).156*157* @return the client cipher key (or null).158*/159public SecretKey getClientCipherKey() {160return clientCipherKey;161}162163/**164* Return the client initialization vector (or null).165*166* @return the client initialization vector (or null).167*/168public IvParameterSpec getClientIv() {169return clientIv;170}171172/**173* Return the server cipher key (or null).174*175* @return the server cipher key (or null).176*/177public SecretKey getServerCipherKey() {178return serverCipherKey;179}180181/**182* Return the server initialization vector (or null).183*184* @return the server initialization vector (or null).185*/186public IvParameterSpec getServerIv() {187return serverIv;188}189190}191192193