Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
64744bac
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看板
提交
64744bac
编写于
10月 13, 2016
作者:
R
robm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8140353: Improve signature checking
Reviewed-by: mullan
上级
b931ae25
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
93 addition
and
11 deletion
+93
-11
src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
...ses/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
+35
-1
src/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java
src/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java
+18
-0
src/share/lib/security/java.security-aix
src/share/lib/security/java.security-aix
+8
-2
src/share/lib/security/java.security-linux
src/share/lib/security/java.security-linux
+8
-2
src/share/lib/security/java.security-macosx
src/share/lib/security/java.security-macosx
+8
-2
src/share/lib/security/java.security-solaris
src/share/lib/security/java.security-solaris
+8
-2
src/share/lib/security/java.security-windows
src/share/lib/security/java.security-windows
+8
-2
未找到文件。
src/share/classes/org/jcp/xml/dsig/internal/dom/DOMSignatureMethod.java
浏览文件 @
64744bac
...
...
@@ -21,7 +21,7 @@
* under the License.
*/
/*
* Copyright (c) 2005, 201
4
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 201
6
, Oracle and/or its affiliates. All rights reserved.
*/
/*
* $Id: DOMSignatureMethod.java 1333415 2012-05-03 12:03:51Z coheigea $
...
...
@@ -41,6 +41,7 @@ import org.w3c.dom.Element;
import
com.sun.org.apache.xml.internal.security.algorithms.implementations.SignatureECDSA
;
import
com.sun.org.apache.xml.internal.security.utils.JavaUtils
;
import
org.jcp.xml.dsig.internal.SignerOutputStream
;
import
sun.security.util.KeyUtil
;
/**
* DOM-based abstract implementation of SignatureMethod.
...
...
@@ -162,6 +163,7 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
if
(!(
key
instanceof
PublicKey
))
{
throw
new
InvalidKeyException
(
"key must be PublicKey"
);
}
checkKeySize
(
context
,
key
);
if
(
signature
==
null
)
{
try
{
Provider
p
=
(
Provider
)
context
.
getProperty
...
...
@@ -197,6 +199,37 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
}
}
/**
* If secure validation mode is enabled, checks that the key size is
* restricted.
*
* @param context the context
* @param key the key to check
* @throws XMLSignatureException if the key size is restricted
*/
private
static
void
checkKeySize
(
XMLCryptoContext
context
,
Key
key
)
throws
XMLSignatureException
{
if
(
Utils
.
secureValidation
(
context
))
{
int
size
=
KeyUtil
.
getKeySize
(
key
);
if
(
size
==
-
1
)
{
// key size cannot be determined, so we cannot check against
// restrictions. Note that a DSA key w/o params will be
// rejected later if the certificate chain is validated.
if
(
log
.
isLoggable
(
java
.
util
.
logging
.
Level
.
FINE
))
{
log
.
log
(
java
.
util
.
logging
.
Level
.
FINE
,
"Size for "
+
key
.
getAlgorithm
()
+
" key cannot be determined"
);
}
return
;
}
if
(
Policy
.
restrictKey
(
key
.
getAlgorithm
(),
size
))
{
throw
new
XMLSignatureException
(
key
.
getAlgorithm
()
+
" keys less than "
+
Policy
.
minKeySize
(
key
.
getAlgorithm
())
+
" bits are"
+
" forbidden when secure validation is enabled"
);
}
}
}
byte
[]
sign
(
Key
key
,
SignedInfo
si
,
XMLSignContext
context
)
throws
InvalidKeyException
,
XMLSignatureException
{
...
...
@@ -207,6 +240,7 @@ public abstract class DOMSignatureMethod extends AbstractDOMSignatureMethod {
if
(!(
key
instanceof
PrivateKey
))
{
throw
new
InvalidKeyException
(
"key must be PrivateKey"
);
}
checkKeySize
(
context
,
key
);
if
(
signature
==
null
)
{
try
{
Provider
p
=
(
Provider
)
context
.
getProperty
...
...
src/share/classes/org/jcp/xml/dsig/internal/dom/Policy.java
浏览文件 @
64744bac
...
...
@@ -31,8 +31,10 @@ import java.security.AccessController;
import
java.security.PrivilegedAction
;
import
java.security.Security
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.HashSet
;
import
java.util.Locale
;
import
java.util.Map
;
import
java.util.Set
;
/**
...
...
@@ -46,6 +48,7 @@ public final class Policy {
private
static
int
maxTrans
=
Integer
.
MAX_VALUE
;
private
static
int
maxRefs
=
Integer
.
MAX_VALUE
;
private
static
Set
<
String
>
disallowedRefUriSchemes
=
new
HashSet
<>();
private
static
Map
<
String
,
Integer
>
minKeyMap
=
new
HashMap
<>();
private
static
boolean
noDuplicateIds
=
false
;
private
static
boolean
noRMLoops
=
false
;
...
...
@@ -101,6 +104,13 @@ public final class Policy {
scheme
.
toLowerCase
(
Locale
.
ROOT
));
}
break
;
case
"minKeySize"
:
if
(
tokens
.
length
!=
3
)
{
error
(
entry
);
}
minKeyMap
.
put
(
tokens
[
1
],
Integer
.
parseUnsignedInt
(
tokens
[
2
]));
break
;
case
"noDuplicateIds"
:
if
(
tokens
.
length
!=
1
)
{
error
(
entry
);
...
...
@@ -147,6 +157,10 @@ public final class Policy {
return
false
;
}
public
static
boolean
restrictKey
(
String
type
,
int
size
)
{
return
(
size
<
minKeyMap
.
getOrDefault
(
type
,
0
));
}
public
static
boolean
restrictDuplicateIds
()
{
return
noDuplicateIds
;
}
...
...
@@ -171,6 +185,10 @@ public final class Policy {
return
Collections
.<
String
>
unmodifiableSet
(
disallowedRefUriSchemes
);
}
public
static
int
minKeySize
(
String
type
)
{
return
minKeyMap
.
getOrDefault
(
type
,
0
);
}
private
static
void
error
(
String
entry
)
{
throw
new
IllegalArgumentException
(
"Invalid jdk.xml.dsig.secureValidationPolicy entry: "
+
entry
);
...
...
src/share/lib/security/java.security-aix
浏览文件 @
64744bac
...
...
@@ -674,7 +674,7 @@ jdk.tls.legacyAlgorithms= \
# Constraint {"," Constraint }
# Constraint:
# AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
# ReferenceUriSchemeConstraint | OtherConstraint
# ReferenceUriSchemeConstraint |
KeySizeConstraint |
OtherConstraint
# AlgConstraint
# "disallowAlg" Uri
# MaxTransformsConstraint:
...
...
@@ -683,12 +683,16 @@ jdk.tls.legacyAlgorithms= \
# "maxReferences" Integer
# ReferenceUriSchemeConstraint:
# "disallowReferenceUriSchemes" String { String }
# KeySizeConstraint:
# "minKeySize" KeyAlg Integer
# OtherConstraint:
# "noDuplicateIds" | "noRetrievalMethodLoops"
#
# For AlgConstraint, Uri is the algorithm URI String that is not allowed.
# See the XML Signature Recommendation for more information on algorithm
# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
# specified more than once, only the last entry is enforced.
#
# Note: This property is currently used by the JDK Reference implementation. It
...
...
@@ -702,6 +706,8 @@ jdk.xml.dsig.secureValidationPolicy=\
maxTransforms 5,\
maxReferences 30,\
disallowReferenceUriSchemes file http https,\
minKeySize RSA 1024,\
minKeySize DSA 1024,\
noDuplicateIds,\
noRetrievalMethodLoops
...
...
src/share/lib/security/java.security-linux
浏览文件 @
64744bac
...
...
@@ -674,7 +674,7 @@ jdk.tls.legacyAlgorithms= \
# Constraint {"," Constraint }
# Constraint:
# AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
# ReferenceUriSchemeConstraint | OtherConstraint
# ReferenceUriSchemeConstraint |
KeySizeConstraint |
OtherConstraint
# AlgConstraint
# "disallowAlg" Uri
# MaxTransformsConstraint:
...
...
@@ -683,12 +683,16 @@ jdk.tls.legacyAlgorithms= \
# "maxReferences" Integer
# ReferenceUriSchemeConstraint:
# "disallowReferenceUriSchemes" String { String }
# KeySizeConstraint:
# "minKeySize" KeyAlg Integer
# OtherConstraint:
# "noDuplicateIds" | "noRetrievalMethodLoops"
#
# For AlgConstraint, Uri is the algorithm URI String that is not allowed.
# See the XML Signature Recommendation for more information on algorithm
# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
# specified more than once, only the last entry is enforced.
#
# Note: This property is currently used by the JDK Reference implementation. It
...
...
@@ -702,6 +706,8 @@ jdk.xml.dsig.secureValidationPolicy=\
maxTransforms 5,\
maxReferences 30,\
disallowReferenceUriSchemes file http https,\
minKeySize RSA 1024,\
minKeySize DSA 1024,\
noDuplicateIds,\
noRetrievalMethodLoops
...
...
src/share/lib/security/java.security-macosx
浏览文件 @
64744bac
...
...
@@ -677,7 +677,7 @@ jdk.tls.legacyAlgorithms= \
# Constraint {"," Constraint }
# Constraint:
# AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
# ReferenceUriSchemeConstraint | OtherConstraint
# ReferenceUriSchemeConstraint |
KeySizeConstraint |
OtherConstraint
# AlgConstraint
# "disallowAlg" Uri
# MaxTransformsConstraint:
...
...
@@ -686,12 +686,16 @@ jdk.tls.legacyAlgorithms= \
# "maxReferences" Integer
# ReferenceUriSchemeConstraint:
# "disallowReferenceUriSchemes" String { String }
# KeySizeConstraint:
# "minKeySize" KeyAlg Integer
# OtherConstraint:
# "noDuplicateIds" | "noRetrievalMethodLoops"
#
# For AlgConstraint, Uri is the algorithm URI String that is not allowed.
# See the XML Signature Recommendation for more information on algorithm
# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
# specified more than once, only the last entry is enforced.
#
# Note: This property is currently used by the JDK Reference implementation. It
...
...
@@ -705,6 +709,8 @@ jdk.xml.dsig.secureValidationPolicy=\
maxTransforms 5,\
maxReferences 30,\
disallowReferenceUriSchemes file http https,\
minKeySize RSA 1024,\
minKeySize DSA 1024,\
noDuplicateIds,\
noRetrievalMethodLoops
...
...
src/share/lib/security/java.security-solaris
浏览文件 @
64744bac
...
...
@@ -676,7 +676,7 @@ jdk.tls.legacyAlgorithms= \
# Constraint {"," Constraint }
# Constraint:
# AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
# ReferenceUriSchemeConstraint | OtherConstraint
# ReferenceUriSchemeConstraint |
KeySizeConstraint |
OtherConstraint
# AlgConstraint
# "disallowAlg" Uri
# MaxTransformsConstraint:
...
...
@@ -685,12 +685,16 @@ jdk.tls.legacyAlgorithms= \
# "maxReferences" Integer
# ReferenceUriSchemeConstraint:
# "disallowReferenceUriSchemes" String { String }
# KeySizeConstraint:
# "minKeySize" KeyAlg Integer
# OtherConstraint:
# "noDuplicateIds" | "noRetrievalMethodLoops"
#
# For AlgConstraint, Uri is the algorithm URI String that is not allowed.
# See the XML Signature Recommendation for more information on algorithm
# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
# specified more than once, only the last entry is enforced.
#
# Note: This property is currently used by the JDK Reference implementation. It
...
...
@@ -704,6 +708,8 @@ jdk.xml.dsig.secureValidationPolicy=\
maxTransforms 5,\
maxReferences 30,\
disallowReferenceUriSchemes file http https,\
minKeySize RSA 1024,\
minKeySize DSA 1024,\
noDuplicateIds,\
noRetrievalMethodLoops
...
...
src/share/lib/security/java.security-windows
浏览文件 @
64744bac
...
...
@@ -677,7 +677,7 @@ jdk.tls.legacyAlgorithms= \
# Constraint {"," Constraint }
# Constraint:
# AlgConstraint | MaxTransformsConstraint | MaxReferencesConstraint |
# ReferenceUriSchemeConstraint | OtherConstraint
# ReferenceUriSchemeConstraint |
KeySizeConstraint |
OtherConstraint
# AlgConstraint
# "disallowAlg" Uri
# MaxTransformsConstraint:
...
...
@@ -686,12 +686,16 @@ jdk.tls.legacyAlgorithms= \
# "maxReferences" Integer
# ReferenceUriSchemeConstraint:
# "disallowReferenceUriSchemes" String { String }
# KeySizeConstraint:
# "minKeySize" KeyAlg Integer
# OtherConstraint:
# "noDuplicateIds" | "noRetrievalMethodLoops"
#
# For AlgConstraint, Uri is the algorithm URI String that is not allowed.
# See the XML Signature Recommendation for more information on algorithm
# URI Identifiers. If the MaxTransformsConstraint or MaxReferencesConstraint is
# URI Identifiers. For KeySizeConstraint, KeyAlg is the standard algorithm
# name of the key type (ex: "RSA"). If the MaxTransformsConstraint,
# MaxReferencesConstraint or KeySizeConstraint (for the same key type) is
# specified more than once, only the last entry is enforced.
#
# Note: This property is currently used by the JDK Reference implementation. It
...
...
@@ -705,6 +709,8 @@ jdk.xml.dsig.secureValidationPolicy=\
maxTransforms 5,\
maxReferences 30,\
disallowReferenceUriSchemes file http https,\
minKeySize RSA 1024,\
minKeySize DSA 1024,\
noDuplicateIds,\
noRetrievalMethodLoops
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录