mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 23:04:50 +02:00
8217835: Remove the experimental SunJSSE FIPS compliant mode
Reviewed-by: mullan
This commit is contained in:
parent
5d0ff15a58
commit
fca0af0487
46 changed files with 364 additions and 2350 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2019, 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
|
||||
|
@ -42,21 +42,6 @@ public final class Provider extends SunJSSE {
|
|||
super();
|
||||
}
|
||||
|
||||
// preferred constructor to enable FIPS mode at runtime
|
||||
public Provider(java.security.Provider cryptoProvider) {
|
||||
super(cryptoProvider);
|
||||
}
|
||||
|
||||
// constructor to enable FIPS mode from java.security file
|
||||
public Provider(String cryptoProvider) {
|
||||
super(cryptoProvider);
|
||||
}
|
||||
|
||||
// public for now, but we may want to change it or not document it.
|
||||
public static synchronized boolean isFIPS() {
|
||||
return SunJSSE.isFIPS();
|
||||
}
|
||||
|
||||
/**
|
||||
* Installs the JSSE provider.
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2012, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2012, 2019, 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
|
||||
|
@ -484,7 +484,7 @@ abstract class Authenticator {
|
|||
throw new RuntimeException("Unknown MacAlg " + macAlg);
|
||||
}
|
||||
|
||||
Mac m = JsseJce.getMac(algorithm);
|
||||
Mac m = Mac.getInstance(algorithm);
|
||||
m.init(key);
|
||||
this.macAlg = macAlg;
|
||||
this.mac = m;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -196,13 +196,13 @@ final class CertificateVerify {
|
|||
Signature signer = null;
|
||||
switch (algorithm) {
|
||||
case "RSA":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA);
|
||||
break;
|
||||
case "DSA":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWDSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWDSA);
|
||||
break;
|
||||
case "EC":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWECDSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWECDSA);
|
||||
break;
|
||||
default:
|
||||
throw new SignatureException("Unrecognized algorithm: "
|
||||
|
@ -439,13 +439,13 @@ final class CertificateVerify {
|
|||
Signature signer = null;
|
||||
switch (algorithm) {
|
||||
case "RSA":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA);
|
||||
break;
|
||||
case "DSA":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWDSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWDSA);
|
||||
break;
|
||||
case "EC":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_RAWECDSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_RAWECDSA);
|
||||
break;
|
||||
default:
|
||||
throw new SignatureException("Unrecognized algorithm: "
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2019, 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
|
||||
|
@ -280,7 +280,7 @@ final class DHClientKeyExchange {
|
|||
DHPublicKeySpec spec = new DHPublicKeySpec(
|
||||
new BigInteger(1, ckem.y),
|
||||
params.getP(), params.getG());
|
||||
KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman");
|
||||
KeyFactory kf = KeyFactory.getInstance("DiffieHellman");
|
||||
DHPublicKey peerPublicKey =
|
||||
(DHPublicKey)kf.generatePublic(spec);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ final class DHKeyExchange {
|
|||
return null;
|
||||
}
|
||||
|
||||
KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman");
|
||||
KeyFactory kf = KeyFactory.getInstance("DiffieHellman");
|
||||
DHPublicKeySpec spec = new DHPublicKeySpec(
|
||||
new BigInteger(1, encodedPublic),
|
||||
params.getP(), params.getG());
|
||||
|
@ -106,7 +106,7 @@ final class DHKeyExchange {
|
|||
DHEPossession(NamedGroup namedGroup, SecureRandom random) {
|
||||
try {
|
||||
KeyPairGenerator kpg =
|
||||
JsseJce.getKeyPairGenerator("DiffieHellman");
|
||||
KeyPairGenerator.getInstance("DiffieHellman");
|
||||
DHParameterSpec params =
|
||||
(DHParameterSpec)namedGroup.getParameterSpec();
|
||||
kpg.initialize(params, random);
|
||||
|
@ -129,7 +129,7 @@ final class DHKeyExchange {
|
|||
PredefinedDHParameterSpecs.definedParams.get(keyLength);
|
||||
try {
|
||||
KeyPairGenerator kpg =
|
||||
JsseJce.getKeyPairGenerator("DiffieHellman");
|
||||
KeyPairGenerator.getInstance("DiffieHellman");
|
||||
if (params != null) {
|
||||
kpg.initialize(params, random);
|
||||
} else {
|
||||
|
@ -155,7 +155,7 @@ final class DHKeyExchange {
|
|||
DHEPossession(DHECredentials credentials, SecureRandom random) {
|
||||
try {
|
||||
KeyPairGenerator kpg =
|
||||
JsseJce.getKeyPairGenerator("DiffieHellman");
|
||||
KeyPairGenerator.getInstance("DiffieHellman");
|
||||
kpg.initialize(credentials.popPublicKey.getParams(), random);
|
||||
KeyPair kp = generateDHKeyPair(kpg);
|
||||
if (kp == null) {
|
||||
|
@ -208,7 +208,7 @@ final class DHKeyExchange {
|
|||
params.getP(), params.getG());
|
||||
}
|
||||
try {
|
||||
KeyFactory factory = JsseJce.getKeyFactory("DiffieHellman");
|
||||
KeyFactory factory = KeyFactory.getInstance("DiffieHellman");
|
||||
return factory.getKeySpec(key, DHPublicKeySpec.class);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeySpecException e) {
|
||||
// unlikely
|
||||
|
@ -473,7 +473,7 @@ final class DHKeyExchange {
|
|||
private SecretKey t12DeriveKey(String algorithm,
|
||||
AlgorithmParameterSpec params) throws IOException {
|
||||
try {
|
||||
KeyAgreement ka = JsseJce.getKeyAgreement("DiffieHellman");
|
||||
KeyAgreement ka = KeyAgreement.getInstance("DiffieHellman");
|
||||
ka.init(localPrivateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
SecretKey preMasterSecret =
|
||||
|
@ -499,7 +499,7 @@ final class DHKeyExchange {
|
|||
private SecretKey t13DeriveKey(String algorithm,
|
||||
AlgorithmParameterSpec params) throws IOException {
|
||||
try {
|
||||
KeyAgreement ka = JsseJce.getKeyAgreement("DiffieHellman");
|
||||
KeyAgreement ka = KeyAgreement.getInstance("DiffieHellman");
|
||||
ka.init(localPrivateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
SecretKey sharedSecret =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -420,7 +420,7 @@ final class DHServerKeyExchange {
|
|||
Signature signer = null;
|
||||
switch (keyAlgorithm) {
|
||||
case "DSA":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_DSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_DSA);
|
||||
break;
|
||||
case "RSA":
|
||||
signer = RSASignature.getInstance();
|
||||
|
@ -524,7 +524,7 @@ final class DHServerKeyExchange {
|
|||
// check constraints of EC PublicKey
|
||||
DHPublicKey publicKey;
|
||||
try {
|
||||
KeyFactory kf = JsseJce.getKeyFactory("DiffieHellman");
|
||||
KeyFactory kf = KeyFactory.getInstance("DiffieHellman");
|
||||
DHPublicKeySpec spec = new DHPublicKeySpec(
|
||||
new BigInteger(1, skem.y),
|
||||
new BigInteger(1, skem.p),
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2019, 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,6 +49,7 @@ import sun.security.ssl.SSLHandshake.HandshakeMessage;
|
|||
import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
|
||||
import sun.security.ssl.X509Authentication.X509Credentials;
|
||||
import sun.security.ssl.X509Authentication.X509Possession;
|
||||
import sun.security.util.ECUtil;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
|
@ -78,7 +79,7 @@ final class ECDHClientKeyExchange {
|
|||
|
||||
ECPoint point = publicKey.getW();
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
encodedPoint = JsseJce.encodePoint(point, params.getCurve());
|
||||
encodedPoint = ECUtil.encodePoint(point, params.getCurve());
|
||||
}
|
||||
|
||||
ECDHClientKeyExchangeMessage(HandshakeContext handshakeContext,
|
||||
|
@ -99,10 +100,10 @@ final class ECDHClientKeyExchange {
|
|||
try {
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(encodedPoint, params.getCurve());
|
||||
ECUtil.decodePoint(encodedPoint, params.getCurve());
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(point, params);
|
||||
|
||||
KeyFactory kf = JsseJce.getKeyFactory("EC");
|
||||
KeyFactory kf = KeyFactory.getInstance("EC");
|
||||
ECPublicKey peerPublicKey =
|
||||
(ECPublicKey)kf.generatePublic(spec);
|
||||
|
||||
|
@ -319,10 +320,10 @@ final class ECDHClientKeyExchange {
|
|||
// create the credentials
|
||||
try {
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(cke.encodedPoint, params.getCurve());
|
||||
ECUtil.decodePoint(cke.encodedPoint, params.getCurve());
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(point, params);
|
||||
|
||||
KeyFactory kf = JsseJce.getKeyFactory("EC");
|
||||
KeyFactory kf = KeyFactory.getInstance("EC");
|
||||
ECPublicKey peerPublicKey =
|
||||
(ECPublicKey)kf.generatePublic(spec);
|
||||
|
||||
|
@ -493,10 +494,10 @@ final class ECDHClientKeyExchange {
|
|||
// create the credentials
|
||||
try {
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(cke.encodedPoint, params.getCurve());
|
||||
ECUtil.decodePoint(cke.encodedPoint, params.getCurve());
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(point, params);
|
||||
|
||||
KeyFactory kf = JsseJce.getKeyFactory("EC");
|
||||
KeyFactory kf = KeyFactory.getInstance("EC");
|
||||
ECPublicKey peerPublicKey =
|
||||
(ECPublicKey)kf.generatePublic(spec);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -85,14 +85,14 @@ final class ECDHKeyExchange {
|
|||
}
|
||||
|
||||
ECParameterSpec parameters =
|
||||
JsseJce.getECParameterSpec(namedGroup.oid);
|
||||
ECUtil.getECParameterSpec(null, namedGroup.oid);
|
||||
if (parameters == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ECPoint point = JsseJce.decodePoint(
|
||||
ECPoint point = ECUtil.decodePoint(
|
||||
encodedPoint, parameters.getCurve());
|
||||
KeyFactory factory = JsseJce.getKeyFactory("EC");
|
||||
KeyFactory factory = KeyFactory.getInstance("EC");
|
||||
ECPublicKey publicKey = (ECPublicKey)factory.generatePublic(
|
||||
new ECPublicKeySpec(point, parameters));
|
||||
return new ECDHECredentials(publicKey, namedGroup);
|
||||
|
@ -106,7 +106,7 @@ final class ECDHKeyExchange {
|
|||
|
||||
ECDHEPossession(NamedGroup namedGroup, SecureRandom random) {
|
||||
try {
|
||||
KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC");
|
||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
|
||||
ECGenParameterSpec params =
|
||||
(ECGenParameterSpec)namedGroup.getParameterSpec();
|
||||
kpg.initialize(params, random);
|
||||
|
@ -124,7 +124,7 @@ final class ECDHKeyExchange {
|
|||
ECDHEPossession(ECDHECredentials credentials, SecureRandom random) {
|
||||
ECParameterSpec params = credentials.popPublicKey.getParams();
|
||||
try {
|
||||
KeyPairGenerator kpg = JsseJce.getKeyPairGenerator("EC");
|
||||
KeyPairGenerator kpg = KeyPairGenerator.getInstance("EC");
|
||||
kpg.initialize(params, random);
|
||||
KeyPair kp = kpg.generateKeyPair();
|
||||
privateKey = kp.getPrivate();
|
||||
|
@ -149,7 +149,7 @@ final class ECDHKeyExchange {
|
|||
PublicKey peerPublicKey) throws SSLHandshakeException {
|
||||
|
||||
try {
|
||||
KeyAgreement ka = JsseJce.getKeyAgreement("ECDH");
|
||||
KeyAgreement ka = KeyAgreement.getInstance("ECDH");
|
||||
ka.init(privateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
return ka.generateSecret("TlsPremasterSecret");
|
||||
|
@ -165,8 +165,8 @@ final class ECDHKeyExchange {
|
|||
try {
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(encodedPoint, params.getCurve());
|
||||
KeyFactory kf = JsseJce.getKeyFactory("EC");
|
||||
ECUtil.decodePoint(encodedPoint, params.getCurve());
|
||||
KeyFactory kf = KeyFactory.getInstance("EC");
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(point, params);
|
||||
PublicKey peerPublicKey = kf.generatePublic(spec);
|
||||
return getAgreedSecret(peerPublicKey);
|
||||
|
@ -183,10 +183,10 @@ final class ECDHKeyExchange {
|
|||
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(encodedPoint, params.getCurve());
|
||||
ECUtil.decodePoint(encodedPoint, params.getCurve());
|
||||
ECPublicKeySpec spec = new ECPublicKeySpec(point, params);
|
||||
|
||||
KeyFactory kf = JsseJce.getKeyFactory("EC");
|
||||
KeyFactory kf = KeyFactory.getInstance("EC");
|
||||
ECPublicKey pubKey = (ECPublicKey)kf.generatePublic(spec);
|
||||
|
||||
// check constraints of ECPublicKey
|
||||
|
@ -424,7 +424,7 @@ final class ECDHKeyExchange {
|
|||
private SecretKey t12DeriveKey(String algorithm,
|
||||
AlgorithmParameterSpec params) throws IOException {
|
||||
try {
|
||||
KeyAgreement ka = JsseJce.getKeyAgreement("ECDH");
|
||||
KeyAgreement ka = KeyAgreement.getInstance("ECDH");
|
||||
ka.init(localPrivateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
SecretKey preMasterSecret =
|
||||
|
@ -451,7 +451,7 @@ final class ECDHKeyExchange {
|
|||
private SecretKey t13DeriveKey(String algorithm,
|
||||
AlgorithmParameterSpec params) throws IOException {
|
||||
try {
|
||||
KeyAgreement ka = JsseJce.getKeyAgreement("ECDH");
|
||||
KeyAgreement ka = KeyAgreement.getInstance("ECDH");
|
||||
ka.init(localPrivateKey);
|
||||
ka.doPhase(peerPublicKey, true);
|
||||
SecretKey sharedSecret =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -52,6 +52,7 @@ import sun.security.ssl.SupportedGroupsExtension.NamedGroup;
|
|||
import sun.security.ssl.SupportedGroupsExtension.SupportedGroups;
|
||||
import sun.security.ssl.X509Authentication.X509Credentials;
|
||||
import sun.security.ssl.X509Authentication.X509Possession;
|
||||
import sun.security.util.ECUtil;
|
||||
import sun.security.util.HexDumpEncoder;
|
||||
|
||||
/**
|
||||
|
@ -120,7 +121,7 @@ final class ECDHServerKeyExchange {
|
|||
publicKey = ecdhePossession.publicKey;
|
||||
ECParameterSpec params = publicKey.getParams();
|
||||
ECPoint point = publicKey.getW();
|
||||
publicPoint = JsseJce.encodePoint(point, params.getCurve());
|
||||
publicPoint = ECUtil.encodePoint(point, params.getCurve());
|
||||
|
||||
this.namedGroup = NamedGroup.valueOf(params);
|
||||
if ((namedGroup == null) || (namedGroup.oid == null) ) {
|
||||
|
@ -221,7 +222,7 @@ final class ECDHServerKeyExchange {
|
|||
}
|
||||
|
||||
ECParameterSpec parameters =
|
||||
JsseJce.getECParameterSpec(namedGroup.oid);
|
||||
ECUtil.getECParameterSpec(null, namedGroup.oid);
|
||||
if (parameters == null) {
|
||||
throw chc.conContext.fatal(Alert.ILLEGAL_PARAMETER,
|
||||
"No supported EC parameter: " + namedGroup);
|
||||
|
@ -236,8 +237,8 @@ final class ECDHServerKeyExchange {
|
|||
ECPublicKey ecPublicKey = null;
|
||||
try {
|
||||
ECPoint point =
|
||||
JsseJce.decodePoint(publicPoint, parameters.getCurve());
|
||||
KeyFactory factory = JsseJce.getKeyFactory("EC");
|
||||
ECUtil.decodePoint(publicPoint, parameters.getCurve());
|
||||
KeyFactory factory = KeyFactory.getInstance("EC");
|
||||
ecPublicKey = (ECPublicKey)factory.generatePublic(
|
||||
new ECPublicKeySpec(point, parameters));
|
||||
} catch (NoSuchAlgorithmException |
|
||||
|
@ -446,7 +447,7 @@ final class ECDHServerKeyExchange {
|
|||
Signature signer = null;
|
||||
switch (keyAlgorithm) {
|
||||
case "EC":
|
||||
signer = JsseJce.getSignature(JsseJce.SIGNATURE_ECDSA);
|
||||
signer = Signature.getInstance(JsseJce.SIGNATURE_ECDSA);
|
||||
break;
|
||||
case "RSA":
|
||||
signer = RSASignature.getInstance();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2002, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2019, 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
|
||||
|
@ -69,7 +69,7 @@ final class EphemeralKeyManager {
|
|||
KeyPair kp = keys[index].getKeyPair();
|
||||
if (kp == null) {
|
||||
try {
|
||||
KeyPairGenerator kgen = JsseJce.getKeyPairGenerator("RSA");
|
||||
KeyPairGenerator kgen = KeyPairGenerator.getInstance("RSA");
|
||||
kgen.initialize(length, random);
|
||||
keys[index] = new EphemeralKeyPair(kgen.genKeyPair());
|
||||
kp = keys[index].getKeyPair();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -257,7 +257,7 @@ final class Finished {
|
|||
TlsPrfParameterSpec spec = new TlsPrfParameterSpec(
|
||||
masterSecretKey, tlsLabel, seed, 12,
|
||||
hashAlg.name, hashAlg.hashLength, hashAlg.blockSize);
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(prfAlg);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(prfAlg);
|
||||
kg.init(spec);
|
||||
SecretKey prfKey = kg.generateKey();
|
||||
if (!"RAW".equals(prfKey.getFormat())) {
|
||||
|
@ -309,7 +309,7 @@ final class Finished {
|
|||
TlsPrfParameterSpec spec = new TlsPrfParameterSpec(
|
||||
masterSecretKey, tlsLabel, seed, 12,
|
||||
hashAlg.name, hashAlg.hashLength, hashAlg.blockSize);
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(prfAlg);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(prfAlg);
|
||||
kg.init(spec);
|
||||
SecretKey prfKey = kg.generateKey();
|
||||
if (!"RAW".equals(prfKey.getFormat())) {
|
||||
|
@ -350,7 +350,7 @@ final class Finished {
|
|||
String hmacAlg =
|
||||
"Hmac" + hashAlg.name.replace("-", "");
|
||||
try {
|
||||
Mac hmac = JsseJce.getMac(hmacAlg);
|
||||
Mac hmac = Mac.getInstance(hmacAlg);
|
||||
hmac.init(finishedSecret);
|
||||
return hmac.doFinal(context.handshakeHash.digest());
|
||||
} catch (NoSuchAlgorithmException |InvalidKeyException ex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -62,7 +62,7 @@ final class HKDF {
|
|||
Objects.requireNonNull(hashAlg,
|
||||
"Must provide underlying HKDF Digest algorithm.");
|
||||
hmacAlg = "Hmac" + hashAlg.replace("-", "");
|
||||
hmacObj = JsseJce.getMac(hmacAlg);
|
||||
hmacObj = Mac.getInstance(hmacAlg);
|
||||
hmacLen = hmacObj.getMacLength();
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.io.ByteArrayOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import javax.crypto.SecretKey;
|
||||
|
@ -269,8 +270,13 @@ final class HandshakeHash {
|
|||
private final ByteArrayOutputStream baos;
|
||||
|
||||
S30HandshakeHash(CipherSuite cipherSuite) {
|
||||
this.mdMD5 = JsseJce.getMessageDigest("MD5");
|
||||
this.mdSHA = JsseJce.getMessageDigest("SHA");
|
||||
try {
|
||||
this.mdMD5 = MessageDigest.getInstance("MD5");
|
||||
this.mdSHA = MessageDigest.getInstance("SHA");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm MD5 or SHA is not available", nsae);
|
||||
}
|
||||
|
||||
boolean hasArchived = false;
|
||||
if (mdMD5 instanceof Cloneable) {
|
||||
|
@ -379,7 +385,12 @@ final class HandshakeHash {
|
|||
"MessageDigest does no support clone operation");
|
||||
}
|
||||
} else {
|
||||
md5Clone = JsseJce.getMessageDigest("MD5");
|
||||
try {
|
||||
md5Clone = MessageDigest.getInstance("MD5");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm MD5 is not available", nsae);
|
||||
}
|
||||
md5Clone.update(md5.archived());
|
||||
}
|
||||
|
||||
|
@ -396,7 +407,12 @@ final class HandshakeHash {
|
|||
"MessageDigest does no support clone operation");
|
||||
}
|
||||
} else {
|
||||
shaClone = JsseJce.getMessageDigest("SHA");
|
||||
try {
|
||||
shaClone = MessageDigest.getInstance("SHA");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm SHA is not available", nsae);
|
||||
}
|
||||
shaClone.update(sha.archived());
|
||||
}
|
||||
|
||||
|
@ -447,8 +463,15 @@ final class HandshakeHash {
|
|||
private final ByteArrayOutputStream baos;
|
||||
|
||||
T10HandshakeHash(CipherSuite cipherSuite) {
|
||||
MessageDigest mdMD5 = JsseJce.getMessageDigest("MD5");
|
||||
MessageDigest mdSHA = JsseJce.getMessageDigest("SHA");
|
||||
MessageDigest mdMD5;
|
||||
MessageDigest mdSHA;
|
||||
try {
|
||||
mdMD5 = MessageDigest.getInstance("MD5");
|
||||
mdSHA = MessageDigest.getInstance("SHA");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm MD5 or SHA is not available", nsae);
|
||||
}
|
||||
|
||||
boolean hasArchived = false;
|
||||
if (mdMD5 instanceof Cloneable) {
|
||||
|
@ -514,8 +537,15 @@ final class HandshakeHash {
|
|||
private final ByteArrayOutputStream baos;
|
||||
|
||||
T12HandshakeHash(CipherSuite cipherSuite) {
|
||||
MessageDigest md =
|
||||
JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance(cipherSuite.hashAlg.name);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm " +
|
||||
cipherSuite.hashAlg.name + " is not available", nsae);
|
||||
}
|
||||
|
||||
if (md instanceof Cloneable) {
|
||||
transcriptHash = new CloneableHash(md);
|
||||
this.baos = new ByteArrayOutputStream();
|
||||
|
@ -552,8 +582,15 @@ final class HandshakeHash {
|
|||
private final TranscriptHash transcriptHash;
|
||||
|
||||
T13HandshakeHash(CipherSuite cipherSuite) {
|
||||
MessageDigest md =
|
||||
JsseJce.getMessageDigest(cipherSuite.hashAlg.name);
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance(cipherSuite.hashAlg.name);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"Hash algorithm " +
|
||||
cipherSuite.hashAlg.name + " is not available", nsae);
|
||||
}
|
||||
|
||||
if (md instanceof Cloneable) {
|
||||
transcriptHash = new CloneableHash(md);
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -27,6 +27,7 @@ package sun.security.ssl;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.Arrays;
|
||||
import static sun.security.ssl.ClientHello.ClientHelloMessage;
|
||||
|
@ -143,7 +144,13 @@ abstract class HelloCookieManager {
|
|||
cookieVersion++;
|
||||
}
|
||||
|
||||
MessageDigest md = JsseJce.getMessageDigest("SHA-256");
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"MessageDigest algorithm SHA-256 is not available", nsae);
|
||||
}
|
||||
byte[] helloBytes = clientHello.getHelloCookieBytes();
|
||||
md.update(helloBytes);
|
||||
byte[] cookie = md.digest(secret); // 32 bytes
|
||||
|
@ -169,7 +176,13 @@ abstract class HelloCookieManager {
|
|||
}
|
||||
}
|
||||
|
||||
MessageDigest md = JsseJce.getMessageDigest("SHA-256");
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance("SHA-256");
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"MessageDigest algorithm SHA-256 is not available", nsae);
|
||||
}
|
||||
byte[] helloBytes = clientHello.getHelloCookieBytes();
|
||||
md.update(helloBytes);
|
||||
byte[] target = md.digest(secret); // 32 bytes
|
||||
|
@ -234,8 +247,16 @@ abstract class HelloCookieManager {
|
|||
cookieVersion++; // allow wrapped version number
|
||||
}
|
||||
|
||||
MessageDigest md = JsseJce.getMessageDigest(
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance(
|
||||
context.negotiatedCipherSuite.hashAlg.name);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"MessageDigest algorithm " +
|
||||
context.negotiatedCipherSuite.hashAlg.name +
|
||||
" is not available", nsae);
|
||||
}
|
||||
byte[] headerBytes = clientHello.getHeaderBytes();
|
||||
md.update(headerBytes);
|
||||
byte[] headerCookie = md.digest(secret);
|
||||
|
@ -300,7 +321,14 @@ abstract class HelloCookieManager {
|
|||
}
|
||||
}
|
||||
|
||||
MessageDigest md = JsseJce.getMessageDigest(cs.hashAlg.name);
|
||||
MessageDigest md;
|
||||
try {
|
||||
md = MessageDigest.getInstance(cs.hashAlg.name);
|
||||
} catch (NoSuchAlgorithmException nsae) {
|
||||
throw new RuntimeException(
|
||||
"MessageDigest algorithm " +
|
||||
cs.hashAlg.name + " is not available", nsae);
|
||||
}
|
||||
byte[] headerBytes = clientHello.getHeaderBytes();
|
||||
md.update(headerBytes);
|
||||
byte[] headerCookie = md.digest(secret);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2001, 2019, 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
|
||||
|
@ -29,13 +29,7 @@ import java.math.BigInteger;
|
|||
import java.security.*;
|
||||
import java.security.interfaces.RSAPublicKey;
|
||||
import java.security.spec.*;
|
||||
import java.util.*;
|
||||
import javax.crypto.*;
|
||||
import sun.security.jca.ProviderList;
|
||||
import sun.security.jca.Providers;
|
||||
import static sun.security.ssl.SunJSSE.cryptoProvider;
|
||||
import sun.security.util.ECUtil;
|
||||
import static sun.security.util.SecurityConstants.PROVIDER_VER;
|
||||
|
||||
/**
|
||||
* This class contains a few static methods for interaction with the JCA/JCE
|
||||
|
@ -47,54 +41,6 @@ final class JsseJce {
|
|||
static final boolean ALLOW_ECC =
|
||||
Utilities.getBooleanProperty("com.sun.net.ssl.enableECC", true);
|
||||
|
||||
private static final ProviderList fipsProviderList;
|
||||
|
||||
static {
|
||||
// force FIPS flag initialization
|
||||
// Because isFIPS() is synchronized and cryptoProvider is not modified
|
||||
// after it completes, this also eliminates the need for any further
|
||||
// synchronization when accessing cryptoProvider
|
||||
if (SunJSSE.isFIPS() == false) {
|
||||
fipsProviderList = null;
|
||||
} else {
|
||||
// Setup a ProviderList that can be used by the trust manager
|
||||
// during certificate chain validation. All the crypto must be
|
||||
// from the FIPS provider, but we also allow the required
|
||||
// certificate related services from the SUN provider.
|
||||
Provider sun = Security.getProvider("SUN");
|
||||
if (sun == null) {
|
||||
throw new RuntimeException
|
||||
("FIPS mode: SUN provider must be installed");
|
||||
}
|
||||
Provider sunCerts = new SunCertificates(sun);
|
||||
fipsProviderList = ProviderList.newList(cryptoProvider, sunCerts);
|
||||
}
|
||||
}
|
||||
|
||||
private static final class SunCertificates extends Provider {
|
||||
private static final long serialVersionUID = -3284138292032213752L;
|
||||
|
||||
SunCertificates(final Provider p) {
|
||||
super("SunCertificates", PROVIDER_VER, "SunJSSE internal");
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
// copy certificate related services from the Sun provider
|
||||
for (Map.Entry<Object,Object> entry : p.entrySet()) {
|
||||
String key = (String)entry.getKey();
|
||||
if (key.startsWith("CertPathValidator.")
|
||||
|| key.startsWith("CertPathBuilder.")
|
||||
|| key.startsWith("CertStore.")
|
||||
|| key.startsWith("CertificateFactory.")) {
|
||||
put(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* JCE transformation string for RSA with PKCS#1 v1.5 padding.
|
||||
* Can be used for encryption, decryption, signing, verifying.
|
||||
|
@ -180,153 +126,6 @@ final class JsseJce {
|
|||
return EcAvailability.isAvailable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an JCE cipher implementation for the specified algorithm.
|
||||
*/
|
||||
static Cipher getCipher(String transformation)
|
||||
throws NoSuchAlgorithmException {
|
||||
try {
|
||||
if (cryptoProvider == null) {
|
||||
return Cipher.getInstance(transformation);
|
||||
} else {
|
||||
return Cipher.getInstance(transformation, cryptoProvider);
|
||||
}
|
||||
} catch (NoSuchPaddingException e) {
|
||||
throw new NoSuchAlgorithmException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an JCA signature implementation for the specified algorithm.
|
||||
* The algorithm string should be one of the constants defined
|
||||
* in this class.
|
||||
*/
|
||||
static Signature getSignature(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return Signature.getInstance(algorithm);
|
||||
} else {
|
||||
// reference equality
|
||||
if (algorithm == SIGNATURE_SSLRSA) {
|
||||
// The SunPKCS11 provider currently does not support this
|
||||
// special algorithm. We allow a fallback in this case because
|
||||
// the SunJSSE implementation does the actual crypto using
|
||||
// a NONEwithRSA signature obtained from the cryptoProvider.
|
||||
if (cryptoProvider.getService("Signature", algorithm) == null) {
|
||||
// Calling Signature.getInstance() and catching the
|
||||
// exception would be cleaner, but exceptions are a little
|
||||
// expensive. So we check directly via getService().
|
||||
try {
|
||||
return Signature.getInstance(algorithm, "SunJSSE");
|
||||
} catch (NoSuchProviderException e) {
|
||||
throw new NoSuchAlgorithmException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
return Signature.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static KeyGenerator getKeyGenerator(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return KeyGenerator.getInstance(algorithm);
|
||||
} else {
|
||||
return KeyGenerator.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static KeyPairGenerator getKeyPairGenerator(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return KeyPairGenerator.getInstance(algorithm);
|
||||
} else {
|
||||
return KeyPairGenerator.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static KeyAgreement getKeyAgreement(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return KeyAgreement.getInstance(algorithm);
|
||||
} else {
|
||||
return KeyAgreement.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static Mac getMac(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return Mac.getInstance(algorithm);
|
||||
} else {
|
||||
return Mac.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static KeyFactory getKeyFactory(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return KeyFactory.getInstance(algorithm);
|
||||
} else {
|
||||
return KeyFactory.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static AlgorithmParameters getAlgorithmParameters(String algorithm)
|
||||
throws NoSuchAlgorithmException {
|
||||
if (cryptoProvider == null) {
|
||||
return AlgorithmParameters.getInstance(algorithm);
|
||||
} else {
|
||||
return AlgorithmParameters.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
}
|
||||
|
||||
static SecureRandom getSecureRandom() throws KeyManagementException {
|
||||
if (cryptoProvider == null) {
|
||||
return new SecureRandom();
|
||||
}
|
||||
// Try "PKCS11" first. If that is not supported, iterate through
|
||||
// the provider and return the first working implementation.
|
||||
try {
|
||||
return SecureRandom.getInstance("PKCS11", cryptoProvider);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
// ignore
|
||||
}
|
||||
for (Provider.Service s : cryptoProvider.getServices()) {
|
||||
if (s.getType().equals("SecureRandom")) {
|
||||
try {
|
||||
return SecureRandom.getInstance(
|
||||
s.getAlgorithm(), cryptoProvider);
|
||||
} catch (NoSuchAlgorithmException ee) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new KeyManagementException("FIPS mode: no SecureRandom "
|
||||
+ " implementation found in provider " + cryptoProvider.getName());
|
||||
}
|
||||
|
||||
static MessageDigest getMD5() {
|
||||
return getMessageDigest("MD5");
|
||||
}
|
||||
|
||||
static MessageDigest getSHA() {
|
||||
return getMessageDigest("SHA");
|
||||
}
|
||||
|
||||
static MessageDigest getMessageDigest(String algorithm) {
|
||||
try {
|
||||
if (cryptoProvider == null) {
|
||||
return MessageDigest.getInstance(algorithm);
|
||||
} else {
|
||||
return MessageDigest.getInstance(algorithm, cryptoProvider);
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException
|
||||
("Algorithm " + algorithm + " not available", e);
|
||||
}
|
||||
}
|
||||
|
||||
static int getRSAKeyLength(PublicKey key) {
|
||||
BigInteger modulus;
|
||||
if (key instanceof RSAPublicKey) {
|
||||
|
@ -345,47 +144,13 @@ final class JsseJce {
|
|||
rsaKey.getPublicExponent());
|
||||
}
|
||||
try {
|
||||
KeyFactory factory = JsseJce.getKeyFactory("RSA");
|
||||
KeyFactory factory = KeyFactory.getInstance("RSA");
|
||||
return factory.getKeySpec(key, RSAPublicKeySpec.class);
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
static ECParameterSpec getECParameterSpec(String namedCurveOid) {
|
||||
return ECUtil.getECParameterSpec(cryptoProvider, namedCurveOid);
|
||||
}
|
||||
|
||||
static String getNamedCurveOid(ECParameterSpec params) {
|
||||
return ECUtil.getCurveName(cryptoProvider, params);
|
||||
}
|
||||
|
||||
static ECPoint decodePoint(byte[] encoded, EllipticCurve curve)
|
||||
throws java.io.IOException {
|
||||
return ECUtil.decodePoint(encoded, curve);
|
||||
}
|
||||
|
||||
static byte[] encodePoint(ECPoint point, EllipticCurve curve) {
|
||||
return ECUtil.encodePoint(point, curve);
|
||||
}
|
||||
|
||||
// In FIPS mode, set thread local providers; otherwise a no-op.
|
||||
// Must be paired with endFipsProvider.
|
||||
static Object beginFipsProvider() {
|
||||
if (fipsProviderList == null) {
|
||||
return null;
|
||||
} else {
|
||||
return Providers.beginThreadProviderList(fipsProviderList);
|
||||
}
|
||||
}
|
||||
|
||||
static void endFipsProvider(Object o) {
|
||||
if (fipsProviderList != null) {
|
||||
Providers.endThreadProviderList((ProviderList)o);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// lazy initialization holder class idiom for static default parameters
|
||||
//
|
||||
// See Effective Java Second Edition: Item 71.
|
||||
|
@ -396,12 +161,12 @@ final class JsseJce {
|
|||
static {
|
||||
boolean mediator = true;
|
||||
try {
|
||||
JsseJce.getSignature(SIGNATURE_ECDSA);
|
||||
JsseJce.getSignature(SIGNATURE_RAWECDSA);
|
||||
JsseJce.getKeyAgreement("ECDH");
|
||||
JsseJce.getKeyFactory("EC");
|
||||
JsseJce.getKeyPairGenerator("EC");
|
||||
JsseJce.getAlgorithmParameters("EC");
|
||||
Signature.getInstance(SIGNATURE_ECDSA);
|
||||
Signature.getInstance(SIGNATURE_RAWECDSA);
|
||||
KeyAgreement.getInstance("ECDH");
|
||||
KeyFactory.getInstance("EC");
|
||||
KeyPairGenerator.getInstance("EC");
|
||||
AlgorithmParameters.getInstance("EC");
|
||||
} catch (Exception e) {
|
||||
mediator = false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2019, 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
|
||||
|
@ -61,12 +61,6 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
|
|||
protected void engineInit(KeyStore ks, char[] password) throws
|
||||
KeyStoreException, NoSuchAlgorithmException,
|
||||
UnrecoverableKeyException {
|
||||
if ((ks != null) && SunJSSE.isFIPS()) {
|
||||
if (ks.getProvider() != SunJSSE.cryptoProvider) {
|
||||
throw new KeyStoreException("FIPS mode: KeyStore must be "
|
||||
+ "from provider " + SunJSSE.cryptoProvider.getName());
|
||||
}
|
||||
}
|
||||
keyManager = new SunX509KeyManagerImpl(ks, password);
|
||||
isInitialized = true;
|
||||
}
|
||||
|
@ -91,12 +85,6 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
|
|||
keyManager = new X509KeyManagerImpl(
|
||||
Collections.<Builder>emptyList());
|
||||
} else {
|
||||
if (SunJSSE.isFIPS() &&
|
||||
(ks.getProvider() != SunJSSE.cryptoProvider)) {
|
||||
throw new KeyStoreException(
|
||||
"FIPS mode: KeyStore must be " +
|
||||
"from provider " + SunJSSE.cryptoProvider.getName());
|
||||
}
|
||||
try {
|
||||
Builder builder = Builder.newInstance(ks,
|
||||
new PasswordProtection(password));
|
||||
|
@ -115,10 +103,7 @@ abstract class KeyManagerFactoryImpl extends KeyManagerFactorySpi {
|
|||
throw new InvalidAlgorithmParameterException(
|
||||
"Parameters must be instance of KeyStoreBuilderParameters");
|
||||
}
|
||||
if (SunJSSE.isFIPS()) {
|
||||
throw new InvalidAlgorithmParameterException
|
||||
("FIPS mode: KeyStoreBuilderParameters not supported");
|
||||
}
|
||||
|
||||
List<Builder> builders =
|
||||
((KeyStoreBuilderParameters)params).getParameters();
|
||||
keyManager = new X509KeyManagerImpl(builders);
|
||||
|
|
|
@ -765,7 +765,7 @@ final class PreSharedKeyExtension {
|
|||
String hmacAlg =
|
||||
"Hmac" + hashAlg.name.replace("-", "");
|
||||
try {
|
||||
Mac hmac = JsseJce.getMac(hmacAlg);
|
||||
Mac hmac = Mac.getInstance(hmacAlg);
|
||||
hmac.init(finishedKey);
|
||||
return hmac.doFinal(digest);
|
||||
} catch (NoSuchAlgorithmException | InvalidKeyException ex) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -109,7 +109,7 @@ final class RSAKeyExchange {
|
|||
|
||||
byte[] getEncoded(PublicKey publicKey,
|
||||
SecureRandom secureRandom) throws GeneralSecurityException {
|
||||
Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
|
||||
Cipher cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1);
|
||||
cipher.init(Cipher.WRAP_MODE, publicKey, secureRandom);
|
||||
return cipher.wrap(premasterSecret);
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ final class RSAKeyExchange {
|
|||
ClientHandshakeContext chc) throws GeneralSecurityException {
|
||||
String algorithm = chc.negotiatedProtocol.useTLS12PlusSpec() ?
|
||||
"SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret";
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(algorithm);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(algorithm);
|
||||
TlsRsaPremasterSecretParameterSpec spec =
|
||||
new TlsRsaPremasterSecretParameterSpec(
|
||||
chc.clientHelloVersion,
|
||||
|
@ -136,7 +136,7 @@ final class RSAKeyExchange {
|
|||
|
||||
byte[] encoded = null;
|
||||
boolean needFailover = false;
|
||||
Cipher cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
|
||||
Cipher cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1);
|
||||
try {
|
||||
// Try UNWRAP_MODE mode firstly.
|
||||
cipher.init(Cipher.UNWRAP_MODE, privateKey,
|
||||
|
@ -163,7 +163,7 @@ final class RSAKeyExchange {
|
|||
if (needFailover) {
|
||||
// The cipher might be spoiled by unsuccessful call to init(),
|
||||
// so request a fresh instance
|
||||
cipher = JsseJce.getCipher(JsseJce.CIPHER_RSA_PKCS1);
|
||||
cipher = Cipher.getInstance(JsseJce.CIPHER_RSA_PKCS1);
|
||||
|
||||
// Use DECRYPT_MODE and dispose the previous initialization.
|
||||
cipher.init(Cipher.DECRYPT_MODE, privateKey);
|
||||
|
@ -227,7 +227,7 @@ final class RSAKeyExchange {
|
|||
try {
|
||||
String s = ((clientVersion >= ProtocolVersion.TLS12.id) ?
|
||||
"SunTls12RsaPremasterSecret" : "SunTlsRsaPremasterSecret");
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(s);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(s);
|
||||
kg.init(new TlsRsaPremasterSecretParameterSpec(
|
||||
clientVersion, serverVersion, encodedSecret),
|
||||
generator);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -306,7 +306,7 @@ final class RSAServerKeyExchange {
|
|||
// check constraints of RSA PublicKey
|
||||
RSAPublicKey publicKey;
|
||||
try {
|
||||
KeyFactory kf = JsseJce.getKeyFactory("RSA");
|
||||
KeyFactory kf = KeyFactory.getInstance("RSA");
|
||||
RSAPublicKeySpec spec = new RSAPublicKeySpec(
|
||||
new BigInteger(1, skem.modulus),
|
||||
new BigInteger(1, skem.exponent));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, 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
|
||||
|
@ -53,9 +53,9 @@ public final class RSASignature extends SignatureSpi {
|
|||
|
||||
public RSASignature() throws NoSuchAlgorithmException {
|
||||
super();
|
||||
rawRsa = JsseJce.getSignature(JsseJce.SIGNATURE_RAWRSA);
|
||||
this.mdMD5 = JsseJce.getMessageDigest("MD5");
|
||||
this.mdSHA = JsseJce.getMessageDigest("SHA");
|
||||
rawRsa = Signature.getInstance(JsseJce.SIGNATURE_RAWRSA);
|
||||
this.mdMD5 = MessageDigest.getInstance("MD5");
|
||||
this.mdSHA = MessageDigest.getInstance("SHA");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -66,7 +66,7 @@ public final class RSASignature extends SignatureSpi {
|
|||
* which may be this class.
|
||||
*/
|
||||
static Signature getInstance() throws NoSuchAlgorithmException {
|
||||
return JsseJce.getSignature(JsseJce.SIGNATURE_SSLRSA);
|
||||
return Signature.getInstance(JsseJce.SIGNATURE_SSLRSA);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -851,7 +851,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, params, random);
|
||||
}
|
||||
|
||||
|
@ -933,7 +933,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, params, random);
|
||||
}
|
||||
|
||||
|
@ -1023,7 +1023,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
cipher.init(Cipher.DECRYPT_MODE, key, params, random);
|
||||
}
|
||||
|
||||
|
@ -1175,7 +1175,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
cipher.init(Cipher.ENCRYPT_MODE, key, params, random);
|
||||
}
|
||||
|
||||
|
@ -1291,7 +1291,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
if (params == null) {
|
||||
params = new IvParameterSpec(new byte[sslCipher.ivSize]);
|
||||
}
|
||||
|
@ -1455,7 +1455,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.random = random;
|
||||
if (params == null) {
|
||||
params = new IvParameterSpec(new byte[sslCipher.ivSize]);
|
||||
|
@ -1590,7 +1590,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.fixedIv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -1705,7 +1705,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.fixedIv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -1838,7 +1838,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -1992,7 +1992,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -2133,7 +2133,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -2252,7 +2252,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -2392,7 +2392,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
@ -2534,7 +2534,7 @@ enum SSLCipher {
|
|||
Key key, AlgorithmParameterSpec params,
|
||||
SecureRandom random) throws GeneralSecurityException {
|
||||
super(authenticator, protocolVersion);
|
||||
this.cipher = JsseJce.getCipher(algorithm);
|
||||
this.cipher = Cipher.getInstance(algorithm);
|
||||
this.tagSize = sslCipher.tagSize;
|
||||
this.key = key;
|
||||
this.iv = ((IvParameterSpec)params).getIV();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -36,6 +36,7 @@ import java.util.Collections;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.function.BiFunction;
|
||||
import javax.crypto.KeyGenerator;
|
||||
import javax.net.ssl.HandshakeCompletedListener;
|
||||
import javax.net.ssl.SNIMatcher;
|
||||
import javax.net.ssl.SNIServerName;
|
||||
|
@ -104,7 +105,7 @@ final class SSLConfiguration implements Cloneable {
|
|||
"jdk.tls.useExtendedMasterSecret", true);
|
||||
if (supportExtendedMasterSecret) {
|
||||
try {
|
||||
JsseJce.getKeyGenerator("SunTlsExtendedMasterSecret");
|
||||
KeyGenerator.getInstance("SunTlsExtendedMasterSecret");
|
||||
} catch (NoSuchAlgorithmException nae) {
|
||||
supportExtendedMasterSecret = false;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2019, 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
|
||||
|
@ -94,14 +94,8 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
trustManager = chooseTrustManager(tm);
|
||||
|
||||
if (sr == null) {
|
||||
secureRandom = JsseJce.getSecureRandom();
|
||||
secureRandom = new SecureRandom();
|
||||
} else {
|
||||
if (SunJSSE.isFIPS() &&
|
||||
(sr.getProvider() != SunJSSE.cryptoProvider)) {
|
||||
throw new KeyManagementException
|
||||
("FIPS mode: SecureRandom must be from provider "
|
||||
+ SunJSSE.cryptoProvider.getName());
|
||||
}
|
||||
secureRandom = sr;
|
||||
}
|
||||
|
||||
|
@ -127,12 +121,6 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
// We only use the first instance of X509TrustManager passed to us.
|
||||
for (int i = 0; tm != null && i < tm.length; i++) {
|
||||
if (tm[i] instanceof X509TrustManager) {
|
||||
if (SunJSSE.isFIPS() &&
|
||||
!(tm[i] instanceof X509TrustManagerImpl)) {
|
||||
throw new KeyManagementException
|
||||
("FIPS mode: only SunJSSE TrustManagers may be used");
|
||||
}
|
||||
|
||||
if (tm[i] instanceof X509ExtendedTrustManager) {
|
||||
return (X509TrustManager)tm[i];
|
||||
} else {
|
||||
|
@ -153,20 +141,7 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
if (!(km instanceof X509KeyManager)) {
|
||||
continue;
|
||||
}
|
||||
if (SunJSSE.isFIPS()) {
|
||||
// In FIPS mode, require that one of SunJSSE's own keymanagers
|
||||
// is used. Otherwise, we cannot be sure that only keys from
|
||||
// the FIPS token are used.
|
||||
if ((km instanceof X509KeyManagerImpl)
|
||||
|| (km instanceof SunX509KeyManagerImpl)) {
|
||||
return (X509ExtendedKeyManager)km;
|
||||
} else {
|
||||
// throw exception, we don't want to silently use the
|
||||
// dummy keymanager without telling the user.
|
||||
throw new KeyManagementException
|
||||
("FIPS mode: only SunJSSE KeyManagers may be used");
|
||||
}
|
||||
}
|
||||
|
||||
if (km instanceof X509ExtendedKeyManager) {
|
||||
return (X509ExtendedKeyManager)km;
|
||||
}
|
||||
|
@ -548,41 +523,24 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
private static final List<CipherSuite> serverDefaultCipherSuites;
|
||||
|
||||
static {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
supportedProtocols = Arrays.asList(
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
);
|
||||
supportedProtocols = Arrays.asList(
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
);
|
||||
|
||||
serverDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
});
|
||||
} else {
|
||||
supportedProtocols = Arrays.asList(
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
);
|
||||
|
||||
serverDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
});
|
||||
}
|
||||
serverDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
});
|
||||
|
||||
supportedCipherSuites = getApplicableSupportedCipherSuites(
|
||||
supportedProtocols);
|
||||
|
@ -626,23 +584,14 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
}
|
||||
|
||||
static ProtocolVersion[] getSupportedProtocols() {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
return new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
};
|
||||
} else {
|
||||
return new ProtocolVersion[]{
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
};
|
||||
}
|
||||
return new ProtocolVersion[]{
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30,
|
||||
ProtocolVersion.SSL20Hello
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -656,18 +605,11 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
private static final List<CipherSuite> clientDefaultCipherSuites;
|
||||
|
||||
static {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS10
|
||||
});
|
||||
} else {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
}
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
|
||||
clientDefaultCipherSuites = getApplicableEnabledCipherSuites(
|
||||
clientDefaultProtocols, true);
|
||||
|
@ -694,20 +636,12 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
private static final List<CipherSuite> clientDefaultCipherSuites;
|
||||
|
||||
static {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
});
|
||||
} else {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
}
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
|
||||
clientDefaultCipherSuites = getApplicableEnabledCipherSuites(
|
||||
clientDefaultProtocols, true);
|
||||
|
@ -735,22 +669,13 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
private static final List<CipherSuite> clientDefaultCipherSuites;
|
||||
|
||||
static {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
});
|
||||
} else {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
}
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
|
||||
clientDefaultCipherSuites = getApplicableEnabledCipherSuites(
|
||||
clientDefaultProtocols, true);
|
||||
|
@ -777,24 +702,14 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
private static final List<CipherSuite> clientDefaultCipherSuites;
|
||||
|
||||
static {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
});
|
||||
} else {
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
}
|
||||
clientDefaultProtocols = getAvailableProtocols(
|
||||
new ProtocolVersion[] {
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
});
|
||||
|
||||
clientDefaultCipherSuites = getApplicableEnabledCipherSuites(
|
||||
clientDefaultProtocols, true);
|
||||
|
@ -866,16 +781,6 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
" is not a supported SSL protocol name");
|
||||
}
|
||||
|
||||
if (SunJSSE.isFIPS() &&
|
||||
((pv == ProtocolVersion.SSL30) ||
|
||||
(pv == ProtocolVersion.SSL20Hello))) {
|
||||
reservedException = new IllegalArgumentException(
|
||||
propname + ": " + pv +
|
||||
" is not FIPS compliant");
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
// ignore duplicated protocols
|
||||
if (!arrayList.contains(pv)) {
|
||||
arrayList.add(pv);
|
||||
|
@ -955,22 +860,13 @@ public abstract class SSLContextImpl extends SSLContextSpi {
|
|||
}
|
||||
|
||||
static ProtocolVersion[] getProtocols() {
|
||||
if (SunJSSE.isFIPS()) {
|
||||
return new ProtocolVersion[]{
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10
|
||||
};
|
||||
} else {
|
||||
return new ProtocolVersion[]{
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
};
|
||||
}
|
||||
return new ProtocolVersion[]{
|
||||
ProtocolVersion.TLS13,
|
||||
ProtocolVersion.TLS12,
|
||||
ProtocolVersion.TLS11,
|
||||
ProtocolVersion.TLS10,
|
||||
ProtocolVersion.SSL30
|
||||
};
|
||||
}
|
||||
|
||||
protected CustomizedTLSContext() {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -145,7 +145,7 @@ enum SSLMasterKeyDerivation implements SSLKeyDerivationGenerator {
|
|||
}
|
||||
|
||||
try {
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(masterAlg);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(masterAlg);
|
||||
kg.init(spec);
|
||||
return kg.generateKey();
|
||||
} catch (InvalidAlgorithmParameterException |
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2018, 2019, 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
|
||||
|
@ -280,7 +280,7 @@ enum SSLTrafficKeyDerivation implements SSLKeyDerivationGenerator {
|
|||
hashAlg.name, hashAlg.hashLength, hashAlg.blockSize);
|
||||
|
||||
try {
|
||||
KeyGenerator kg = JsseJce.getKeyGenerator(keyMaterialAlg);
|
||||
KeyGenerator kg = KeyGenerator.getInstance(keyMaterialAlg);
|
||||
kg.init(spec);
|
||||
|
||||
this.keyMaterialSpec = (TlsKeyMaterialSpec)kg.generateKey();
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -194,7 +194,7 @@ enum SignatureScheme {
|
|||
|
||||
boolean mediator = true;
|
||||
try {
|
||||
Signature signer = JsseJce.getSignature("RSASSA-PSS");
|
||||
Signature signer = Signature.getInstance("RSASSA-PSS");
|
||||
signer.setParameter(pssParamSpec);
|
||||
} catch (InvalidAlgorithmParameterException |
|
||||
NoSuchAlgorithmException exp) {
|
||||
|
@ -275,7 +275,7 @@ enum SignatureScheme {
|
|||
mediator = signAlgParamSpec.isAvailable;
|
||||
} else {
|
||||
try {
|
||||
JsseJce.getSignature(algorithm);
|
||||
Signature.getInstance(algorithm);
|
||||
} catch (Exception e) {
|
||||
mediator = false;
|
||||
if (SSLLogger.isOn && SSLLogger.isOn("ssl,handshake")) {
|
||||
|
@ -466,7 +466,7 @@ enum SignatureScheme {
|
|||
return null;
|
||||
}
|
||||
|
||||
Signature signer = JsseJce.getSignature(algorithm);
|
||||
Signature signer = Signature.getInstance(algorithm);
|
||||
if (key instanceof PublicKey) {
|
||||
signer.initVerify((PublicKey)(key));
|
||||
} else {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2019, 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
|
||||
|
@ -66,97 +66,16 @@ public abstract class SunJSSE extends java.security.Provider {
|
|||
"(PKCS12, SunX509/PKIX key/trust factories, " +
|
||||
"SSLv3/TLSv1/TLSv1.1/TLSv1.2/TLSv1.3/DTLSv1.0/DTLSv1.2)";
|
||||
|
||||
private static String fipsInfo =
|
||||
"Sun JSSE provider (FIPS mode, crypto provider ";
|
||||
|
||||
// tri-valued flag:
|
||||
// null := no final decision made
|
||||
// false := data structures initialized in non-FIPS mode
|
||||
// true := data structures initialized in FIPS mode
|
||||
private static Boolean fips;
|
||||
|
||||
// the FIPS certificate crypto provider that we use to perform all crypto
|
||||
// operations. null in non-FIPS mode
|
||||
static java.security.Provider cryptoProvider;
|
||||
|
||||
protected static synchronized boolean isFIPS() {
|
||||
if (fips == null) {
|
||||
fips = false;
|
||||
}
|
||||
return fips;
|
||||
}
|
||||
|
||||
// ensure we can use FIPS mode using the specified crypto provider.
|
||||
// enable FIPS mode if not already enabled.
|
||||
private static synchronized void ensureFIPS(java.security.Provider p) {
|
||||
if (fips == null) {
|
||||
fips = true;
|
||||
cryptoProvider = p;
|
||||
} else {
|
||||
if (fips == false) {
|
||||
throw new ProviderException
|
||||
("SunJSSE already initialized in non-FIPS mode");
|
||||
}
|
||||
if (cryptoProvider != p) {
|
||||
throw new ProviderException
|
||||
("SunJSSE already initialized with FIPS crypto provider "
|
||||
+ cryptoProvider);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// standard constructor
|
||||
protected SunJSSE() {
|
||||
super("SunJSSE", PROVIDER_VER, info);
|
||||
subclassCheck();
|
||||
if (Boolean.TRUE.equals(fips)) {
|
||||
throw new ProviderException
|
||||
("SunJSSE is already initialized in FIPS mode");
|
||||
}
|
||||
registerAlgorithms(false);
|
||||
registerAlgorithms();
|
||||
}
|
||||
|
||||
// preferred constructor to enable FIPS mode at runtime
|
||||
protected SunJSSE(java.security.Provider cryptoProvider){
|
||||
this(checkNull(cryptoProvider), cryptoProvider.getName());
|
||||
}
|
||||
|
||||
// constructor to enable FIPS mode from java.security file
|
||||
protected SunJSSE(String cryptoProvider){
|
||||
this(null, checkNull(cryptoProvider));
|
||||
}
|
||||
|
||||
private static <T> T checkNull(T t) {
|
||||
if (t == null) {
|
||||
throw new ProviderException("cryptoProvider must not be null");
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
private SunJSSE(java.security.Provider cryptoProvider,
|
||||
String providerName) {
|
||||
super("SunJSSE", PROVIDER_VER, fipsInfo + providerName + ")");
|
||||
subclassCheck();
|
||||
if (cryptoProvider == null) {
|
||||
// Calling Security.getProvider() will cause other providers to be
|
||||
// loaded. That is not good but unavoidable here.
|
||||
cryptoProvider = Security.getProvider(providerName);
|
||||
if (cryptoProvider == null) {
|
||||
throw new ProviderException
|
||||
("Crypto provider not installed: " + providerName);
|
||||
}
|
||||
}
|
||||
ensureFIPS(cryptoProvider);
|
||||
registerAlgorithms(true);
|
||||
}
|
||||
|
||||
private void registerAlgorithms(final boolean isfips) {
|
||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
||||
@Override
|
||||
public Object run() {
|
||||
doRegister(isfips);
|
||||
return null;
|
||||
}
|
||||
private void registerAlgorithms() {
|
||||
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||
doRegister();
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -165,14 +84,13 @@ public abstract class SunJSSE extends java.security.Provider {
|
|||
putService(new Provider.Service(this, type, algo, cn, aliases, attrs));
|
||||
}
|
||||
|
||||
private void doRegister(boolean isfips) {
|
||||
if (isfips == false) {
|
||||
Iterator<Provider.Service> rsaIter =
|
||||
new SunRsaSignEntries(this).iterator();
|
||||
while (rsaIter.hasNext()) {
|
||||
putService(rsaIter.next());
|
||||
}
|
||||
private void doRegister() {
|
||||
Iterator<Provider.Service> rsaIter =
|
||||
new SunRsaSignEntries(this).iterator();
|
||||
while (rsaIter.hasNext()) {
|
||||
putService(rsaIter.next());
|
||||
}
|
||||
|
||||
ps("Signature", "MD5andSHA1withRSA",
|
||||
"sun.security.ssl.RSASignature", null, null);
|
||||
|
||||
|
@ -183,14 +101,15 @@ public abstract class SunJSSE extends java.security.Provider {
|
|||
createAliases("PKIX"), null);
|
||||
|
||||
ps("TrustManagerFactory", "SunX509",
|
||||
"sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory", null, null);
|
||||
"sun.security.ssl.TrustManagerFactoryImpl$SimpleFactory",
|
||||
null, null);
|
||||
ps("TrustManagerFactory", "PKIX",
|
||||
"sun.security.ssl.TrustManagerFactoryImpl$PKIXFactory",
|
||||
createAliases("SunPKIX", "X509", "X.509"), null);
|
||||
|
||||
ps("SSLContext", "TLSv1",
|
||||
"sun.security.ssl.SSLContextImpl$TLS10Context",
|
||||
(isfips? null : createAliases("SSLv3")), null);
|
||||
createAliases("SSLv3"), null);
|
||||
ps("SSLContext", "TLSv1.1",
|
||||
"sun.security.ssl.SSLContextImpl$TLS11Context", null, null);
|
||||
ps("SSLContext", "TLSv1.2",
|
||||
|
@ -199,7 +118,7 @@ public abstract class SunJSSE extends java.security.Provider {
|
|||
"sun.security.ssl.SSLContextImpl$TLS13Context", null, null);
|
||||
ps("SSLContext", "TLS",
|
||||
"sun.security.ssl.SSLContextImpl$TLSContext",
|
||||
(isfips? null : createAliases("SSL")), null);
|
||||
createAliases("SSL"), null);
|
||||
|
||||
ps("SSLContext", "DTLSv1.0",
|
||||
"sun.security.ssl.SSLContextImpl$DTLS10Context", null, null);
|
||||
|
@ -225,12 +144,4 @@ public abstract class SunJSSE extends java.security.Provider {
|
|||
throw new AssertionError("Illegal subclass: " + getClass());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
protected final void finalize() throws Throwable {
|
||||
// empty
|
||||
super.finalize();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2019, 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
|
||||
|
@ -52,6 +52,7 @@ import static sun.security.ssl.SSLExtension.EE_SUPPORTED_GROUPS;
|
|||
import sun.security.ssl.SSLExtension.ExtensionConsumer;
|
||||
import sun.security.ssl.SSLExtension.SSLExtensionSpec;
|
||||
import sun.security.ssl.SSLHandshake.HandshakeMessage;
|
||||
import sun.security.util.ECUtil;
|
||||
|
||||
/**
|
||||
* Pack of the "supported_groups" extensions [RFC 4492/7919].
|
||||
|
@ -158,15 +159,23 @@ final class SupportedGroupsExtension {
|
|||
}
|
||||
|
||||
static enum NamedGroupType {
|
||||
NAMED_GROUP_ECDHE, // Elliptic Curve Groups (ECDHE)
|
||||
NAMED_GROUP_FFDHE, // Finite Field Groups (DHE)
|
||||
NAMED_GROUP_XDH, // Finite Field Groups (XDH)
|
||||
NAMED_GROUP_ARBITRARY, // arbitrary prime and curves (ECDHE)
|
||||
NAMED_GROUP_NONE; // Not predefined named group
|
||||
NAMED_GROUP_ECDHE ("EC"),
|
||||
NAMED_GROUP_FFDHE ("DiffieHellman"),
|
||||
NAMED_GROUP_X25519 ("x25519"),
|
||||
NAMED_GROUP_X448 ("x448"),
|
||||
NAMED_GROUP_ARBITRARY ("EC"),
|
||||
NAMED_GROUP_NONE ("");
|
||||
|
||||
private final String algorithm;
|
||||
|
||||
private NamedGroupType(String algorithm) {
|
||||
this.algorithm = algorithm;
|
||||
}
|
||||
|
||||
boolean isSupported(List<CipherSuite> cipherSuites) {
|
||||
for (CipherSuite cs : cipherSuites) {
|
||||
if (cs.keyExchange == null || cs.keyExchange.groupType == this) {
|
||||
if (cs.keyExchange == null ||
|
||||
cs.keyExchange.groupType == this) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -180,108 +189,142 @@ final class SupportedGroupsExtension {
|
|||
//
|
||||
// See sun.security.util.CurveDB for the OIDs
|
||||
// NIST K-163
|
||||
SECT163_K1 (0x0001, "sect163k1", "1.3.132.0.1", true,
|
||||
SECT163_K1 (0x0001, "sect163k1", "1.3.132.0.1",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECT163_R1 (0x0002, "sect163r1", "1.3.132.0.2", false,
|
||||
SECT163_R1 (0x0002, "sect163r1", "1.3.132.0.2",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST B-163
|
||||
SECT163_R2 (0x0003, "sect163r2", "1.3.132.0.15", true,
|
||||
SECT163_R2 (0x0003, "sect163r2", "1.3.132.0.15",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECT193_R1 (0x0004, "sect193r1", "1.3.132.0.24", false,
|
||||
SECT193_R1 (0x0004, "sect193r1", "1.3.132.0.24",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECT193_R2 (0x0005, "sect193r2", "1.3.132.0.25", false,
|
||||
SECT193_R2 (0x0005, "sect193r2", "1.3.132.0.25",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST K-233
|
||||
SECT233_K1 (0x0006, "sect233k1", "1.3.132.0.26", true,
|
||||
SECT233_K1 (0x0006, "sect233k1", "1.3.132.0.26",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST B-233
|
||||
SECT233_R1 (0x0007, "sect233r1", "1.3.132.0.27", true,
|
||||
SECT233_R1 (0x0007, "sect233r1", "1.3.132.0.27",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECT239_K1 (0x0008, "sect239k1", "1.3.132.0.3", false,
|
||||
SECT239_K1 (0x0008, "sect239k1", "1.3.132.0.3",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST K-283
|
||||
SECT283_K1 (0x0009, "sect283k1", "1.3.132.0.16", true,
|
||||
SECT283_K1 (0x0009, "sect283k1", "1.3.132.0.16",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST B-283
|
||||
SECT283_R1 (0x000A, "sect283r1", "1.3.132.0.17", true,
|
||||
SECT283_R1 (0x000A, "sect283r1", "1.3.132.0.17",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST K-409
|
||||
SECT409_K1 (0x000B, "sect409k1", "1.3.132.0.36", true,
|
||||
SECT409_K1 (0x000B, "sect409k1", "1.3.132.0.36",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST B-409
|
||||
SECT409_R1 (0x000C, "sect409r1", "1.3.132.0.37", true,
|
||||
SECT409_R1 (0x000C, "sect409r1", "1.3.132.0.37",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST K-571
|
||||
SECT571_K1 (0x000D, "sect571k1", "1.3.132.0.38", true,
|
||||
SECT571_K1 (0x000D, "sect571k1", "1.3.132.0.38",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST B-571
|
||||
SECT571_R1 (0x000E, "sect571r1", "1.3.132.0.39", true,
|
||||
SECT571_R1 (0x000E, "sect571r1", "1.3.132.0.39",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP160_K1 (0x000F, "secp160k1", "1.3.132.0.9", false,
|
||||
SECP160_K1 (0x000F, "secp160k1", "1.3.132.0.9",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP160_R1 (0x0010, "secp160r1", "1.3.132.0.8", false,
|
||||
SECP160_R1 (0x0010, "secp160r1", "1.3.132.0.8",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP160_R2 (0x0011, "secp160r2", "1.3.132.0.30", false,
|
||||
SECP160_R2 (0x0011, "secp160r2", "1.3.132.0.30",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP192_K1 (0x0012, "secp192k1", "1.3.132.0.31", false,
|
||||
SECP192_K1 (0x0012, "secp192k1", "1.3.132.0.31",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST P-192
|
||||
SECP192_R1 (0x0013, "secp192r1", "1.2.840.10045.3.1.1", true,
|
||||
SECP192_R1 (0x0013, "secp192r1", "1.2.840.10045.3.1.1",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP224_K1 (0x0014, "secp224k1", "1.3.132.0.32", false,
|
||||
SECP224_K1 (0x0014, "secp224k1", "1.3.132.0.32",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
// NIST P-224
|
||||
SECP224_R1 (0x0015, "secp224r1", "1.3.132.0.33", true,
|
||||
SECP224_R1 (0x0015, "secp224r1", "1.3.132.0.33",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
SECP256_K1 (0x0016, "secp256k1", "1.3.132.0.10", false,
|
||||
SECP256_K1 (0x0016, "secp256k1", "1.3.132.0.10",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
|
||||
// NIST P-256
|
||||
SECP256_R1 (0x0017, "secp256r1", "1.2.840.10045.3.1.7", true,
|
||||
SECP256_R1 (0x0017, "secp256r1", "1.2.840.10045.3.1.7",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
|
||||
// NIST P-384
|
||||
SECP384_R1 (0x0018, "secp384r1", "1.3.132.0.34", true,
|
||||
SECP384_R1 (0x0018, "secp384r1", "1.3.132.0.34",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
|
||||
// NIST P-521
|
||||
SECP521_R1 (0x0019, "secp521r1", "1.3.132.0.35", true,
|
||||
SECP521_R1 (0x0019, "secp521r1", "1.3.132.0.35",
|
||||
NamedGroupType.NAMED_GROUP_ECDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
|
||||
// x25519 and x448
|
||||
X25519 (0x001D, "x25519", true, "x25519",
|
||||
X25519 (0x001D, "x25519", null,
|
||||
NamedGroupType.NAMED_GROUP_X25519,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
X448 (0x001E, "x448", true, "x448",
|
||||
X448 (0x001E, "x448", null,
|
||||
NamedGroupType.NAMED_GROUP_X448,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
|
||||
// Finite Field Diffie-Hellman Ephemeral Parameters (RFC 7919)
|
||||
FFDHE_2048 (0x0100, "ffdhe2048", true,
|
||||
FFDHE_2048 (0x0100, "ffdhe2048", null,
|
||||
NamedGroupType.NAMED_GROUP_FFDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
FFDHE_3072 (0x0101, "ffdhe3072", true,
|
||||
FFDHE_3072 (0x0101, "ffdhe3072", null,
|
||||
NamedGroupType.NAMED_GROUP_FFDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
FFDHE_4096 (0x0102, "ffdhe4096", true,
|
||||
FFDHE_4096 (0x0102, "ffdhe4096", null,
|
||||
NamedGroupType.NAMED_GROUP_FFDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
FFDHE_6144 (0x0103, "ffdhe6144", true,
|
||||
FFDHE_6144 (0x0103, "ffdhe6144", null,
|
||||
NamedGroupType.NAMED_GROUP_FFDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
FFDHE_8192 (0x0104, "ffdhe8192", true,
|
||||
FFDHE_8192 (0x0104, "ffdhe8192", null,
|
||||
NamedGroupType.NAMED_GROUP_FFDHE,
|
||||
ProtocolVersion.PROTOCOLS_TO_13),
|
||||
|
||||
// Elliptic Curves (RFC 4492)
|
||||
//
|
||||
// arbitrary prime and characteristic-2 curves
|
||||
ARBITRARY_PRIME (0xFF01, "arbitrary_explicit_prime_curves",
|
||||
ARBITRARY_PRIME (0xFF01, "arbitrary_explicit_prime_curves", null,
|
||||
NamedGroupType.NAMED_GROUP_ARBITRARY,
|
||||
ProtocolVersion.PROTOCOLS_TO_12),
|
||||
ARBITRARY_CHAR2 (0xFF02, "arbitrary_explicit_char2_curves",
|
||||
ARBITRARY_CHAR2 (0xFF02, "arbitrary_explicit_char2_curves", null,
|
||||
NamedGroupType.NAMED_GROUP_ARBITRARY,
|
||||
ProtocolVersion.PROTOCOLS_TO_12);
|
||||
|
||||
final int id; // hash + signature
|
||||
|
@ -289,55 +332,16 @@ final class SupportedGroupsExtension {
|
|||
final String name; // literal name
|
||||
final String oid; // object identifier of the named group
|
||||
final String algorithm; // signature algorithm
|
||||
final boolean isFips; // can be used in FIPS mode?
|
||||
final ProtocolVersion[] supportedProtocols;
|
||||
|
||||
// Constructor used for Elliptic Curve Groups (ECDHE)
|
||||
private NamedGroup(int id, String name, String oid, boolean isFips,
|
||||
private NamedGroup(int id, String name, String oid,
|
||||
NamedGroupType namedGroupType,
|
||||
ProtocolVersion[] supportedProtocols) {
|
||||
this.id = id;
|
||||
this.type = NamedGroupType.NAMED_GROUP_ECDHE;
|
||||
this.type = namedGroupType;
|
||||
this.name = name;
|
||||
this.oid = oid;
|
||||
this.algorithm = "EC";
|
||||
this.isFips = isFips;
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
}
|
||||
|
||||
// Constructor used for Elliptic Curve Groups (XDH)
|
||||
private NamedGroup(int id, String name,
|
||||
boolean isFips, String algorithm,
|
||||
ProtocolVersion[] supportedProtocols) {
|
||||
this.id = id;
|
||||
this.type = NamedGroupType.NAMED_GROUP_XDH;
|
||||
this.name = name;
|
||||
this.oid = null;
|
||||
this.algorithm = algorithm;
|
||||
this.isFips = isFips;
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
}
|
||||
|
||||
// Constructor used for Finite Field Diffie-Hellman Groups (FFDHE)
|
||||
private NamedGroup(int id, String name, boolean isFips,
|
||||
ProtocolVersion[] supportedProtocols) {
|
||||
this.id = id;
|
||||
this.type = NamedGroupType.NAMED_GROUP_FFDHE;
|
||||
this.name = name;
|
||||
this.oid = null;
|
||||
this.algorithm = "DiffieHellman";
|
||||
this.isFips = isFips;
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
}
|
||||
|
||||
// Constructor used for arbitrary prime and curves (ECDHE)
|
||||
private NamedGroup(int id, String name,
|
||||
ProtocolVersion[] supportedProtocols) {
|
||||
this.id = id;
|
||||
this.type = NamedGroupType.NAMED_GROUP_ARBITRARY;
|
||||
this.name = name;
|
||||
this.oid = null;
|
||||
this.algorithm = "EC";
|
||||
this.isFips = false;
|
||||
this.algorithm = namedGroupType.algorithm;
|
||||
this.supportedProtocols = supportedProtocols;
|
||||
}
|
||||
|
||||
|
@ -352,7 +356,7 @@ final class SupportedGroupsExtension {
|
|||
}
|
||||
|
||||
static NamedGroup valueOf(ECParameterSpec params) {
|
||||
String oid = JsseJce.getNamedCurveOid(params);
|
||||
String oid = ECUtil.getCurveName(null, params);
|
||||
if ((oid != null) && (!oid.isEmpty())) {
|
||||
for (NamedGroup group : NamedGroup.values()) {
|
||||
if ((group.type == NamedGroupType.NAMED_GROUP_ECDHE) &&
|
||||
|
@ -472,8 +476,6 @@ final class SupportedGroupsExtension {
|
|||
static final NamedGroup[] supportedNamedGroups;
|
||||
|
||||
static {
|
||||
boolean requireFips = SunJSSE.isFIPS();
|
||||
|
||||
// The value of the System Property defines a list of enabled named
|
||||
// groups in preference order, separated with comma. For example:
|
||||
//
|
||||
|
@ -499,8 +501,7 @@ final class SupportedGroupsExtension {
|
|||
group = group.trim();
|
||||
if (!group.isEmpty()) {
|
||||
NamedGroup namedGroup = NamedGroup.nameOf(group);
|
||||
if (namedGroup != null &&
|
||||
(!requireFips || namedGroup.isFips)) {
|
||||
if (namedGroup != null) {
|
||||
if (isAvailableGroup(namedGroup)) {
|
||||
groupList.add(namedGroup);
|
||||
}
|
||||
|
@ -514,29 +515,7 @@ final class SupportedGroupsExtension {
|
|||
property + ") contains no supported named groups");
|
||||
}
|
||||
} else { // default groups
|
||||
NamedGroup[] groups;
|
||||
if (requireFips) {
|
||||
groups = new NamedGroup[] {
|
||||
// only NIST curves in FIPS mode
|
||||
NamedGroup.SECP256_R1,
|
||||
NamedGroup.SECP384_R1,
|
||||
NamedGroup.SECP521_R1,
|
||||
NamedGroup.SECT283_K1,
|
||||
NamedGroup.SECT283_R1,
|
||||
NamedGroup.SECT409_K1,
|
||||
NamedGroup.SECT409_R1,
|
||||
NamedGroup.SECT571_K1,
|
||||
NamedGroup.SECT571_R1,
|
||||
|
||||
// FFDHE 2048
|
||||
NamedGroup.FFDHE_2048,
|
||||
NamedGroup.FFDHE_3072,
|
||||
NamedGroup.FFDHE_4096,
|
||||
NamedGroup.FFDHE_6144,
|
||||
NamedGroup.FFDHE_8192,
|
||||
};
|
||||
} else {
|
||||
groups = new NamedGroup[] {
|
||||
NamedGroup[] groups = new NamedGroup[] {
|
||||
// NIST curves first
|
||||
NamedGroup.SECP256_R1,
|
||||
NamedGroup.SECP384_R1,
|
||||
|
@ -558,7 +537,6 @@ final class SupportedGroupsExtension {
|
|||
NamedGroup.FFDHE_6144,
|
||||
NamedGroup.FFDHE_8192,
|
||||
};
|
||||
}
|
||||
|
||||
groupList = new ArrayList<>(groups.length);
|
||||
for (NamedGroup group : groups) {
|
||||
|
@ -587,7 +565,7 @@ final class SupportedGroupsExtension {
|
|||
if (namedGroup.type == NamedGroupType.NAMED_GROUP_ECDHE) {
|
||||
if (namedGroup.oid != null) {
|
||||
try {
|
||||
params = JsseJce.getAlgorithmParameters("EC");
|
||||
params = AlgorithmParameters.getInstance("EC");
|
||||
spec = new ECGenParameterSpec(namedGroup.oid);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return false;
|
||||
|
@ -595,7 +573,7 @@ final class SupportedGroupsExtension {
|
|||
}
|
||||
} else if (namedGroup.type == NamedGroupType.NAMED_GROUP_FFDHE) {
|
||||
try {
|
||||
params = JsseJce.getAlgorithmParameters("DiffieHellman");
|
||||
params = AlgorithmParameters.getInstance("DiffieHellman");
|
||||
spec = getFFDHEDHParameterSpec(namedGroup);
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
return false;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, 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
|
||||
|
@ -218,7 +218,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
responseList =
|
||||
((ExtendedSSLSession)session).getStatusResponses();
|
||||
}
|
||||
trustedChain = validate(v, chain, responseList,
|
||||
trustedChain = v.validate(chain, null, responseList,
|
||||
constraints, isClient ? null : authType);
|
||||
|
||||
// check if EE certificate chains to a public root CA (as
|
||||
|
@ -234,7 +234,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
getRequestedServerNames(socket), chainsToPublicCA);
|
||||
}
|
||||
} else {
|
||||
trustedChain = validate(v, chain, Collections.emptyList(),
|
||||
trustedChain = v.validate(chain, null, Collections.emptyList(),
|
||||
null, isClient ? null : authType);
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
responseList =
|
||||
((ExtendedSSLSession)session).getStatusResponses();
|
||||
}
|
||||
trustedChain = validate(v, chain, responseList,
|
||||
trustedChain = v.validate(chain, null, responseList,
|
||||
constraints, isClient ? null : authType);
|
||||
|
||||
// check if EE certificate chains to a public root CA (as
|
||||
|
@ -292,7 +292,7 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
getRequestedServerNames(engine), chainsToPublicCA);
|
||||
}
|
||||
} else {
|
||||
trustedChain = validate(v, chain, Collections.emptyList(),
|
||||
trustedChain = v.validate(chain, null, Collections.emptyList(),
|
||||
null, isClient ? null : authType);
|
||||
}
|
||||
|
||||
|
@ -312,18 +312,6 @@ final class X509TrustManagerImpl extends X509ExtendedTrustManager
|
|||
return v;
|
||||
}
|
||||
|
||||
private static X509Certificate[] validate(Validator v,
|
||||
X509Certificate[] chain, List<byte[]> responseList,
|
||||
AlgorithmConstraints constraints, String authType)
|
||||
throws CertificateException {
|
||||
Object o = JsseJce.beginFipsProvider();
|
||||
try {
|
||||
return v.validate(chain, null, responseList, constraints, authType);
|
||||
} finally {
|
||||
JsseJce.endFipsProvider(o);
|
||||
}
|
||||
}
|
||||
|
||||
// Get string representation of HostName from a list of server names.
|
||||
//
|
||||
// We are only accepting host_name name type in the list.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue