Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9b65d35f
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9b65d35f
编写于
4月 19, 2013
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8009636: JARSigner including TimeStamp PolicyID (TSAPolicyID) as defined in RFC3161
Reviewed-by: mullan
上级
1137dfe6
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
59 addition
and
11 deletion
+59
-11
src/share/classes/com/sun/jarsigner/ContentSignerParameters.java
...re/classes/com/sun/jarsigner/ContentSignerParameters.java
+7
-0
src/share/classes/sun/security/pkcs/PKCS7.java
src/share/classes/sun/security/pkcs/PKCS7.java
+20
-4
src/share/classes/sun/security/timestamp/TSRequest.java
src/share/classes/sun/security/timestamp/TSRequest.java
+2
-1
src/share/classes/sun/security/timestamp/TimestampToken.java
src/share/classes/sun/security/timestamp/TimestampToken.java
+4
-0
src/share/classes/sun/security/tools/jarsigner/Main.java
src/share/classes/sun/security/tools/jarsigner/Main.java
+19
-4
src/share/classes/sun/security/tools/jarsigner/Resources.java
...share/classes/sun/security/tools/jarsigner/Resources.java
+2
-0
src/share/classes/sun/security/tools/jarsigner/TimestampedSigner.java
...asses/sun/security/tools/jarsigner/TimestampedSigner.java
+2
-1
test/sun/security/tools/jarsigner/TimestampCheck.java
test/sun/security/tools/jarsigner/TimestampCheck.java
+2
-0
test/sun/security/tools/jarsigner/ts.sh
test/sun/security/tools/jarsigner/ts.sh
+1
-1
未找到文件。
src/share/classes/com/sun/jarsigner/ContentSignerParameters.java
浏览文件 @
9b65d35f
...
...
@@ -59,6 +59,13 @@ public interface ContentSignerParameters {
*/
public
X509Certificate
getTimestampingAuthorityCertificate
();
/**
* Retrieves the TSAPolicyID for a Timestamping Authority (TSA).
*
* @return The TSAPolicyID. May be null.
*/
public
String
getTSAPolicyID
();
/**
* Retrieves the JAR file's signature.
*
...
...
src/share/classes/sun/security/pkcs/PKCS7.java
浏览文件 @
9b65d35f
...
...
@@ -784,6 +784,9 @@ public class PKCS7 {
* @param signatureAlgorithm the name of the signature algorithm
* @param tsaURI the URI of the Timestamping Authority; or null if no
* timestamp is requested
* @param tSAPolicyID the TSAPolicyID of the Timestamping Authority as a
* numerical object identifier; or null if we leave the TSA server
* to choose one. This argument is only used when tsaURI is provided
* @return the bytes of the encoded PKCS #7 signed data message
* @throws NoSuchAlgorithmException The exception is thrown if the signature
* algorithm is unrecognised.
...
...
@@ -798,7 +801,8 @@ public class PKCS7 {
X509Certificate
[]
signerChain
,
byte
[]
content
,
String
signatureAlgorithm
,
URI
tsaURI
)
URI
tsaURI
,
String
tSAPolicyID
)
throws
CertificateException
,
IOException
,
NoSuchAlgorithmException
{
...
...
@@ -807,7 +811,7 @@ public class PKCS7 {
if
(
tsaURI
!=
null
)
{
// Timestamp the signature
HttpTimestamper
tsa
=
new
HttpTimestamper
(
tsaURI
);
byte
[]
tsToken
=
generateTimestampToken
(
tsa
,
signature
);
byte
[]
tsToken
=
generateTimestampToken
(
tsa
,
tSAPolicyID
,
signature
);
// Insert the timestamp token into the PKCS #7 signer info element
// (as an unsigned attribute)
...
...
@@ -851,14 +855,20 @@ public class PKCS7 {
* set to true.
*
* @param tsa the timestamping authority to use
* @param tSAPolicyID the TSAPolicyID of the Timestamping Authority as a
* numerical object identifier; or null if we leave the TSA server
* to choose one
* @param toBeTimestamped the token that is to be timestamped
* @return the encoded timestamp token
* @throws IOException The exception is thrown if an error occurs while
* communicating with the TSA.
* communicating with the TSA, or a non-null
* TSAPolicyID is specified in the request but it
* does not match the one in the reply
* @throws CertificateException The exception is thrown if the TSA's
* certificate is not permitted for timestamping.
*/
private
static
byte
[]
generateTimestampToken
(
Timestamper
tsa
,
String
tSAPolicyID
,
byte
[]
toBeTimestamped
)
throws
IOException
,
CertificateException
{
...
...
@@ -868,7 +878,7 @@ public class PKCS7 {
try
{
// SHA-1 is always used.
messageDigest
=
MessageDigest
.
getInstance
(
"SHA-1"
);
tsQuery
=
new
TSRequest
(
toBeTimestamped
,
messageDigest
);
tsQuery
=
new
TSRequest
(
t
SAPolicyID
,
t
oBeTimestamped
,
messageDigest
);
}
catch
(
NoSuchAlgorithmException
e
)
{
// ignore
}
...
...
@@ -889,6 +899,12 @@ public class PKCS7 {
tsReply
.
getStatusCodeAsText
()
+
" "
+
tsReply
.
getFailureCodeAsText
());
}
if
(
tSAPolicyID
!=
null
&&
!
tSAPolicyID
.
equals
(
tsReply
.
getTimestampToken
().
getPolicyID
()))
{
throw
new
IOException
(
"TSAPolicyID changed in "
+
"timestamp token"
);
}
PKCS7
tsToken
=
tsReply
.
getToken
();
TimestampToken
tst
=
tsReply
.
getTimestampToken
();
...
...
src/share/classes/sun/security/timestamp/TSRequest.java
浏览文件 @
9b65d35f
...
...
@@ -88,9 +88,10 @@ public class TSRequest {
* @param messageDigest The MessageDigest of the hash algorithm to use.
* @throws NoSuchAlgorithmException if the hash algorithm is not supported
*/
public
TSRequest
(
byte
[]
toBeTimeStamped
,
MessageDigest
messageDigest
)
public
TSRequest
(
String
tSAPolicyID
,
byte
[]
toBeTimeStamped
,
MessageDigest
messageDigest
)
throws
NoSuchAlgorithmException
{
this
.
policyId
=
tSAPolicyID
;
this
.
hashAlgorithmId
=
AlgorithmId
.
get
(
messageDigest
.
getAlgorithm
());
this
.
hashValue
=
messageDigest
.
digest
(
toBeTimeStamped
);
}
...
...
src/share/classes/sun/security/timestamp/TimestampToken.java
浏览文件 @
9b65d35f
...
...
@@ -115,6 +115,10 @@ public class TimestampToken {
return
nonce
;
}
public
String
getPolicyID
()
{
return
policy
.
toString
();
}
/*
* Parses the timestamp token info.
*
...
...
src/share/classes/sun/security/tools/jarsigner/Main.java
浏览文件 @
9b65d35f
...
...
@@ -141,6 +141,7 @@ public class Main {
String
tsaUrl
;
// location of the Timestamping Authority
String
tsaAlias
;
// alias for the Timestamping Authority's certificate
String
altCertChain
;
// file to read alternative cert chain from
String
tSAPolicyID
;
boolean
verify
=
false
;
// verify the jar
String
verbose
=
null
;
// verbose output when signing/verifying
boolean
showcerts
=
false
;
// show certs when verifying
...
...
@@ -331,6 +332,9 @@ public class Main {
}
else
if
(
collator
.
compare
(
flags
,
"-certchain"
)
==
0
)
{
if
(++
n
==
args
.
length
)
usageNoArg
();
altCertChain
=
args
[
n
];
}
else
if
(
collator
.
compare
(
flags
,
"-tsapolicyid"
)
==
0
)
{
if
(++
n
==
args
.
length
)
usageNoArg
();
tSAPolicyID
=
args
[
n
];
}
else
if
(
collator
.
compare
(
flags
,
"-debug"
)
==
0
)
{
debug
=
true
;
}
else
if
(
collator
.
compare
(
flags
,
"-keypass"
)
==
0
)
{
...
...
@@ -530,6 +534,9 @@ public class Main {
System
.
out
.
println
(
rb
.
getString
(
".tsacert.alias.public.key.certificate.for.Timestamping.Authority"
));
System
.
out
.
println
();
System
.
out
.
println
(
rb
.
getString
(
".tsapolicyid.tsapolicyid.for.Timestamping.Authority"
));
System
.
out
.
println
();
System
.
out
.
println
(
rb
.
getString
(
".altsigner.class.class.name.of.an.alternative.signing.mechanism"
));
System
.
out
.
println
();
...
...
@@ -1232,7 +1239,7 @@ public class Main {
try
{
block
=
sf
.
generateBlock
(
privateKey
,
sigalg
,
certChain
,
externalSF
,
tsaUrl
,
tsaCert
,
signingMechanism
,
args
,
externalSF
,
tsaUrl
,
tsaCert
,
tSAPolicyID
,
signingMechanism
,
args
,
zipFile
);
}
catch
(
SocketTimeoutException
e
)
{
// Provide a helpful message when TSA is beyond a firewall
...
...
@@ -2206,13 +2213,14 @@ class SignatureFile {
X509Certificate
[]
certChain
,
boolean
externalSF
,
String
tsaUrl
,
X509Certificate
tsaCert
,
String
tSAPolicyID
,
ContentSigner
signingMechanism
,
String
[]
args
,
ZipFile
zipFile
)
throws
NoSuchAlgorithmException
,
InvalidKeyException
,
IOException
,
SignatureException
,
CertificateException
{
return
new
Block
(
this
,
privateKey
,
sigalg
,
certChain
,
externalSF
,
tsaUrl
,
tsaCert
,
signingMechanism
,
args
,
zipFile
);
tsaUrl
,
tsaCert
,
tSAPolicyID
,
signingMechanism
,
args
,
zipFile
);
}
...
...
@@ -2226,7 +2234,7 @@ class SignatureFile {
*/
Block
(
SignatureFile
sfg
,
PrivateKey
privateKey
,
String
sigalg
,
X509Certificate
[]
certChain
,
boolean
externalSF
,
String
tsaUrl
,
X509Certificate
tsaCert
,
ContentSigner
signingMechanism
,
X509Certificate
tsaCert
,
String
tSAPolicyID
,
ContentSigner
signingMechanism
,
String
[]
args
,
ZipFile
zipFile
)
throws
NoSuchAlgorithmException
,
InvalidKeyException
,
IOException
,
SignatureException
,
CertificateException
{
...
...
@@ -2309,7 +2317,7 @@ class SignatureFile {
// Assemble parameters for the signing mechanism
ContentSignerParameters
params
=
new
JarSignerParameters
(
args
,
tsaUri
,
tsaCert
,
signature
,
new
JarSignerParameters
(
args
,
tsaUri
,
tsaCert
,
tSAPolicyID
,
signature
,
signatureAlgorithm
,
certChain
,
content
,
zipFile
);
// Generate the signature block
...
...
@@ -2353,11 +2361,13 @@ class JarSignerParameters implements ContentSignerParameters {
private
X509Certificate
[]
signerCertificateChain
;
private
byte
[]
content
;
private
ZipFile
source
;
private
String
tSAPolicyID
;
/**
* Create a new object.
*/
JarSignerParameters
(
String
[]
args
,
URI
tsa
,
X509Certificate
tsaCertificate
,
String
tSAPolicyID
,
byte
[]
signature
,
String
signatureAlgorithm
,
X509Certificate
[]
signerCertificateChain
,
byte
[]
content
,
ZipFile
source
)
{
...
...
@@ -2369,6 +2379,7 @@ class JarSignerParameters implements ContentSignerParameters {
this
.
args
=
args
;
this
.
tsa
=
tsa
;
this
.
tsaCertificate
=
tsaCertificate
;
this
.
tSAPolicyID
=
tSAPolicyID
;
this
.
signature
=
signature
;
this
.
signatureAlgorithm
=
signatureAlgorithm
;
this
.
signerCertificateChain
=
signerCertificateChain
;
...
...
@@ -2403,6 +2414,10 @@ class JarSignerParameters implements ContentSignerParameters {
return
tsaCertificate
;
}
public
String
getTSAPolicyID
()
{
return
tSAPolicyID
;
}
/**
* Retrieves the signature.
*
...
...
src/share/classes/sun/security/tools/jarsigner/Resources.java
浏览文件 @
9b65d35f
...
...
@@ -86,6 +86,8 @@ public class Resources extends java.util.ListResourceBundle {
"[-tsa <url>] location of the Timestamping Authority"
},
{
".tsacert.alias.public.key.certificate.for.Timestamping.Authority"
,
"[-tsacert <alias>] public key certificate for Timestamping Authority"
},
{
".tsapolicyid.tsapolicyid.for.Timestamping.Authority"
,
"[-tsapolicyid <oid>] TSAPolicyID for Timestamping Authority"
},
{
".altsigner.class.class.name.of.an.alternative.signing.mechanism"
,
"[-altsigner <class>] class name of an alternative signing mechanism"
},
{
".altsignerpath.pathlist.location.of.an.alternative.signing.mechanism"
,
...
...
src/share/classes/sun/security/tools/jarsigner/TimestampedSigner.java
浏览文件 @
9b65d35f
...
...
@@ -133,7 +133,8 @@ public final class TimestampedSigner extends ContentSigner {
}
}
return
PKCS7
.
generateSignedData
(
signature
,
signerChain
,
content
,
params
.
getSignatureAlgorithm
(),
tsaURI
);
params
.
getSignatureAlgorithm
(),
tsaURI
,
params
.
getTSAPolicyID
());
}
/**
...
...
test/sun/security/tools/jarsigner/TimestampCheck.java
浏览文件 @
9b65d35f
...
...
@@ -260,6 +260,8 @@ public class TimestampCheck {
jarsigner
(
cmd
,
7
,
false
);
// tsbad2
jarsigner
(
cmd
,
8
,
false
);
// tsbad3
jarsigner
(
cmd
,
9
,
false
);
// no cert in timestamp
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.4"
,
0
,
true
);
jarsigner
(
cmd
+
" -tsapolicyid 1.2.3.5"
,
0
,
false
);
}
else
{
// Run as a standalone server
System
.
err
.
println
(
"Press Enter to quit server"
);
System
.
in
.
read
();
...
...
test/sun/security/tools/jarsigner/ts.sh
浏览文件 @
9b65d35f
...
...
@@ -22,7 +22,7 @@
#
# @test
# @bug 6543842 6543440 6939248
# @bug 6543842 6543440 6939248
8009636
# @summary checking response of timestamp
#
# @run shell/timeout=600 ts.sh
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录