8156502: Use short name of SupportedEllipticCurvesExtension.java
Reviewed-by: vinnie
This commit is contained in:
parent
50a7fba4de
commit
5df499dd0b
jdk/src/java.base/share/classes/sun/security/ssl
@ -933,10 +933,8 @@ final class ClientHandshaker extends Handshaker {
|
||||
ECParameterSpec params =
|
||||
((ECPublicKey)publicKey).getParams();
|
||||
int index =
|
||||
SupportedEllipticCurvesExtension.getCurveIndex(
|
||||
params);
|
||||
if (!SupportedEllipticCurvesExtension.isSupported(
|
||||
index)) {
|
||||
EllipticCurvesExtension.getCurveIndex(params);
|
||||
if (!EllipticCurvesExtension.isSupported(index)) {
|
||||
publicKey = null;
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,10 +32,10 @@ import java.util.Map;
|
||||
|
||||
import javax.net.ssl.SSLProtocolException;
|
||||
|
||||
final class SupportedEllipticCurvesExtension extends HelloExtension {
|
||||
final class EllipticCurvesExtension extends HelloExtension {
|
||||
|
||||
// the extension value to send in the ClientHello message
|
||||
static final SupportedEllipticCurvesExtension DEFAULT;
|
||||
static final EllipticCurvesExtension DEFAULT;
|
||||
|
||||
private static final boolean fips;
|
||||
|
||||
@ -56,17 +56,17 @@ final class SupportedEllipticCurvesExtension extends HelloExtension {
|
||||
23, 1, 3, 19, 21, 6, 7, 9, 10, 24, 11, 12, 25, 13, 14,
|
||||
};
|
||||
}
|
||||
DEFAULT = new SupportedEllipticCurvesExtension(ids);
|
||||
DEFAULT = new EllipticCurvesExtension(ids);
|
||||
}
|
||||
|
||||
private final int[] curveIds;
|
||||
|
||||
private SupportedEllipticCurvesExtension(int[] curveIds) {
|
||||
private EllipticCurvesExtension(int[] curveIds) {
|
||||
super(ExtensionType.EXT_ELLIPTIC_CURVES);
|
||||
this.curveIds = curveIds;
|
||||
}
|
||||
|
||||
SupportedEllipticCurvesExtension(HandshakeInStream s, int len)
|
||||
EllipticCurvesExtension(HandshakeInStream s, int len)
|
||||
throws IOException {
|
||||
super(ExtensionType.EXT_ELLIPTIC_CURVES);
|
||||
int k = s.getInt16();
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,24 +31,23 @@ import java.util.List;
|
||||
|
||||
import javax.net.ssl.SSLProtocolException;
|
||||
|
||||
final class SupportedEllipticPointFormatsExtension extends HelloExtension {
|
||||
final class EllipticPointFormatsExtension extends HelloExtension {
|
||||
|
||||
static final int FMT_UNCOMPRESSED = 0;
|
||||
static final int FMT_ANSIX962_COMPRESSED_PRIME = 1;
|
||||
static final int FMT_ANSIX962_COMPRESSED_CHAR2 = 2;
|
||||
|
||||
static final HelloExtension DEFAULT =
|
||||
new SupportedEllipticPointFormatsExtension(
|
||||
new byte[] {FMT_UNCOMPRESSED});
|
||||
new EllipticPointFormatsExtension(new byte[] {FMT_UNCOMPRESSED});
|
||||
|
||||
private final byte[] formats;
|
||||
|
||||
private SupportedEllipticPointFormatsExtension(byte[] formats) {
|
||||
private EllipticPointFormatsExtension(byte[] formats) {
|
||||
super(ExtensionType.EXT_EC_POINT_FORMATS);
|
||||
this.formats = formats;
|
||||
}
|
||||
|
||||
SupportedEllipticPointFormatsExtension(HandshakeInStream s, int len)
|
||||
EllipticPointFormatsExtension(HandshakeInStream s, int len)
|
||||
throws IOException {
|
||||
super(ExtensionType.EXT_EC_POINT_FORMATS);
|
||||
formats = s.getBytes8();
|
@ -314,8 +314,8 @@ static final class ClientHello extends HandshakeMessage {
|
||||
}
|
||||
|
||||
if (cipherSuites.containsEC()) {
|
||||
extensions.add(SupportedEllipticCurvesExtension.DEFAULT);
|
||||
extensions.add(SupportedEllipticPointFormatsExtension.DEFAULT);
|
||||
extensions.add(EllipticCurvesExtension.DEFAULT);
|
||||
extensions.add(EllipticPointFormatsExtension.DEFAULT);
|
||||
}
|
||||
|
||||
clnt_random = new RandomCookie(generator);
|
||||
@ -1401,7 +1401,7 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
ECPoint point = publicKey.getW();
|
||||
pointBytes = JsseJce.encodePoint(point, params.getCurve());
|
||||
curveId = SupportedEllipticCurvesExtension.getCurveIndex(params);
|
||||
curveId = EllipticCurvesExtension.getCurveIndex(params);
|
||||
|
||||
if (privateKey == null) {
|
||||
// ECDH_anon
|
||||
@ -1439,13 +1439,11 @@ class ECDH_ServerKeyExchange extends ServerKeyExchange {
|
||||
// the supported curves during the exchange of the Hello messages.
|
||||
if (curveType == CURVE_NAMED_CURVE) {
|
||||
curveId = input.getInt16();
|
||||
if (SupportedEllipticCurvesExtension.isSupported(curveId)
|
||||
== false) {
|
||||
if (!EllipticCurvesExtension.isSupported(curveId)) {
|
||||
throw new SSLHandshakeException(
|
||||
"Unsupported curveId: " + curveId);
|
||||
}
|
||||
String curveOid =
|
||||
SupportedEllipticCurvesExtension.getCurveOid(curveId);
|
||||
String curveOid = EllipticCurvesExtension.getCurveOid(curveId);
|
||||
if (curveOid == null) {
|
||||
throw new SSLHandshakeException(
|
||||
"Unknown named curve: " + curveId);
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2006, 2015, 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.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -49,8 +49,8 @@ import javax.net.ssl.*;
|
||||
* explicitly support.
|
||||
* . ServerNameExtension: the server_name extension.
|
||||
* . SignatureAlgorithmsExtension: the signature_algorithms extension.
|
||||
* . SupportedEllipticCurvesExtension: the ECC supported curves extension.
|
||||
* . SupportedEllipticPointFormatsExtension: the ECC supported point formats
|
||||
* . EllipticCurvesExtension: the ECC supported curves extension.
|
||||
* . EllipticPointFormatsExtension: the ECC supported point formats
|
||||
* (compressed/uncompressed) extension.
|
||||
* . ALPNExtension: the application_layer_protocol_negotiation extension.
|
||||
*
|
||||
@ -80,10 +80,9 @@ final class HelloExtensions {
|
||||
} else if (extType == ExtensionType.EXT_SIGNATURE_ALGORITHMS) {
|
||||
extension = new SignatureAlgorithmsExtension(s, extlen);
|
||||
} 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) {
|
||||
extension =
|
||||
new SupportedEllipticPointFormatsExtension(s, extlen);
|
||||
extension = new EllipticPointFormatsExtension(s, extlen);
|
||||
} else if (extType == ExtensionType.EXT_RENEGOTIATION_INFO) {
|
||||
extension = new RenegotiationInfoExtension(s, extlen);
|
||||
} else if (extType == ExtensionType.EXT_ALPN) {
|
||||
|
@ -94,7 +94,7 @@ final class ServerHandshaker extends Handshaker {
|
||||
// we remember it for the RSA premaster secret version check
|
||||
private ProtocolVersion clientRequestedVersion;
|
||||
|
||||
private SupportedEllipticCurvesExtension supportedCurves;
|
||||
private EllipticCurvesExtension supportedCurves;
|
||||
|
||||
// the preferable signature algorithm used by ServerKeyExchange message
|
||||
SignatureAndHashAlgorithm preferableSignatureAlgorithm;
|
||||
@ -741,7 +741,7 @@ final class ServerHandshaker extends Handshaker {
|
||||
throw new SSLException("Client did not resume a session");
|
||||
}
|
||||
|
||||
supportedCurves = (SupportedEllipticCurvesExtension)
|
||||
supportedCurves = (EllipticCurvesExtension)
|
||||
mesg.extensions.get(ExtensionType.EXT_ELLIPTIC_CURVES);
|
||||
|
||||
// We only need to handle the "signature_algorithm" extension
|
||||
@ -1577,7 +1577,7 @@ final class ServerHandshaker extends Handshaker {
|
||||
// if the client sent the supported curves extension, pick the
|
||||
// first one that we support;
|
||||
for (int curveId : supportedCurves.curveIds()) {
|
||||
if (SupportedEllipticCurvesExtension.isSupported(curveId)) {
|
||||
if (EllipticCurvesExtension.isSupported(curveId)) {
|
||||
index = curveId;
|
||||
break;
|
||||
}
|
||||
@ -1588,9 +1588,9 @@ final class ServerHandshaker extends Handshaker {
|
||||
}
|
||||
} else {
|
||||
// pick our preference
|
||||
index = SupportedEllipticCurvesExtension.DEFAULT.curveIds()[0];
|
||||
index = EllipticCurvesExtension.DEFAULT.curveIds()[0];
|
||||
}
|
||||
String oid = SupportedEllipticCurvesExtension.getCurveOid(index);
|
||||
String oid = EllipticCurvesExtension.getCurveOid(index);
|
||||
ecdh = new ECDHCrypt(oid, sslContext.getSecureRandom());
|
||||
return true;
|
||||
}
|
||||
@ -1633,15 +1633,15 @@ final class ServerHandshaker extends Handshaker {
|
||||
return false;
|
||||
}
|
||||
// For ECC certs, check whether we support the EC domain parameters.
|
||||
// If the client sent a SupportedEllipticCurves ClientHello extension,
|
||||
// If the client sent a EllipticCurves ClientHello extension,
|
||||
// check against that too.
|
||||
if (keyAlgorithm.equals("EC")) {
|
||||
if (publicKey instanceof ECPublicKey == false) {
|
||||
return false;
|
||||
}
|
||||
ECParameterSpec params = ((ECPublicKey)publicKey).getParams();
|
||||
int index = SupportedEllipticCurvesExtension.getCurveIndex(params);
|
||||
if (SupportedEllipticCurvesExtension.isSupported(index) == false) {
|
||||
int index = EllipticCurvesExtension.getCurveIndex(params);
|
||||
if (!EllipticCurvesExtension.isSupported(index)) {
|
||||
return false;
|
||||
}
|
||||
if ((supportedCurves != null) && !supportedCurves.contains(index)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user