Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
a795dae7
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
4
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dragonwell8_jdk
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
a795dae7
编写于
3月 03, 2015
作者:
A
asmotrak
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8043201: Deprecate RC4 in SunJSSE provider
Reviewed-by: xuelei
上级
5a8f41f7
变更
13
隐藏空白更改
内联
并排
Showing
13 changed file
with
913 addition
and
394 deletion
+913
-394
src/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
...are/classes/sun/security/ssl/SSLAlgorithmConstraints.java
+9
-217
src/share/classes/sun/security/ssl/SSLAlgorithmDecomposer.java
...hare/classes/sun/security/ssl/SSLAlgorithmDecomposer.java
+251
-0
src/share/classes/sun/security/ssl/ServerHandshaker.java
src/share/classes/sun/security/ssl/ServerHandshaker.java
+22
-1
src/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
...asses/sun/security/util/AbstractAlgorithmConstraints.java
+119
-0
src/share/classes/sun/security/util/AlgorithmDecomposer.java
src/share/classes/sun/security/util/AlgorithmDecomposer.java
+130
-0
src/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
...asses/sun/security/util/DisabledAlgorithmConstraints.java
+22
-174
src/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
...classes/sun/security/util/LegacyAlgorithmConstraints.java
+73
-0
src/share/lib/security/java.security-aix
src/share/lib/security/java.security-aix
+57
-0
src/share/lib/security/java.security-linux
src/share/lib/security/java.security-linux
+57
-0
src/share/lib/security/java.security-macosx
src/share/lib/security/java.security-macosx
+57
-0
src/share/lib/security/java.security-solaris
src/share/lib/security/java.security-solaris
+57
-0
src/share/lib/security/java.security-windows
src/share/lib/security/java.security-windows
+57
-0
test/sun/security/ssl/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java
...ssl/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java
+2
-2
未找到文件。
src/share/classes/sun/security/ssl/SSLAlgorithmConstraints.java
浏览文件 @
a795dae7
/*
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
5
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -34,9 +34,9 @@ import javax.net.ssl.*;
...
@@ -34,9 +34,9 @@ import javax.net.ssl.*;
import
java.security.Key
;
import
java.security.Key
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.HashSet
;
import
sun.security.util.DisabledAlgorithmConstraints
;
import
sun.security.util.DisabledAlgorithmConstraints
;
import
static
sun
.
security
.
util
.
DisabledAlgorithmConstraints
.*;
import
sun.security.ssl.CipherSuite.*
;
import
sun.security.ssl.CipherSuite.*
;
/**
/**
...
@@ -46,10 +46,15 @@ import sun.security.ssl.CipherSuite.*;
...
@@ -46,10 +46,15 @@ import sun.security.ssl.CipherSuite.*;
* for the syntax of the disabled algorithm string.
* for the syntax of the disabled algorithm string.
*/
*/
final
class
SSLAlgorithmConstraints
implements
AlgorithmConstraints
{
final
class
SSLAlgorithmConstraints
implements
AlgorithmConstraints
{
private
final
static
AlgorithmConstraints
tlsDisabledAlgConstraints
=
private
final
static
AlgorithmConstraints
tlsDisabledAlgConstraints
=
new
TLSDisabledAlgConstraints
();
new
DisabledAlgorithmConstraints
(
PROPERTY_TLS_DISABLED_ALGS
,
new
SSLAlgorithmDecomposer
());
private
final
static
AlgorithmConstraints
x509DisabledAlgConstraints
=
private
final
static
AlgorithmConstraints
x509DisabledAlgConstraints
=
new
X509DisabledAlgConstraints
();
new
DisabledAlgorithmConstraints
(
PROPERTY_CERTPATH_DISABLED_ALGS
,
new
SSLAlgorithmDecomposer
(
true
));
private
AlgorithmConstraints
userAlgConstraints
=
null
;
private
AlgorithmConstraints
userAlgConstraints
=
null
;
private
AlgorithmConstraints
peerAlgConstraints
=
null
;
private
AlgorithmConstraints
peerAlgConstraints
=
null
;
...
@@ -267,217 +272,4 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
...
@@ -267,217 +272,4 @@ final class SSLAlgorithmConstraints implements AlgorithmConstraints {
}
}
}
}
static
private
class
BasicDisabledAlgConstraints
extends
DisabledAlgorithmConstraints
{
BasicDisabledAlgConstraints
(
String
propertyName
)
{
super
(
propertyName
);
}
protected
Set
<
String
>
decomposes
(
KeyExchange
keyExchange
,
boolean
forCertPathOnly
)
{
Set
<
String
>
components
=
new
HashSet
<>();
switch
(
keyExchange
)
{
case
K_NULL:
if
(!
forCertPathOnly
)
{
components
.
add
(
"NULL"
);
}
break
;
case
K_RSA:
components
.
add
(
"RSA"
);
break
;
case
K_RSA_EXPORT:
components
.
add
(
"RSA"
);
components
.
add
(
"RSA_EXPORT"
);
break
;
case
K_DH_RSA:
components
.
add
(
"RSA"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_RSA"
);
break
;
case
K_DH_DSS:
components
.
add
(
"DSA"
);
components
.
add
(
"DSS"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_DSS"
);
break
;
case
K_DHE_DSS:
components
.
add
(
"DSA"
);
components
.
add
(
"DSS"
);
components
.
add
(
"DH"
);
components
.
add
(
"DHE"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DHE_DSS"
);
break
;
case
K_DHE_RSA:
components
.
add
(
"RSA"
);
components
.
add
(
"DH"
);
components
.
add
(
"DHE"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DHE_RSA"
);
break
;
case
K_DH_ANON:
if
(!
forCertPathOnly
)
{
components
.
add
(
"ANON"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_ANON"
);
}
break
;
case
K_ECDH_ECDSA:
components
.
add
(
"ECDH"
);
components
.
add
(
"ECDSA"
);
components
.
add
(
"ECDH_ECDSA"
);
break
;
case
K_ECDH_RSA:
components
.
add
(
"ECDH"
);
components
.
add
(
"RSA"
);
components
.
add
(
"ECDH_RSA"
);
break
;
case
K_ECDHE_ECDSA:
components
.
add
(
"ECDHE"
);
components
.
add
(
"ECDSA"
);
components
.
add
(
"ECDHE_ECDSA"
);
break
;
case
K_ECDHE_RSA:
components
.
add
(
"ECDHE"
);
components
.
add
(
"RSA"
);
components
.
add
(
"ECDHE_RSA"
);
break
;
case
K_ECDH_ANON:
if
(!
forCertPathOnly
)
{
components
.
add
(
"ECDH"
);
components
.
add
(
"ANON"
);
components
.
add
(
"ECDH_ANON"
);
}
break
;
case
K_KRB5:
if
(!
forCertPathOnly
)
{
components
.
add
(
"KRB5"
);
}
break
;
case
K_KRB5_EXPORT:
if
(!
forCertPathOnly
)
{
components
.
add
(
"KRB5_EXPORT"
);
}
break
;
default
:
// ignore
}
return
components
;
}
protected
Set
<
String
>
decomposes
(
BulkCipher
bulkCipher
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
bulkCipher
.
transformation
!=
null
)
{
components
.
addAll
(
super
.
decomposes
(
bulkCipher
.
transformation
));
}
return
components
;
}
protected
Set
<
String
>
decomposes
(
MacAlg
macAlg
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
macAlg
==
CipherSuite
.
M_MD5
)
{
components
.
add
(
"MD5"
);
components
.
add
(
"HmacMD5"
);
}
else
if
(
macAlg
==
CipherSuite
.
M_SHA
)
{
components
.
add
(
"SHA1"
);
components
.
add
(
"SHA-1"
);
components
.
add
(
"HmacSHA1"
);
}
else
if
(
macAlg
==
CipherSuite
.
M_SHA256
)
{
components
.
add
(
"SHA256"
);
components
.
add
(
"SHA-256"
);
components
.
add
(
"HmacSHA256"
);
}
else
if
(
macAlg
==
CipherSuite
.
M_SHA384
)
{
components
.
add
(
"SHA384"
);
components
.
add
(
"SHA-384"
);
components
.
add
(
"HmacSHA384"
);
}
return
components
;
}
}
static
private
class
TLSDisabledAlgConstraints
extends
BasicDisabledAlgConstraints
{
TLSDisabledAlgConstraints
()
{
super
(
DisabledAlgorithmConstraints
.
PROPERTY_TLS_DISABLED_ALGS
);
}
@Override
protected
Set
<
String
>
decomposes
(
String
algorithm
)
{
if
(
algorithm
.
startsWith
(
"SSL_"
)
||
algorithm
.
startsWith
(
"TLS_"
))
{
CipherSuite
cipherSuite
=
null
;
try
{
cipherSuite
=
CipherSuite
.
valueOf
(
algorithm
);
}
catch
(
IllegalArgumentException
iae
)
{
// ignore: unknown or unsupported ciphersuite
}
if
(
cipherSuite
!=
null
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
cipherSuite
.
keyExchange
!=
null
)
{
components
.
addAll
(
decomposes
(
cipherSuite
.
keyExchange
,
false
));
}
if
(
cipherSuite
.
cipher
!=
null
)
{
components
.
addAll
(
decomposes
(
cipherSuite
.
cipher
));
}
if
(
cipherSuite
.
macAlg
!=
null
)
{
components
.
addAll
(
decomposes
(
cipherSuite
.
macAlg
));
}
return
components
;
}
}
return
super
.
decomposes
(
algorithm
);
}
}
static
private
class
X509DisabledAlgConstraints
extends
BasicDisabledAlgConstraints
{
X509DisabledAlgConstraints
()
{
super
(
DisabledAlgorithmConstraints
.
PROPERTY_CERTPATH_DISABLED_ALGS
);
}
@Override
protected
Set
<
String
>
decomposes
(
String
algorithm
)
{
if
(
algorithm
.
startsWith
(
"SSL_"
)
||
algorithm
.
startsWith
(
"TLS_"
))
{
CipherSuite
cipherSuite
=
null
;
try
{
cipherSuite
=
CipherSuite
.
valueOf
(
algorithm
);
}
catch
(
IllegalArgumentException
iae
)
{
// ignore: unknown or unsupported ciphersuite
}
if
(
cipherSuite
!=
null
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
cipherSuite
.
keyExchange
!=
null
)
{
components
.
addAll
(
decomposes
(
cipherSuite
.
keyExchange
,
true
));
}
// Certification path algorithm constraints do not apply
// to cipherSuite.cipher and cipherSuite.macAlg.
return
components
;
}
}
return
super
.
decomposes
(
algorithm
);
}
}
}
}
src/share/classes/sun/security/ssl/SSLAlgorithmDecomposer.java
0 → 100644
浏览文件 @
a795dae7
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.security.ssl
;
import
java.util.HashSet
;
import
java.util.Set
;
import
sun.security.util.AlgorithmDecomposer
;
import
static
sun
.
security
.
ssl
.
CipherSuite
.*;
import
static
sun
.
security
.
ssl
.
CipherSuite
.
KeyExchange
.*;
/**
* The class decomposes standard SSL/TLS cipher suites into sub-elements.
*/
class
SSLAlgorithmDecomposer
extends
AlgorithmDecomposer
{
// indicates that only certification path algorithms need to be used
private
final
boolean
onlyX509
;
SSLAlgorithmDecomposer
(
boolean
onlyX509
)
{
this
.
onlyX509
=
onlyX509
;
}
SSLAlgorithmDecomposer
()
{
this
(
false
);
}
private
Set
<
String
>
decomposes
(
CipherSuite
.
KeyExchange
keyExchange
)
{
Set
<
String
>
components
=
new
HashSet
<>();
switch
(
keyExchange
)
{
case
K_NULL:
if
(!
onlyX509
)
{
components
.
add
(
"K_NULL"
);
}
break
;
case
K_RSA:
components
.
add
(
"RSA"
);
break
;
case
K_RSA_EXPORT:
components
.
add
(
"RSA"
);
components
.
add
(
"RSA_EXPORT"
);
break
;
case
K_DH_RSA:
components
.
add
(
"RSA"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_RSA"
);
break
;
case
K_DH_DSS:
components
.
add
(
"DSA"
);
components
.
add
(
"DSS"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_DSS"
);
break
;
case
K_DHE_DSS:
components
.
add
(
"DSA"
);
components
.
add
(
"DSS"
);
components
.
add
(
"DH"
);
components
.
add
(
"DHE"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DHE_DSS"
);
break
;
case
K_DHE_RSA:
components
.
add
(
"RSA"
);
components
.
add
(
"DH"
);
components
.
add
(
"DHE"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DHE_RSA"
);
break
;
case
K_DH_ANON:
if
(!
onlyX509
)
{
components
.
add
(
"ANON"
);
components
.
add
(
"DH"
);
components
.
add
(
"DiffieHellman"
);
components
.
add
(
"DH_ANON"
);
}
break
;
case
K_ECDH_ECDSA:
components
.
add
(
"ECDH"
);
components
.
add
(
"ECDSA"
);
components
.
add
(
"ECDH_ECDSA"
);
break
;
case
K_ECDH_RSA:
components
.
add
(
"ECDH"
);
components
.
add
(
"RSA"
);
components
.
add
(
"ECDH_RSA"
);
break
;
case
K_ECDHE_ECDSA:
components
.
add
(
"ECDHE"
);
components
.
add
(
"ECDSA"
);
components
.
add
(
"ECDHE_ECDSA"
);
break
;
case
K_ECDHE_RSA:
components
.
add
(
"ECDHE"
);
components
.
add
(
"RSA"
);
components
.
add
(
"ECDHE_RSA"
);
break
;
case
K_ECDH_ANON:
if
(!
onlyX509
)
{
components
.
add
(
"ECDH"
);
components
.
add
(
"ANON"
);
components
.
add
(
"ECDH_ANON"
);
}
break
;
case
K_KRB5:
if
(!
onlyX509
)
{
components
.
add
(
"KRB5"
);
}
break
;
case
K_KRB5_EXPORT:
if
(!
onlyX509
)
{
components
.
add
(
"KRB5_EXPORT"
);
}
break
;
default
:
// ignore
}
return
components
;
}
private
Set
<
String
>
decomposes
(
CipherSuite
.
BulkCipher
bulkCipher
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
bulkCipher
.
transformation
!=
null
)
{
components
.
addAll
(
super
.
decompose
(
bulkCipher
.
transformation
));
}
if
(
bulkCipher
==
B_NULL
)
{
components
.
add
(
"C_NULL"
);
}
else
if
(
bulkCipher
==
B_RC2_40
)
{
components
.
add
(
"RC2_CBC_40"
);
}
else
if
(
bulkCipher
==
B_RC4_40
)
{
components
.
add
(
"RC4_40"
);
}
else
if
(
bulkCipher
==
B_RC4_128
)
{
components
.
add
(
"RC4_128"
);
}
else
if
(
bulkCipher
==
B_DES_40
)
{
components
.
add
(
"DES40_CBC"
);
components
.
add
(
"DES_CBC_40"
);
}
else
if
(
bulkCipher
==
B_DES
)
{
components
.
add
(
"DES_CBC"
);
}
else
if
(
bulkCipher
==
B_3DES
)
{
components
.
add
(
"3DES_EDE_CBC"
);
}
else
if
(
bulkCipher
==
B_AES_128
)
{
components
.
add
(
"AES_128_CBC"
);
}
else
if
(
bulkCipher
==
B_AES_256
)
{
components
.
add
(
"AES_256_CBC"
);
}
else
if
(
bulkCipher
==
B_AES_128_GCM
)
{
components
.
add
(
"AES_128_GCM"
);
}
else
if
(
bulkCipher
==
B_AES_256_GCM
)
{
components
.
add
(
"AES_256_GCM"
);
}
return
components
;
}
private
Set
<
String
>
decomposes
(
CipherSuite
.
MacAlg
macAlg
,
BulkCipher
cipher
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
macAlg
==
M_NULL
&&
cipher
.
cipherType
!=
CipherType
.
AEAD_CIPHER
)
{
components
.
add
(
"M_NULL"
);
}
else
if
(
macAlg
==
M_MD5
)
{
components
.
add
(
"MD5"
);
components
.
add
(
"HmacMD5"
);
}
else
if
(
macAlg
==
M_SHA
)
{
components
.
add
(
"SHA1"
);
components
.
add
(
"SHA-1"
);
components
.
add
(
"HmacSHA1"
);
}
else
if
(
macAlg
==
M_SHA256
)
{
components
.
add
(
"SHA256"
);
components
.
add
(
"SHA-256"
);
components
.
add
(
"HmacSHA256"
);
}
else
if
(
macAlg
==
M_SHA384
)
{
components
.
add
(
"SHA384"
);
components
.
add
(
"SHA-384"
);
components
.
add
(
"HmacSHA384"
);
}
return
components
;
}
private
Set
<
String
>
decompose
(
KeyExchange
keyExchange
,
BulkCipher
cipher
,
MacAlg
macAlg
)
{
Set
<
String
>
components
=
new
HashSet
<>();
if
(
keyExchange
!=
null
)
{
components
.
addAll
(
decomposes
(
keyExchange
));
}
if
(
onlyX509
)
{
// Certification path algorithm constraints do not apply
// to cipher and macAlg.
return
components
;
}
if
(
cipher
!=
null
)
{
components
.
addAll
(
decomposes
(
cipher
));
}
if
(
macAlg
!=
null
)
{
components
.
addAll
(
decomposes
(
macAlg
,
cipher
));
}
return
components
;
}
@Override
public
Set
<
String
>
decompose
(
String
algorithm
)
{
if
(
algorithm
.
startsWith
(
"SSL_"
)
||
algorithm
.
startsWith
(
"TLS_"
))
{
CipherSuite
cipherSuite
=
null
;
try
{
cipherSuite
=
CipherSuite
.
valueOf
(
algorithm
);
}
catch
(
IllegalArgumentException
iae
)
{
// ignore: unknown or unsupported ciphersuite
}
if
(
cipherSuite
!=
null
)
{
return
decompose
(
cipherSuite
.
keyExchange
,
cipherSuite
.
cipher
,
cipherSuite
.
macAlg
);
}
}
return
super
.
decompose
(
algorithm
);
}
}
src/share/classes/sun/security/ssl/ServerHandshaker.java
浏览文件 @
a795dae7
/*
/*
* Copyright (c) 1996, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1996, 201
5
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -41,6 +41,7 @@ import javax.net.ssl.*;
...
@@ -41,6 +41,7 @@ import javax.net.ssl.*;
import
javax.security.auth.Subject
;
import
javax.security.auth.Subject
;
import
sun.security.util.KeyUtil
;
import
sun.security.util.KeyUtil
;
import
sun.security.util.LegacyAlgorithmConstraints
;
import
sun.security.action.GetPropertyAction
;
import
sun.security.action.GetPropertyAction
;
import
sun.security.ssl.HandshakeMessage.*
;
import
sun.security.ssl.HandshakeMessage.*
;
import
sun.security.ssl.CipherSuite.*
;
import
sun.security.ssl.CipherSuite.*
;
...
@@ -106,6 +107,12 @@ final class ServerHandshaker extends Handshaker {
...
@@ -106,6 +107,12 @@ final class ServerHandshaker extends Handshaker {
// The customized ephemeral DH key size for non-exportable cipher suites.
// The customized ephemeral DH key size for non-exportable cipher suites.
private
static
final
int
customizedDHKeySize
;
private
static
final
int
customizedDHKeySize
;
// legacy algorithm constraints
private
static
final
AlgorithmConstraints
legacyAlgorithmConstraints
=
new
LegacyAlgorithmConstraints
(
LegacyAlgorithmConstraints
.
PROPERTY_TLS_LEGACY_ALGS
,
new
SSLAlgorithmDecomposer
());
static
{
static
{
String
property
=
AccessController
.
doPrivileged
(
String
property
=
AccessController
.
doPrivileged
(
new
GetPropertyAction
(
"jdk.tls.ephemeralDHKeySize"
));
new
GetPropertyAction
(
"jdk.tls.ephemeralDHKeySize"
));
...
@@ -995,6 +1002,7 @@ final class ServerHandshaker extends Handshaker {
...
@@ -995,6 +1002,7 @@ final class ServerHandshaker extends Handshaker {
proposed
=
getActiveCipherSuites
();
proposed
=
getActiveCipherSuites
();
}
}
List
<
CipherSuite
>
legacySuites
=
new
ArrayList
<>();
for
(
CipherSuite
suite
:
prefered
.
collection
())
{
for
(
CipherSuite
suite
:
prefered
.
collection
())
{
if
(
isNegotiable
(
proposed
,
suite
)
==
false
)
{
if
(
isNegotiable
(
proposed
,
suite
)
==
false
)
{
continue
;
continue
;
...
@@ -1006,11 +1014,24 @@ final class ServerHandshaker extends Handshaker {
...
@@ -1006,11 +1014,24 @@ final class ServerHandshaker extends Handshaker {
continue
;
continue
;
}
}
}
}
if
(!
legacyAlgorithmConstraints
.
permits
(
null
,
suite
.
name
,
null
))
{
legacySuites
.
add
(
suite
);
continue
;
}
if
(
trySetCipherSuite
(
suite
)
==
false
)
{
if
(
trySetCipherSuite
(
suite
)
==
false
)
{
continue
;
continue
;
}
}
return
;
return
;
}
}
for
(
CipherSuite
suite
:
legacySuites
)
{
if
(
trySetCipherSuite
(
suite
))
{
return
;
}
}
fatalSE
(
Alerts
.
alert_handshake_failure
,
"no cipher suites in common"
);
fatalSE
(
Alerts
.
alert_handshake_failure
,
"no cipher suites in common"
);
}
}
...
...
src/share/classes/sun/security/util/AbstractAlgorithmConstraints.java
0 → 100644
浏览文件 @
a795dae7
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.security.util
;
import
java.security.AccessController
;
import
java.security.AlgorithmConstraints
;
import
java.security.PrivilegedAction
;
import
java.security.Security
;
import
java.util.Map
;
import
java.util.Set
;
/**
* The class contains common functionality for algorithm constraints classes.
*/
public
abstract
class
AbstractAlgorithmConstraints
implements
AlgorithmConstraints
{
protected
final
AlgorithmDecomposer
decomposer
;
protected
AbstractAlgorithmConstraints
(
AlgorithmDecomposer
decomposer
)
{
this
.
decomposer
=
decomposer
;
}
// Get algorithm constraints from the specified security property.
private
static
void
loadAlgorithmsMap
(
Map
<
String
,
String
[]>
algorithmsMap
,
String
propertyName
)
{
String
property
=
AccessController
.
doPrivileged
(
(
PrivilegedAction
<
String
>)
()
->
Security
.
getProperty
(
propertyName
));
String
[]
algorithmsInProperty
=
null
;
if
(
property
!=
null
&&
!
property
.
isEmpty
())
{
// remove double quote marks from beginning/end of the property
if
(
property
.
charAt
(
0
)
==
'"'
&&
property
.
charAt
(
property
.
length
()
-
1
)
==
'"'
)
{
property
=
property
.
substring
(
1
,
property
.
length
()
-
1
);
}
algorithmsInProperty
=
property
.
split
(
","
);
for
(
int
i
=
0
;
i
<
algorithmsInProperty
.
length
;
i
++)
{
algorithmsInProperty
[
i
]
=
algorithmsInProperty
[
i
].
trim
();
}
}
// map the disabled algorithms
if
(
algorithmsInProperty
==
null
)
{
algorithmsInProperty
=
new
String
[
0
];
}
algorithmsMap
.
put
(
propertyName
,
algorithmsInProperty
);
}
static
String
[]
getAlgorithms
(
Map
<
String
,
String
[]>
algorithmsMap
,
String
propertyName
)
{
synchronized
(
algorithmsMap
)
{
if
(!
algorithmsMap
.
containsKey
(
propertyName
))
{
loadAlgorithmsMap
(
algorithmsMap
,
propertyName
);
}
return
algorithmsMap
.
get
(
propertyName
);
}
}
static
boolean
checkAlgorithm
(
String
[]
algorithms
,
String
algorithm
,
AlgorithmDecomposer
decomposer
)
{
if
(
algorithm
==
null
||
algorithm
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"No algorithm name specified"
);
}
Set
<
String
>
elements
=
null
;
for
(
String
item
:
algorithms
)
{
if
(
item
==
null
||
item
.
isEmpty
())
{
continue
;
}
// check the full name
if
(
item
.
equalsIgnoreCase
(
algorithm
))
{
return
false
;
}
// decompose the algorithm into sub-elements
if
(
elements
==
null
)
{
elements
=
decomposer
.
decompose
(
algorithm
);
}
// check the items of the algorithm
for
(
String
element
:
elements
)
{
if
(
item
.
equalsIgnoreCase
(
element
))
{
return
false
;
}
}
}
return
true
;
}
}
src/share/classes/sun/security/util/AlgorithmDecomposer.java
0 → 100644
浏览文件 @
a795dae7
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.security.util
;
import
java.util.HashSet
;
import
java.util.Set
;
import
java.util.regex.Pattern
;
/**
* The class decomposes standard algorithms into sub-elements.
*/
public
class
AlgorithmDecomposer
{
private
static
final
Pattern
transPattern
=
Pattern
.
compile
(
"/"
);
private
static
final
Pattern
pattern
=
Pattern
.
compile
(
"with|and"
,
Pattern
.
CASE_INSENSITIVE
);
/**
* Decompose the standard algorithm name into sub-elements.
* <p>
* For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
* so that we can check the "SHA1" and "RSA" algorithm constraints
* separately.
* <p>
* Please override the method if need to support more name pattern.
*/
public
Set
<
String
>
decompose
(
String
algorithm
)
{
if
(
algorithm
==
null
||
algorithm
.
length
()
==
0
)
{
return
new
HashSet
<>();
}
// algorithm/mode/padding
String
[]
transTockens
=
transPattern
.
split
(
algorithm
);
Set
<
String
>
elements
=
new
HashSet
<>();
for
(
String
transTocken
:
transTockens
)
{
if
(
transTocken
==
null
||
transTocken
.
length
()
==
0
)
{
continue
;
}
// PBEWith<digest>And<encryption>
// PBEWith<prf>And<encryption>
// OAEPWith<digest>And<mgf>Padding
// <digest>with<encryption>
// <digest>with<encryption>and<mgf>
String
[]
tokens
=
pattern
.
split
(
transTocken
);
for
(
String
token
:
tokens
)
{
if
(
token
==
null
||
token
.
length
()
==
0
)
{
continue
;
}
elements
.
add
(
token
);
}
}
// In Java standard algorithm name specification, for different
// purpose, the SHA-1 and SHA-2 algorithm names are different. For
// example, for MessageDigest, the standard name is "SHA-256", while
// for Signature, the digest algorithm component is "SHA256" for
// signature algorithm "SHA256withRSA". So we need to check both
// "SHA-256" and "SHA256" to make the right constraint checking.
// handle special name: SHA-1 and SHA1
if
(
elements
.
contains
(
"SHA1"
)
&&
!
elements
.
contains
(
"SHA-1"
))
{
elements
.
add
(
"SHA-1"
);
}
if
(
elements
.
contains
(
"SHA-1"
)
&&
!
elements
.
contains
(
"SHA1"
))
{
elements
.
add
(
"SHA1"
);
}
// handle special name: SHA-224 and SHA224
if
(
elements
.
contains
(
"SHA224"
)
&&
!
elements
.
contains
(
"SHA-224"
))
{
elements
.
add
(
"SHA-224"
);
}
if
(
elements
.
contains
(
"SHA-224"
)
&&
!
elements
.
contains
(
"SHA224"
))
{
elements
.
add
(
"SHA224"
);
}
// handle special name: SHA-256 and SHA256
if
(
elements
.
contains
(
"SHA256"
)
&&
!
elements
.
contains
(
"SHA-256"
))
{
elements
.
add
(
"SHA-256"
);
}
if
(
elements
.
contains
(
"SHA-256"
)
&&
!
elements
.
contains
(
"SHA256"
))
{
elements
.
add
(
"SHA256"
);
}
// handle special name: SHA-384 and SHA384
if
(
elements
.
contains
(
"SHA384"
)
&&
!
elements
.
contains
(
"SHA-384"
))
{
elements
.
add
(
"SHA-384"
);
}
if
(
elements
.
contains
(
"SHA-384"
)
&&
!
elements
.
contains
(
"SHA384"
))
{
elements
.
add
(
"SHA384"
);
}
// handle special name: SHA-512 and SHA512
if
(
elements
.
contains
(
"SHA512"
)
&&
!
elements
.
contains
(
"SHA-512"
))
{
elements
.
add
(
"SHA-512"
);
}
if
(
elements
.
contains
(
"SHA-512"
)
&&
!
elements
.
contains
(
"SHA512"
))
{
elements
.
add
(
"SHA512"
);
}
return
elements
;
}
}
src/share/classes/sun/security/util/DisabledAlgorithmConstraints.java
浏览文件 @
a795dae7
/*
/*
* Copyright (c) 2010, 201
2
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2010, 201
5
, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -25,15 +25,9 @@
...
@@ -25,15 +25,9 @@
package
sun.security.util
;
package
sun.security.util
;
import
java.security.AlgorithmConstraints
;
import
java.security.CryptoPrimitive
;
import
java.security.CryptoPrimitive
;
import
java.security.AlgorithmParameters
;
import
java.security.AlgorithmParameters
;
import
java.security.Key
;
import
java.security.Key
;
import
java.security.Security
;
import
java.security.PrivilegedAction
;
import
java.security.AccessController
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.Set
;
import
java.util.Set
;
import
java.util.Collections
;
import
java.util.Collections
;
...
@@ -49,7 +43,7 @@ import java.util.regex.Matcher;
...
@@ -49,7 +43,7 @@ import java.util.regex.Matcher;
* See the "jdk.certpath.disabledAlgorithms" specification in java.security
* See the "jdk.certpath.disabledAlgorithms" specification in java.security
* for the syntax of the disabled algorithm string.
* for the syntax of the disabled algorithm string.
*/
*/
public
class
DisabledAlgorithmConstraints
implements
AlgorithmConstraints
{
public
class
DisabledAlgorithmConstraints
extends
Abstract
AlgorithmConstraints
{
// the known security property, jdk.certpath.disabledAlgorithms
// the known security property, jdk.certpath.disabledAlgorithms
public
final
static
String
PROPERTY_CERTPATH_DISABLED_ALGS
=
public
final
static
String
PROPERTY_CERTPATH_DISABLED_ALGS
=
...
@@ -64,8 +58,8 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
...
@@ -64,8 +58,8 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
private
final
static
Map
<
String
,
KeySizeConstraints
>
keySizeConstraintsMap
=
private
final
static
Map
<
String
,
KeySizeConstraints
>
keySizeConstraintsMap
=
new
HashMap
<>();
new
HashMap
<>();
private
String
[]
disabledAlgorithms
;
private
final
String
[]
disabledAlgorithms
;
private
KeySizeConstraints
keySizeConstraints
;
private
final
KeySizeConstraints
keySizeConstraints
;
/**
/**
* Initialize algorithm constraints with the specified security property.
* Initialize algorithm constraints with the specified security property.
...
@@ -74,56 +68,27 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
...
@@ -74,56 +68,27 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
* algorithm constraints
* algorithm constraints
*/
*/
public
DisabledAlgorithmConstraints
(
String
propertyName
)
{
public
DisabledAlgorithmConstraints
(
String
propertyName
)
{
// Both disabledAlgorithmsMap and keySizeConstraintsMap are
this
(
propertyName
,
new
AlgorithmDecomposer
());
// synchronized with the lock of disabledAlgorithmsMap.
}
synchronized
(
disabledAlgorithmsMap
)
{
if
(!
disabledAlgorithmsMap
.
containsKey
(
propertyName
))
{
loadDisabledAlgorithmsMap
(
propertyName
);
}
disabledAlgorithms
=
disabledAlgorithmsMap
.
get
(
propertyName
);
public
DisabledAlgorithmConstraints
(
String
propertyName
,
keySizeConstraints
=
keySizeConstraintsMap
.
get
(
propertyName
);
AlgorithmDecomposer
decomposer
)
{
}
super
(
decomposer
);
disabledAlgorithms
=
getAlgorithms
(
disabledAlgorithmsMap
,
propertyName
);
keySizeConstraints
=
getKeySizeConstraints
(
disabledAlgorithms
,
propertyName
);
}
}
@Override
@Override
final
public
boolean
permits
(
Set
<
CryptoPrimitive
>
primitives
,
final
public
boolean
permits
(
Set
<
CryptoPrimitive
>
primitives
,
String
algorithm
,
AlgorithmParameters
parameters
)
{
String
algorithm
,
AlgorithmParameters
parameters
)
{
if
(
algorithm
==
null
||
algorithm
.
length
()
==
0
)
{
throw
new
IllegalArgumentException
(
"No algorithm name specified"
);
}
if
(
primitives
==
null
||
primitives
.
isEmpty
())
{
if
(
primitives
==
null
||
primitives
.
isEmpty
())
{
throw
new
IllegalArgumentException
(
throw
new
IllegalArgumentException
(
"No cryptographic primitive specified"
);
"No cryptographic primitive specified"
);
}
}
Set
<
String
>
elements
=
null
;
return
checkAlgorithm
(
disabledAlgorithms
,
algorithm
,
decomposer
);
for
(
String
disabled
:
disabledAlgorithms
)
{
if
(
disabled
==
null
||
disabled
.
isEmpty
())
{
continue
;
}
// check the full name
if
(
disabled
.
equalsIgnoreCase
(
algorithm
))
{
return
false
;
}
// decompose the algorithm into sub-elements
if
(
elements
==
null
)
{
elements
=
decomposes
(
algorithm
);
}
// check the items of the algorithm
for
(
String
element
:
elements
)
{
if
(
disabled
.
equalsIgnoreCase
(
element
))
{
return
false
;
}
}
}
return
true
;
}
}
@Override
@Override
...
@@ -142,98 +107,6 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
...
@@ -142,98 +107,6 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
return
checkConstraints
(
primitives
,
algorithm
,
key
,
parameters
);
return
checkConstraints
(
primitives
,
algorithm
,
key
,
parameters
);
}
}
/**
* Decompose the standard algorithm name into sub-elements.
* <p>
* For example, we need to decompose "SHA1WithRSA" into "SHA1" and "RSA"
* so that we can check the "SHA1" and "RSA" algorithm constraints
* separately.
* <p>
* Please override the method if need to support more name pattern.
*/
protected
Set
<
String
>
decomposes
(
String
algorithm
)
{
if
(
algorithm
==
null
||
algorithm
.
length
()
==
0
)
{
return
new
HashSet
<
String
>();
}
// algorithm/mode/padding
Pattern
transPattern
=
Pattern
.
compile
(
"/"
);
String
[]
transTockens
=
transPattern
.
split
(
algorithm
);
Set
<
String
>
elements
=
new
HashSet
<
String
>();
for
(
String
transTocken
:
transTockens
)
{
if
(
transTocken
==
null
||
transTocken
.
length
()
==
0
)
{
continue
;
}
// PBEWith<digest>And<encryption>
// PBEWith<prf>And<encryption>
// OAEPWith<digest>And<mgf>Padding
// <digest>with<encryption>
// <digest>with<encryption>and<mgf>
Pattern
pattern
=
Pattern
.
compile
(
"with|and"
,
Pattern
.
CASE_INSENSITIVE
);
String
[]
tokens
=
pattern
.
split
(
transTocken
);
for
(
String
token
:
tokens
)
{
if
(
token
==
null
||
token
.
length
()
==
0
)
{
continue
;
}
elements
.
add
(
token
);
}
}
// In Java standard algorithm name specification, for different
// purpose, the SHA-1 and SHA-2 algorithm names are different. For
// example, for MessageDigest, the standard name is "SHA-256", while
// for Signature, the digest algorithm component is "SHA256" for
// signature algorithm "SHA256withRSA". So we need to check both
// "SHA-256" and "SHA256" to make the right constraint checking.
// handle special name: SHA-1 and SHA1
if
(
elements
.
contains
(
"SHA1"
)
&&
!
elements
.
contains
(
"SHA-1"
))
{
elements
.
add
(
"SHA-1"
);
}
if
(
elements
.
contains
(
"SHA-1"
)
&&
!
elements
.
contains
(
"SHA1"
))
{
elements
.
add
(
"SHA1"
);
}
// handle special name: SHA-224 and SHA224
if
(
elements
.
contains
(
"SHA224"
)
&&
!
elements
.
contains
(
"SHA-224"
))
{
elements
.
add
(
"SHA-224"
);
}
if
(
elements
.
contains
(
"SHA-224"
)
&&
!
elements
.
contains
(
"SHA224"
))
{
elements
.
add
(
"SHA224"
);
}
// handle special name: SHA-256 and SHA256
if
(
elements
.
contains
(
"SHA256"
)
&&
!
elements
.
contains
(
"SHA-256"
))
{
elements
.
add
(
"SHA-256"
);
}
if
(
elements
.
contains
(
"SHA-256"
)
&&
!
elements
.
contains
(
"SHA256"
))
{
elements
.
add
(
"SHA256"
);
}
// handle special name: SHA-384 and SHA384
if
(
elements
.
contains
(
"SHA384"
)
&&
!
elements
.
contains
(
"SHA-384"
))
{
elements
.
add
(
"SHA-384"
);
}
if
(
elements
.
contains
(
"SHA-384"
)
&&
!
elements
.
contains
(
"SHA384"
))
{
elements
.
add
(
"SHA384"
);
}
// handle special name: SHA-512 and SHA512
if
(
elements
.
contains
(
"SHA512"
)
&&
!
elements
.
contains
(
"SHA-512"
))
{
elements
.
add
(
"SHA-512"
);
}
if
(
elements
.
contains
(
"SHA-512"
)
&&
!
elements
.
contains
(
"SHA512"
))
{
elements
.
add
(
"SHA512"
);
}
return
elements
;
}
// Check algorithm constraints
// Check algorithm constraints
private
boolean
checkConstraints
(
Set
<
CryptoPrimitive
>
primitives
,
private
boolean
checkConstraints
(
Set
<
CryptoPrimitive
>
primitives
,
String
algorithm
,
Key
key
,
AlgorithmParameters
parameters
)
{
String
algorithm
,
Key
key
,
AlgorithmParameters
parameters
)
{
...
@@ -263,43 +136,18 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
...
@@ -263,43 +136,18 @@ public class DisabledAlgorithmConstraints implements AlgorithmConstraints {
return
true
;
return
true
;
}
}
// Get disabled algorithm constraints from the specified security property.
private
static
KeySizeConstraints
getKeySizeConstraints
(
private
static
void
loadDisabledAlgorithmsMap
(
String
[]
disabledAlgorithms
,
String
propertyName
)
{
final
String
propertyName
)
{
synchronized
(
keySizeConstraintsMap
)
{
if
(!
keySizeConstraintsMap
.
containsKey
(
propertyName
))
{
String
property
=
AccessController
.
doPrivileged
(
// map the key constraints
new
PrivilegedAction
<
String
>()
{
KeySizeConstraints
keySizeConstraints
=
public
String
run
()
{
new
KeySizeConstraints
(
disabledAlgorithms
);
return
Security
.
getProperty
(
propertyName
);
keySizeConstraintsMap
.
put
(
propertyName
,
keySizeConstraints
);
}
});
String
[]
algorithmsInProperty
=
null
;
if
(
property
!=
null
&&
!
property
.
isEmpty
())
{
// remove double quote marks from beginning/end of the property
if
(
property
.
charAt
(
0
)
==
'"'
&&
property
.
charAt
(
property
.
length
()
-
1
)
==
'"'
)
{
property
=
property
.
substring
(
1
,
property
.
length
()
-
1
);
}
}
algorithmsInProperty
=
property
.
split
(
","
);
return
keySizeConstraintsMap
.
get
(
propertyName
);
for
(
int
i
=
0
;
i
<
algorithmsInProperty
.
length
;
i
++)
{
algorithmsInProperty
[
i
]
=
algorithmsInProperty
[
i
].
trim
();
}
}
}
// map the disabled algorithms
if
(
algorithmsInProperty
==
null
)
{
algorithmsInProperty
=
new
String
[
0
];
}
disabledAlgorithmsMap
.
put
(
propertyName
,
algorithmsInProperty
);
// map the key constraints
KeySizeConstraints
keySizeConstraints
=
new
KeySizeConstraints
(
algorithmsInProperty
);
keySizeConstraintsMap
.
put
(
propertyName
,
keySizeConstraints
);
}
}
/**
/**
...
...
src/share/classes/sun/security/util/LegacyAlgorithmConstraints.java
0 → 100644
浏览文件 @
a795dae7
/*
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package
sun.security.util
;
import
java.security.AlgorithmParameters
;
import
java.security.CryptoPrimitive
;
import
java.security.Key
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Set
;
import
static
sun
.
security
.
util
.
AbstractAlgorithmConstraints
.
getAlgorithms
;
/**
* Algorithm constraints for legacy algorithms.
*/
public
class
LegacyAlgorithmConstraints
extends
AbstractAlgorithmConstraints
{
// the known security property, jdk.tls.legacyAlgorithms
public
final
static
String
PROPERTY_TLS_LEGACY_ALGS
=
"jdk.tls.legacyAlgorithms"
;
private
final
static
Map
<
String
,
String
[]>
legacyAlgorithmsMap
=
new
HashMap
<>();
private
final
String
[]
legacyAlgorithms
;
public
LegacyAlgorithmConstraints
(
String
propertyName
,
AlgorithmDecomposer
decomposer
)
{
super
(
decomposer
);
legacyAlgorithms
=
getAlgorithms
(
legacyAlgorithmsMap
,
propertyName
);
}
@Override
final
public
boolean
permits
(
Set
<
CryptoPrimitive
>
primitives
,
String
algorithm
,
AlgorithmParameters
parameters
)
{
return
checkAlgorithm
(
legacyAlgorithms
,
algorithm
,
decomposer
);
}
@Override
final
public
boolean
permits
(
Set
<
CryptoPrimitive
>
primitives
,
Key
key
)
{
return
true
;
}
@Override
final
public
boolean
permits
(
Set
<
CryptoPrimitive
>
primitives
,
String
algorithm
,
Key
key
,
AlgorithmParameters
parameters
)
{
return
checkAlgorithm
(
legacyAlgorithms
,
algorithm
,
decomposer
);
}
}
src/share/lib/security/java.security-aix
浏览文件 @
a795dae7
...
@@ -501,3 +501,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
...
@@ -501,3 +501,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
# Example:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3
jdk.tls.disabledAlgorithms=SSLv3
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
#
# In some environments, a certain algorithm may be undesirable but it
# cannot be disabled because of its use in legacy applications. Legacy
# algorithms may still be supported, but applications should not use them
# as the security strength of legacy algorithms are usually not strong enough
# in practice.
#
# During SSL/TLS security parameters negotiation, legacy algorithms will
# not be negotiated unless there are no other candidates.
#
# The syntax of the disabled algorithm string is described as this Java
# BNF-style:
# LegacyAlgorithms:
# " LegacyAlgorithm { , LegacyAlgorithm } "
#
# LegacyAlgorithm:
# AlgorithmName (standard JSSE algorithm name)
#
# See the specification of security property "jdk.certpath.disabledAlgorithms"
# for the syntax and description of the "AlgorithmName" notation.
#
# Per SSL/TLS specifications, cipher suites have the form:
# SSL_KeyExchangeAlg_WITH_CipherAlg_MacAlg
# or
# TLS_KeyExchangeAlg_WITH_CipherAlg_MacAlg
#
# For example, the cipher suite TLS_RSA_WITH_AES_128_CBC_SHA uses RSA as the
# key exchange algorithm, AES_128_CBC (128 bits AES cipher algorithm in CBC
# mode) as the cipher (encryption) algorithm, and SHA-1 as the message digest
# algorithm for HMAC.
#
# The LegacyAlgorithm can be one of the following standard algorithm names:
# 1. JSSE cipher suite name, e.g., TLS_RSA_WITH_AES_128_CBC_SHA
# 2. JSSE key exchange algorithm name, e.g., RSA
# 3. JSSE cipher (encryption) algorithm name, e.g., AES_128_CBC
# 4. JSSE message digest algorithm name, e.g., SHA-1
#
# See SSL/TLS specifications and "Java Cryptography Architecture Standard
# Algorithm Name Documentation" for information about the algorithm names.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
# There is no guarantee the property will continue to exist or be of the
# same syntax in future releases.
#
# Example:
# jdk.tls.legacyAlgorithms=DH_anon, DES_CBC, SSL_RSA_WITH_RC4_128_MD5
#
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
DH_RSA_EXPORT, RSA_EXPORT, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC
src/share/lib/security/java.security-linux
浏览文件 @
a795dae7
...
@@ -501,3 +501,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
...
@@ -501,3 +501,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
# Example:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3
jdk.tls.disabledAlgorithms=SSLv3
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
#
# In some environments, a certain algorithm may be undesirable but it
# cannot be disabled because of its use in legacy applications. Legacy
# algorithms may still be supported, but applications should not use them
# as the security strength of legacy algorithms are usually not strong enough
# in practice.
#
# During SSL/TLS security parameters negotiation, legacy algorithms will
# not be negotiated unless there are no other candidates.
#
# The syntax of the disabled algorithm string is described as this Java
# BNF-style:
# LegacyAlgorithms:
# " LegacyAlgorithm { , LegacyAlgorithm } "
#
# LegacyAlgorithm:
# AlgorithmName (standard JSSE algorithm name)
#
# See the specification of security property "jdk.certpath.disabledAlgorithms"
# for the syntax and description of the "AlgorithmName" notation.
#
# Per SSL/TLS specifications, cipher suites have the form:
# SSL_KeyExchangeAlg_WITH_CipherAlg_MacAlg
# or
# TLS_KeyExchangeAlg_WITH_CipherAlg_MacAlg
#
# For example, the cipher suite TLS_RSA_WITH_AES_128_CBC_SHA uses RSA as the
# key exchange algorithm, AES_128_CBC (128 bits AES cipher algorithm in CBC
# mode) as the cipher (encryption) algorithm, and SHA-1 as the message digest
# algorithm for HMAC.
#
# The LegacyAlgorithm can be one of the following standard algorithm names:
# 1. JSSE cipher suite name, e.g., TLS_RSA_WITH_AES_128_CBC_SHA
# 2. JSSE key exchange algorithm name, e.g., RSA
# 3. JSSE cipher (encryption) algorithm name, e.g., AES_128_CBC
# 4. JSSE message digest algorithm name, e.g., SHA-1
#
# See SSL/TLS specifications and "Java Cryptography Architecture Standard
# Algorithm Name Documentation" for information about the algorithm names.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
# There is no guarantee the property will continue to exist or be of the
# same syntax in future releases.
#
# Example:
# jdk.tls.legacyAlgorithms=DH_anon, DES_CBC, SSL_RSA_WITH_RC4_128_MD5
#
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
DH_RSA_EXPORT, RSA_EXPORT, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC
src/share/lib/security/java.security-macosx
浏览文件 @
a795dae7
...
@@ -504,3 +504,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
...
@@ -504,3 +504,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
# Example:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3
jdk.tls.disabledAlgorithms=SSLv3
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
#
# In some environments, a certain algorithm may be undesirable but it
# cannot be disabled because of its use in legacy applications. Legacy
# algorithms may still be supported, but applications should not use them
# as the security strength of legacy algorithms are usually not strong enough
# in practice.
#
# During SSL/TLS security parameters negotiation, legacy algorithms will
# not be negotiated unless there are no other candidates.
#
# The syntax of the disabled algorithm string is described as this Java
# BNF-style:
# LegacyAlgorithms:
# " LegacyAlgorithm { , LegacyAlgorithm } "
#
# LegacyAlgorithm:
# AlgorithmName (standard JSSE algorithm name)
#
# See the specification of security property "jdk.certpath.disabledAlgorithms"
# for the syntax and description of the "AlgorithmName" notation.
#
# Per SSL/TLS specifications, cipher suites have the form:
# SSL_KeyExchangeAlg_WITH_CipherAlg_MacAlg
# or
# TLS_KeyExchangeAlg_WITH_CipherAlg_MacAlg
#
# For example, the cipher suite TLS_RSA_WITH_AES_128_CBC_SHA uses RSA as the
# key exchange algorithm, AES_128_CBC (128 bits AES cipher algorithm in CBC
# mode) as the cipher (encryption) algorithm, and SHA-1 as the message digest
# algorithm for HMAC.
#
# The LegacyAlgorithm can be one of the following standard algorithm names:
# 1. JSSE cipher suite name, e.g., TLS_RSA_WITH_AES_128_CBC_SHA
# 2. JSSE key exchange algorithm name, e.g., RSA
# 3. JSSE cipher (encryption) algorithm name, e.g., AES_128_CBC
# 4. JSSE message digest algorithm name, e.g., SHA-1
#
# See SSL/TLS specifications and "Java Cryptography Architecture Standard
# Algorithm Name Documentation" for information about the algorithm names.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
# There is no guarantee the property will continue to exist or be of the
# same syntax in future releases.
#
# Example:
# jdk.tls.legacyAlgorithms=DH_anon, DES_CBC, SSL_RSA_WITH_RC4_128_MD5
#
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
DH_RSA_EXPORT, RSA_EXPORT, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC
src/share/lib/security/java.security-solaris
浏览文件 @
a795dae7
...
@@ -503,3 +503,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
...
@@ -503,3 +503,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
# Example:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3
jdk.tls.disabledAlgorithms=SSLv3
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
#
# In some environments, a certain algorithm may be undesirable but it
# cannot be disabled because of its use in legacy applications. Legacy
# algorithms may still be supported, but applications should not use them
# as the security strength of legacy algorithms are usually not strong enough
# in practice.
#
# During SSL/TLS security parameters negotiation, legacy algorithms will
# not be negotiated unless there are no other candidates.
#
# The syntax of the disabled algorithm string is described as this Java
# BNF-style:
# LegacyAlgorithms:
# " LegacyAlgorithm { , LegacyAlgorithm } "
#
# LegacyAlgorithm:
# AlgorithmName (standard JSSE algorithm name)
#
# See the specification of security property "jdk.certpath.disabledAlgorithms"
# for the syntax and description of the "AlgorithmName" notation.
#
# Per SSL/TLS specifications, cipher suites have the form:
# SSL_KeyExchangeAlg_WITH_CipherAlg_MacAlg
# or
# TLS_KeyExchangeAlg_WITH_CipherAlg_MacAlg
#
# For example, the cipher suite TLS_RSA_WITH_AES_128_CBC_SHA uses RSA as the
# key exchange algorithm, AES_128_CBC (128 bits AES cipher algorithm in CBC
# mode) as the cipher (encryption) algorithm, and SHA-1 as the message digest
# algorithm for HMAC.
#
# The LegacyAlgorithm can be one of the following standard algorithm names:
# 1. JSSE cipher suite name, e.g., TLS_RSA_WITH_AES_128_CBC_SHA
# 2. JSSE key exchange algorithm name, e.g., RSA
# 3. JSSE cipher (encryption) algorithm name, e.g., AES_128_CBC
# 4. JSSE message digest algorithm name, e.g., SHA-1
#
# See SSL/TLS specifications and "Java Cryptography Architecture Standard
# Algorithm Name Documentation" for information about the algorithm names.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
# There is no guarantee the property will continue to exist or be of the
# same syntax in future releases.
#
# Example:
# jdk.tls.legacyAlgorithms=DH_anon, DES_CBC, SSL_RSA_WITH_RC4_128_MD5
#
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
DH_RSA_EXPORT, RSA_EXPORT, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC
src/share/lib/security/java.security-windows
浏览文件 @
a795dae7
...
@@ -504,3 +504,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
...
@@ -504,3 +504,60 @@ jdk.certpath.disabledAlgorithms=MD2, RSA keySize < 1024
# Example:
# Example:
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
# jdk.tls.disabledAlgorithms=MD5, SSLv3, DSA, RSA keySize < 2048
jdk.tls.disabledAlgorithms=SSLv3
jdk.tls.disabledAlgorithms=SSLv3
# Legacy algorithms for Secure Socket Layer/Transport Layer Security (SSL/TLS)
# processing in JSSE implementation.
#
# In some environments, a certain algorithm may be undesirable but it
# cannot be disabled because of its use in legacy applications. Legacy
# algorithms may still be supported, but applications should not use them
# as the security strength of legacy algorithms are usually not strong enough
# in practice.
#
# During SSL/TLS security parameters negotiation, legacy algorithms will
# not be negotiated unless there are no other candidates.
#
# The syntax of the disabled algorithm string is described as this Java
# BNF-style:
# LegacyAlgorithms:
# " LegacyAlgorithm { , LegacyAlgorithm } "
#
# LegacyAlgorithm:
# AlgorithmName (standard JSSE algorithm name)
#
# See the specification of security property "jdk.certpath.disabledAlgorithms"
# for the syntax and description of the "AlgorithmName" notation.
#
# Per SSL/TLS specifications, cipher suites have the form:
# SSL_KeyExchangeAlg_WITH_CipherAlg_MacAlg
# or
# TLS_KeyExchangeAlg_WITH_CipherAlg_MacAlg
#
# For example, the cipher suite TLS_RSA_WITH_AES_128_CBC_SHA uses RSA as the
# key exchange algorithm, AES_128_CBC (128 bits AES cipher algorithm in CBC
# mode) as the cipher (encryption) algorithm, and SHA-1 as the message digest
# algorithm for HMAC.
#
# The LegacyAlgorithm can be one of the following standard algorithm names:
# 1. JSSE cipher suite name, e.g., TLS_RSA_WITH_AES_128_CBC_SHA
# 2. JSSE key exchange algorithm name, e.g., RSA
# 3. JSSE cipher (encryption) algorithm name, e.g., AES_128_CBC
# 4. JSSE message digest algorithm name, e.g., SHA-1
#
# See SSL/TLS specifications and "Java Cryptography Architecture Standard
# Algorithm Name Documentation" for information about the algorithm names.
#
# Note: This property is currently used by Oracle's JSSE implementation.
# It is not guaranteed to be examined and used by other implementations.
# There is no guarantee the property will continue to exist or be of the
# same syntax in future releases.
#
# Example:
# jdk.tls.legacyAlgorithms=DH_anon, DES_CBC, SSL_RSA_WITH_RC4_128_MD5
#
jdk.tls.legacyAlgorithms= \
K_NULL, C_NULL, M_NULL, \
DHE_DSS_EXPORT, DHE_RSA_EXPORT, DH_anon_EXPORT, DH_DSS_EXPORT, \
DH_RSA_EXPORT, RSA_EXPORT, \
DH_anon, ECDH_anon, \
RC4_128, RC4_40, DES_CBC, DES40_CBC
test/sun/security/ssl/javax/net/ssl/SSLParameters/UseCipherSuitesOrder.java
浏览文件 @
a795dae7
/*
/*
* Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2013,
2015,
Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
*
* This code is free software; you can redistribute it and/or modify it
* This code is free software; you can redistribute it and/or modify it
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
* @bug 7188657
* @bug 7188657
* @summary There should be a way to reorder the JSSE ciphers
* @summary There should be a way to reorder the JSSE ciphers
* @run main/othervm UseCipherSuitesOrder
* @run main/othervm UseCipherSuitesOrder
* TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_
RC4_128
_SHA
* TLS_RSA_WITH_AES_128_CBC_SHA,SSL_RSA_WITH_
3DES_EDE_CBC
_SHA
*/
*/
import
java.io.*
;
import
java.io.*
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录