Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
62a13dd6
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看板
提交
62a13dd6
编写于
4月 19, 2016
作者:
R
rhalade
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8137231: sun/security/rsa/SpecTest.java timeout with Agent error: java.lang.Exception
Reviewed-by: valeriep
上级
6a3d6027
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
33 addition
and
43 deletion
+33
-43
test/sun/security/rsa/SpecTest.java
test/sun/security/rsa/SpecTest.java
+33
-43
未找到文件。
test/sun/security/rsa/SpecTest.java
浏览文件 @
62a13dd6
...
...
@@ -20,32 +20,32 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
import
java.math.BigInteger
;
import
java.security.InvalidAlgorithmParameterException
;
import
java.security.KeyPair
;
import
java.security.KeyPairGenerator
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchProviderException
;
import
java.security.interfaces.RSAKey
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.RSAKeyGenParameterSpec
;
/**
* @test
* @bug 8044199
* @bug 8044199
8137231
* @key intermittent
* @summary Check same KeyPair's private key and public key have same modulus.
*
also check public key's public exponent equals to given spec's public
*
exponent
.
* also check public key's public exponent equals to given spec's public
*
exponent. Only key size 1024 is tested with RSAKeyGenParameterSpec.F0 (3)
.
* @run main SpecTest 512
* @run main SpecTest 768
* @run main SpecTest 1024
* @run main SpecTest 1024 3
* @run main SpecTest 2048
* @run main/timeout=240 SpecTest 4096
* @run main/timeout=240 SpecTest 5120
*/
import
java.math.BigInteger
;
import
java.security.KeyPair
;
import
java.security.KeyPairGenerator
;
import
java.security.interfaces.RSAKey
;
import
java.security.interfaces.RSAPrivateKey
;
import
java.security.interfaces.RSAPublicKey
;
import
java.security.spec.RSAKeyGenParameterSpec
;
public
class
SpecTest
{
/**
* ALGORITHM name, fixed as RSA.
*/
...
...
@@ -70,14 +70,14 @@ public class SpecTest {
// test the getModulus method
if
((
priv
instanceof
RSAKey
)
&&
(
pub
instanceof
RSAKey
))
{
if
(!
priv
.
getModulus
().
equals
(
pub
.
getModulus
()))
{
System
.
err
.
println
(
"priv.getModulus() = "
+
priv
.
getModulus
());
System
.
err
.
println
(
"pub.getModulus() = "
+
pub
.
getModulus
());
System
.
out
.
println
(
"priv.getModulus() = "
+
priv
.
getModulus
());
System
.
out
.
println
(
"pub.getModulus() = "
+
pub
.
getModulus
());
passed
=
false
;
}
if
(!
pubExponent
.
equals
(
pub
.
getPublicExponent
()))
{
System
.
err
.
println
(
"pubExponent = "
+
pubExponent
);
System
.
err
.
println
(
"pub.getPublicExponent() = "
System
.
out
.
println
(
"pubExponent = "
+
pubExponent
);
System
.
out
.
println
(
"pub.getPublicExponent() = "
+
pub
.
getPublicExponent
());
passed
=
false
;
}
...
...
@@ -85,36 +85,26 @@ public class SpecTest {
return
passed
;
}
public
static
void
main
(
String
[]
args
)
{
int
failCount
=
0
;
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// Test key size.
int
size
=
Integer
.
parseInt
(
args
[
0
]);
int
size
=
0
;
try
{
KeyPairGenerator
kpg1
=
KeyPairGenerator
.
getInstance
(
KEYALG
,
PROVIDER
);
kpg1
.
initialize
(
new
RSAKeyGenParameterSpec
(
size
,
RSAKeyGenParameterSpec
.
F4
));
if
(!
specTest
(
kpg1
.
generateKeyPair
(),
RSAKeyGenParameterSpec
.
F4
))
{
failCount
++;
}
KeyPairGenerator
kpg2
=
KeyPairGenerator
.
getInstance
(
KEYALG
,
PROVIDER
);
kpg2
.
initialize
(
new
RSAKeyGenParameterSpec
(
size
,
RSAKeyGenParameterSpec
.
F0
));
if
(!
specTest
(
kpg2
.
generateKeyPair
(),
RSAKeyGenParameterSpec
.
F0
))
{
failCount
++;
}
}
catch
(
NoSuchAlgorithmException
|
NoSuchProviderException
|
InvalidAlgorithmParameterException
ex
)
{
ex
.
printStackTrace
(
System
.
err
);
failCount
++;
if
(
args
.
length
>=
1
)
{
size
=
Integer
.
parseInt
(
args
[
0
]);
}
else
{
throw
new
RuntimeException
(
"Missing keysize to test with"
);
}
if
(
failCount
!=
0
)
{
throw
new
RuntimeException
(
"There are "
+
failCount
+
" tests failed."
);
BigInteger
publicExponent
=
(
args
.
length
>=
2
)
?
new
BigInteger
(
args
[
1
])
:
RSAKeyGenParameterSpec
.
F4
;
System
.
out
.
println
(
"Running test with key size: "
+
size
+
" and public exponent: "
+
publicExponent
);
KeyPairGenerator
kpg1
=
KeyPairGenerator
.
getInstance
(
KEYALG
,
PROVIDER
);
kpg1
.
initialize
(
new
RSAKeyGenParameterSpec
(
size
,
publicExponent
));
if
(!
specTest
(
kpg1
.
generateKeyPair
(),
publicExponent
))
{
throw
new
RuntimeException
(
"Test failed."
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录