# HG changeset patch # User apetcher # Date 1535555909 14400 # Node ID 55bac0266042dad0797d67e36b95c60c9c6a7e2a # Parent b37a3b5b5a2924bd7114d7878ed645c71e785f0d Code style improvements diff -r b37a3b5b5a29 -r 55bac0266042 src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java --- a/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java Wed Aug 29 10:52:24 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/KAKeyDerivation.java Wed Aug 29 11:18:29 2018 -0400 @@ -53,8 +53,9 @@ } @Override - public SecretKey deriveKey(String algorithm, - AlgorithmParameterSpec params) throws IOException { + public + SecretKey deriveKey(String algorithm, + AlgorithmParameterSpec params) throws IOException { if (!context.negotiatedProtocol.useTLS13PlusSpec()) { return t12DeriveKey(algorithm, params); } else { @@ -62,8 +63,9 @@ } } - private SecretKey t12DeriveKey(String algorithm, - AlgorithmParameterSpec params) throws IOException { + private + SecretKey t12DeriveKey(String algorithm, + AlgorithmParameterSpec params) throws IOException { try { KeyAgreement ka = JsseJce.getKeyAgreement(algorithmName); ka.init(localPrivateKey); @@ -88,8 +90,9 @@ } } - private SecretKey t13DeriveKey(String algorithm, - AlgorithmParameterSpec params) throws IOException { + private + SecretKey t13DeriveKey(String algorithm, + AlgorithmParameterSpec params) throws IOException { try { KeyAgreement ka = JsseJce.getKeyAgreement(algorithmName); ka.init(localPrivateKey); diff -r b37a3b5b5a29 -r 55bac0266042 src/java.base/share/classes/sun/security/ssl/SSLKeyAgreementCredentials.java --- a/src/java.base/share/classes/sun/security/ssl/SSLKeyAgreementCredentials.java Wed Aug 29 10:52:24 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SSLKeyAgreementCredentials.java Wed Aug 29 11:18:29 2018 -0400 @@ -1,3 +1,28 @@ +/* + * Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + package sun.security.ssl; import java.security.PublicKey; diff -r b37a3b5b5a29 -r 55bac0266042 src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java --- a/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Wed Aug 29 10:52:24 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/SupportedGroupsExtension.java Wed Aug 29 11:18:29 2018 -0400 @@ -210,12 +210,14 @@ return ng; } - public abstract SSLKeyAgreementCredentials decodeCredentials(byte[] encoded) + public abstract + SSLKeyAgreementCredentials decodeCredentials(byte[] encoded) throws IOException, GeneralSecurityException; - public abstract SSLPossession createPossession(SecureRandom random); + public abstract SSLPossession createPossession(SecureRandom random); - public abstract SSLKeyDerivation createKeyDerivation(HandshakeContext hc) + public abstract + SSLKeyDerivation createKeyDerivation(HandshakeContext hc) throws IOException; protected abstract Optional getParametersImpl(); @@ -234,7 +236,8 @@ @Override public SSLKeyAgreementCredentials decodeCredentials(byte[] encoded) throws IOException, GeneralSecurityException { - return DHKeyExchange.DHECredentials.valueOf(getNamedGroup(), encoded); + return DHKeyExchange.DHECredentials.valueOf(getNamedGroup(), + encoded); } @Override @@ -322,11 +325,14 @@ @Override protected Optional getParametersImpl() { try { - AlgorithmParameters params = JsseJce.getAlgorithmParameters("DiffieHellman"); - AlgorithmParameterSpec spec = getFFDHEDHParameterSpec(getNamedGroup()); + AlgorithmParameters params = + JsseJce.getAlgorithmParameters("DiffieHellman"); + AlgorithmParameterSpec spec = + getFFDHEDHParameterSpec(getNamedGroup()); params.init(spec); return Optional.of(params); - } catch(InvalidParameterSpecException | NoSuchAlgorithmException ex) { + } catch (InvalidParameterSpecException | + NoSuchAlgorithmException ex) { return Optional.empty(); } } @@ -342,12 +348,14 @@ @Override public SSLKeyAgreementCredentials decodeCredentials(byte[] encoded) throws IOException, GeneralSecurityException { - return ECDHKeyExchange.ECDHECredentials.valueOf(getNamedGroup(), encoded); + return ECDHKeyExchange.ECDHECredentials.valueOf(getNamedGroup(), + encoded); } @Override public SSLPossession createPossession(SecureRandom random) { - return new ECDHKeyExchange.ECDHEPossession(getNamedGroup(), random); + return new ECDHKeyExchange.ECDHEPossession(getNamedGroup(), + random); } @Override @@ -371,11 +379,14 @@ @Override protected Optional getParametersImpl() { try { - AlgorithmParameters params = JsseJce.getAlgorithmParameters("EC"); - AlgorithmParameterSpec spec = new ECGenParameterSpec(getNamedGroup().oid); + AlgorithmParameters params = + JsseJce.getAlgorithmParameters("EC"); + AlgorithmParameterSpec spec = + new ECGenParameterSpec(getNamedGroup().oid); params.init(spec); return Optional.of(params); - } catch(InvalidParameterSpecException | NoSuchAlgorithmException ex) { + } catch (InvalidParameterSpecException | + NoSuchAlgorithmException ex) { return Optional.empty(); } } @@ -390,7 +401,8 @@ @Override public SSLKeyAgreementCredentials decodeCredentials(byte[] encoded) throws IOException, GeneralSecurityException { - return XDHKeyExchange.XDHECredentials.valueOf(getNamedGroup(), encoded); + return XDHKeyExchange.XDHECredentials.valueOf(getNamedGroup(), + encoded); } @Override diff -r b37a3b5b5a29 -r 55bac0266042 src/java.base/share/classes/sun/security/ssl/XDHKeyExchange.java --- a/src/java.base/share/classes/sun/security/ssl/XDHKeyExchange.java Wed Aug 29 10:52:24 2018 -0400 +++ b/src/java.base/share/classes/sun/security/ssl/XDHKeyExchange.java Wed Aug 29 11:18:29 2018 -0400 @@ -69,11 +69,14 @@ return null; } - NamedParameterSpec namedSpec = new NamedParameterSpec(namedGroup.algorithm); - XECPublicKeySpec xecKeySpec = ECUtil.decodeXecPublicKey(encodedPoint, namedSpec); + NamedParameterSpec namedSpec = + new NamedParameterSpec(namedGroup.algorithm); + XECPublicKeySpec xecKeySpec = + ECUtil.decodeXecPublicKey(encodedPoint, namedSpec); KeyFactory factory = JsseJce.getKeyFactory(namedGroup.algorithm); - XECPublicKey publicKey = (XECPublicKey)factory.generatePublic(xecKeySpec); + XECPublicKey publicKey = + (XECPublicKey) factory.generatePublic(xecKeySpec); return new XDHECredentials(publicKey, namedGroup); } } @@ -85,12 +88,13 @@ XDHEPossession(NamedGroup namedGroup, SecureRandom random) { try { - KeyPairGenerator kpg = JsseJce.getKeyPairGenerator(namedGroup.algorithm); + KeyPairGenerator kpg = + JsseJce.getKeyPairGenerator(namedGroup.algorithm); AlgorithmParameterSpec params = namedGroup.getParameterSpec(); kpg.initialize(params, random); KeyPair kp = kpg.generateKeyPair(); privateKey = kp.getPrivate(); - publicKey = (XECPublicKey)kp.getPublic(); + publicKey = (XECPublicKey) kp.getPublic(); } catch (GeneralSecurityException e) { throw new RuntimeException( "Could not generate XDH keypair", e); @@ -102,7 +106,8 @@ @Override public byte[] encode() { try { - return ECUtil.encodeXecPublicKey(publicKey.getU(), publicKey.getParams()); + return ECUtil.encodeXecPublicKey(publicKey.getU(), + publicKey.getParams()); } catch (InvalidParameterSpecException ex) { throw new RuntimeException(ex); } @@ -126,19 +131,19 @@ continue; } - NamedGroup ng = ((XDHEPossession)poss).namedGroup; + NamedGroup ng = ((XDHEPossession) poss).namedGroup; for (SSLCredentials cred : context.handshakeCredentials) { if (!(cred instanceof XDHECredentials)) { continue; } - if (ng.equals(((XDHECredentials)cred).namedGroup)) { - xdheCredentials = (XDHECredentials)cred; + if (ng.equals(((XDHECredentials) cred).namedGroup)) { + xdheCredentials = (XDHECredentials) cred; break; } } if (xdheCredentials != null) { - xdhePossession = (XDHEPossession)poss; + xdhePossession = (XDHEPossession) poss; break; } } diff -r b37a3b5b5a29 -r 55bac0266042 src/java.base/share/classes/sun/security/util/ECUtil.java --- a/src/java.base/share/classes/sun/security/util/ECUtil.java Wed Aug 29 10:52:24 2018 -0400 +++ b/src/java.base/share/classes/sun/security/util/ECUtil.java Wed Aug 29 11:18:29 2018 -0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -242,8 +242,9 @@ return new BigInteger(1, key); } - public static XECPublicKeySpec decodeXecPublicKey(byte[] key, - AlgorithmParameterSpec spec) + public static + XECPublicKeySpec decodeXecPublicKey(byte[] key, + AlgorithmParameterSpec spec) throws InvalidParameterSpecException { XECParameters params = XECParameters.get(