提交 6a158108 编写于 作者: I igerasim

8156502: Use short name of SupportedEllipticCurvesExtension.java

Reviewed-by: vinnie
上级 96ed4dfd
...@@ -1381,12 +1381,12 @@ final class ClientHandshaker extends Handshaker { ...@@ -1381,12 +1381,12 @@ final class ClientHandshaker extends Handshaker {
// add elliptic curves and point format extensions // add elliptic curves and point format extensions
if (cipherSuites.containsEC()) { if (cipherSuites.containsEC()) {
SupportedEllipticCurvesExtension ece = EllipticCurvesExtension ece =
SupportedEllipticCurvesExtension.createExtension(algorithmConstraints); EllipticCurvesExtension.createExtension(algorithmConstraints);
if (ece != null) { if (ece != null) {
clientHelloMessage.extensions.add(ece); clientHelloMessage.extensions.add(ece);
clientHelloMessage.extensions.add( clientHelloMessage.extensions.add(
SupportedEllipticPointFormatsExtension.DEFAULT); EllipticPointFormatsExtension.DEFAULT);
} }
} }
......
...@@ -60,7 +60,7 @@ final class ECDHCrypt { ...@@ -60,7 +60,7 @@ final class ECDHCrypt {
try { try {
KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC"); KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC");
ECGenParameterSpec params = ECGenParameterSpec params =
SupportedEllipticCurvesExtension.getECGenParamSpec(curveId); EllipticCurvesExtension.getECGenParamSpec(curveId);
kpg.initialize(params, random); kpg.initialize(params, random);
KeyPair kp = kpg.generateKeyPair(); KeyPair kp = kpg.generateKeyPair();
privateKey = kp.getPrivate(); privateKey = kp.getPrivate();
......
...@@ -41,7 +41,7 @@ import javax.net.ssl.SSLProtocolException; ...@@ -41,7 +41,7 @@ import javax.net.ssl.SSLProtocolException;
import sun.security.action.GetPropertyAction; import sun.security.action.GetPropertyAction;
final class SupportedEllipticCurvesExtension extends HelloExtension { final class EllipticCurvesExtension extends HelloExtension {
/* Class and subclass dynamic debugging support */ /* Class and subclass dynamic debugging support */
private static final Debug debug = Debug.getInstance("ssl"); private static final Debug debug = Debug.getInstance("ssl");
...@@ -226,12 +226,12 @@ final class SupportedEllipticCurvesExtension extends HelloExtension { ...@@ -226,12 +226,12 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
return false; return false;
} }
private SupportedEllipticCurvesExtension(int[] curveIds) { private EllipticCurvesExtension(int[] curveIds) {
super(ExtensionType.EXT_ELLIPTIC_CURVES); super(ExtensionType.EXT_ELLIPTIC_CURVES);
this.curveIds = curveIds; this.curveIds = curveIds;
} }
SupportedEllipticCurvesExtension(HandshakeInStream s, int len) EllipticCurvesExtension(HandshakeInStream s, int len)
throws IOException { throws IOException {
super(ExtensionType.EXT_ELLIPTIC_CURVES); super(ExtensionType.EXT_ELLIPTIC_CURVES);
int k = s.getInt16(); int k = s.getInt16();
...@@ -255,7 +255,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension { ...@@ -255,7 +255,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
return getActiveCurves(constraints) >= 0; return getActiveCurves(constraints) >= 0;
} }
static SupportedEllipticCurvesExtension createExtension( static EllipticCurvesExtension createExtension(
AlgorithmConstraints constraints) { AlgorithmConstraints constraints) {
ArrayList<Integer> idList = new ArrayList<>(supportedCurveIds.length); ArrayList<Integer> idList = new ArrayList<>(supportedCurveIds.length);
...@@ -274,7 +274,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension { ...@@ -274,7 +274,7 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
ids[i++] = id; ids[i++] = id;
} }
return new SupportedEllipticCurvesExtension(ids); return new EllipticCurvesExtension(ids);
} }
return null; return null;
......
/* /*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -31,24 +31,24 @@ import java.util.List; ...@@ -31,24 +31,24 @@ import java.util.List;
import javax.net.ssl.SSLProtocolException; import javax.net.ssl.SSLProtocolException;
final class SupportedEllipticPointFormatsExtension extends HelloExtension { final class EllipticPointFormatsExtension extends HelloExtension {
final static int FMT_UNCOMPRESSED = 0; final static int FMT_UNCOMPRESSED = 0;
final static int FMT_ANSIX962_COMPRESSED_PRIME = 1; final static int FMT_ANSIX962_COMPRESSED_PRIME = 1;
final static int FMT_ANSIX962_COMPRESSED_CHAR2 = 2; final static int FMT_ANSIX962_COMPRESSED_CHAR2 = 2;
static final HelloExtension DEFAULT = static final HelloExtension DEFAULT =
new SupportedEllipticPointFormatsExtension( new EllipticPointFormatsExtension(
new byte[] {FMT_UNCOMPRESSED}); new byte[] {FMT_UNCOMPRESSED});
private final byte[] formats; private final byte[] formats;
private SupportedEllipticPointFormatsExtension(byte[] formats) { private EllipticPointFormatsExtension(byte[] formats) {
super(ExtensionType.EXT_EC_POINT_FORMATS); super(ExtensionType.EXT_EC_POINT_FORMATS);
this.formats = formats; this.formats = formats;
} }
SupportedEllipticPointFormatsExtension(HandshakeInStream s, int len) EllipticPointFormatsExtension(HandshakeInStream s, int len)
throws IOException { throws IOException {
super(ExtensionType.EXT_EC_POINT_FORMATS); super(ExtensionType.EXT_EC_POINT_FORMATS);
formats = s.getBytes8(); formats = s.getBytes8();
......
...@@ -1010,7 +1010,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange { ...@@ -1010,7 +1010,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
ECParameterSpec params = publicKey.getParams(); ECParameterSpec params = publicKey.getParams();
ECPoint point = publicKey.getW(); ECPoint point = publicKey.getW();
pointBytes = JsseJce.encodePoint(point, params.getCurve()); pointBytes = JsseJce.encodePoint(point, params.getCurve());
curveId = SupportedEllipticCurvesExtension.getCurveIndex(params); curveId = EllipticCurvesExtension.getCurveIndex(params);
if (privateKey == null) { if (privateKey == null) {
// ECDH_anon // ECDH_anon
...@@ -1048,13 +1048,11 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange { ...@@ -1048,13 +1048,11 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
// the supported curves during the exchange of the Hello messages. // the supported curves during the exchange of the Hello messages.
if (curveType == CURVE_NAMED_CURVE) { if (curveType == CURVE_NAMED_CURVE) {
curveId = input.getInt16(); curveId = input.getInt16();
if (SupportedEllipticCurvesExtension.isSupported(curveId) if (!EllipticCurvesExtension.isSupported(curveId)) {
== false) {
throw new SSLHandshakeException( throw new SSLHandshakeException(
"Unsupported curveId: " + curveId); "Unsupported curveId: " + curveId);
} }
String curveOid = String curveOid = EllipticCurvesExtension.getCurveOid(curveId);
SupportedEllipticCurvesExtension.getCurveOid(curveId);
if (curveOid == null) { if (curveOid == null) {
throw new SSLHandshakeException( throw new SSLHandshakeException(
"Unknown named curve: " + curveId); "Unknown named curve: " + curveId);
......
...@@ -647,7 +647,7 @@ abstract class Handshaker { ...@@ -647,7 +647,7 @@ abstract class Handshaker {
boolean available = true; boolean available = true;
if (suite.keyExchange.isEC) { if (suite.keyExchange.isEC) {
if (!checkedCurves) { if (!checkedCurves) {
hasCurves = SupportedEllipticCurvesExtension hasCurves = EllipticCurvesExtension
.hasActiveCurves(algorithmConstraints); .hasActiveCurves(algorithmConstraints);
checkedCurves = true; checkedCurves = true;
...@@ -738,7 +738,7 @@ abstract class Handshaker { ...@@ -738,7 +738,7 @@ abstract class Handshaker {
boolean available = true; boolean available = true;
if (suite.keyExchange.isEC) { if (suite.keyExchange.isEC) {
if (!checkedCurves) { if (!checkedCurves) {
hasCurves = SupportedEllipticCurvesExtension hasCurves = EllipticCurvesExtension
.hasActiveCurves(algorithmConstraints); .hasActiveCurves(algorithmConstraints);
checkedCurves = true; checkedCurves = true;
......
/* /*
* Copyright (c) 2006, 2012, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* *
* This code is free software; you can redistribute it and/or modify it * This code is free software; you can redistribute it and/or modify it
...@@ -49,8 +49,8 @@ import javax.net.ssl.*; ...@@ -49,8 +49,8 @@ import javax.net.ssl.*;
* explicitly support. * explicitly support.
* . ServerNameExtension: the server_name extension. * . ServerNameExtension: the server_name extension.
* . SignatureAlgorithmsExtension: the signature_algorithms extension. * . SignatureAlgorithmsExtension: the signature_algorithms extension.
* . SupportedEllipticCurvesExtension: the ECC supported curves extension. * . EllipticCurvesExtension: the ECC supported curves extension.
* . SupportedEllipticPointFormatsExtension: the ECC supported point formats * . EllipticPointFormatsExtension: the ECC supported point formats
* (compressed/uncompressed) extension. * (compressed/uncompressed) extension.
* *
* @since 1.6 * @since 1.6
...@@ -79,10 +79,9 @@ final class HelloExtensions { ...@@ -79,10 +79,9 @@ final class HelloExtensions {
} else if (extType == ExtensionType.EXT_SIGNATURE_ALGORITHMS) { } else if (extType == ExtensionType.EXT_SIGNATURE_ALGORITHMS) {
extension = new SignatureAlgorithmsExtension(s, extlen); extension = new SignatureAlgorithmsExtension(s, extlen);
} else if (extType == ExtensionType.EXT_ELLIPTIC_CURVES) { } else if (extType == ExtensionType.EXT_ELLIPTIC_CURVES) {
extension = new SupportedEllipticCurvesExtension(s, extlen); extension = new EllipticCurvesExtension(s, extlen);
} else if (extType == ExtensionType.EXT_EC_POINT_FORMATS) { } else if (extType == ExtensionType.EXT_EC_POINT_FORMATS) {
extension = extension = new EllipticPointFormatsExtension(s, extlen);
new SupportedEllipticPointFormatsExtension(s, extlen);
} else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) { } else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) {
extension = new RenegotiationInfoExtension(s, extlen); extension = new RenegotiationInfoExtension(s, extlen);
} else { } else {
......
...@@ -93,7 +93,7 @@ final class ServerHandshaker extends Handshaker { ...@@ -93,7 +93,7 @@ final class ServerHandshaker extends Handshaker {
private ProtocolVersion clientRequestedVersion; private ProtocolVersion clientRequestedVersion;
// client supported elliptic curves // client supported elliptic curves
private SupportedEllipticCurvesExtension requestedCurves; private EllipticCurvesExtension requestedCurves;
// the preferable signature algorithm used by ServerKeyExchange message // the preferable signature algorithm used by ServerKeyExchange message
SignatureAndHashAlgorithm preferableSignatureAlgorithm; SignatureAndHashAlgorithm preferableSignatureAlgorithm;
...@@ -683,7 +683,7 @@ final class ServerHandshaker extends Handshaker { ...@@ -683,7 +683,7 @@ final class ServerHandshaker extends Handshaker {
throw new SSLException("Client did not resume a session"); throw new SSLException("Client did not resume a session");
} }
requestedCurves = (SupportedEllipticCurvesExtension) requestedCurves = (EllipticCurvesExtension)
mesg.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES); mesg.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES);
// We only need to handle the "signature_algorithm" extension // We only need to handle the "signature_algorithm" extension
...@@ -1422,7 +1422,7 @@ final class ServerHandshaker extends Handshaker { ...@@ -1422,7 +1422,7 @@ final class ServerHandshaker extends Handshaker {
private boolean setupEphemeralECDHKeys() { private boolean setupEphemeralECDHKeys() {
int index = (requestedCurves != null) ? int index = (requestedCurves != null) ?
requestedCurves.getPreferredCurve(algorithmConstraints) : requestedCurves.getPreferredCurve(algorithmConstraints) :
SupportedEllipticCurvesExtension.getActiveCurves(algorithmConstraints); EllipticCurvesExtension.getActiveCurves(algorithmConstraints);
if (index < 0) { if (index < 0) {
// no match found, cannot use this ciphersuite // no match found, cannot use this ciphersuite
return false; return false;
...@@ -1477,8 +1477,8 @@ final class ServerHandshaker extends Handshaker { ...@@ -1477,8 +1477,8 @@ final class ServerHandshaker extends Handshaker {
return false; return false;
} }
ECParameterSpec params = ((ECPublicKey)publicKey).getParams(); ECParameterSpec params = ((ECPublicKey)publicKey).getParams();
int id = SupportedEllipticCurvesExtension.getCurveIndex(params); int id = EllipticCurvesExtension.getCurveIndex(params);
if ((id <= 0) || !SupportedEllipticCurvesExtension.isSupported(id) || if ((id <= 0) || !EllipticCurvesExtension.isSupported(id) ||
((requestedCurves != null) && !requestedCurves.contains(id))) { ((requestedCurves != null) && !requestedCurves.contains(id))) {
return false; return false;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册