Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
7cc8634a
D
dragonwell8_jdk
项目概览
openanolis
/
dragonwell8_jdk
通知
3
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,体验更适合开发者的 AI 搜索 >>
提交
7cc8634a
编写于
7月 22, 2011
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6330275: Rework the PaddingTest regression test.
Reviewed-by: wetmore, smarks
上级
31842b4a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
53 addition
and
82 deletion
+53
-82
test/ProblemList.txt
test/ProblemList.txt
+0
-3
test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
+53
-79
未找到文件。
test/ProblemList.txt
浏览文件 @
7cc8634a
...
...
@@ -537,9 +537,6 @@ sun/security/krb5/auto/basic.sh solaris-sparc
sun/security/provider/PolicyFile/getinstance/getinstance.sh solaris-sparc
sun/security/tools/jarsigner/samename.sh solaris-sparc
# Timed out, Solaris 10 64bit sparcv9
com/sun/crypto/provider/Cipher/DES/PaddingTest.java generic-all
# Othervm, sparc, NoRouteToHostException: Cannot assign requested address
sun/security/ssl/javax/net/ssl/NewAPIs/SessionCacheSizeTests.java generic-all
...
...
test/com/sun/crypto/provider/Cipher/DES/PaddingTest.java
浏览文件 @
7cc8634a
/*
* Copyright (c) 1997, 20
07
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 20
11
, 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
...
...
@@ -23,16 +23,17 @@
/*
* @test
* @bug 0000000 6296075
* @bug 0000000 6296075
6330275
* @summary PaddingTest
* @author Jan Luehe
*/
import
java.io.*
;
import
java.security.*
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.security.spec.*
;
import
javax.crypto.*
;
import
javax.crypto.spec.*
;
import
com.sun.crypto.provider.*
;
import
java.util.Arrays
;
public
class
PaddingTest
{
...
...
@@ -80,7 +81,7 @@ public class PaddingTest {
public
void
run
()
throws
Exception
{
for
(
int
l
=
0
;
l
<
numFiles
;
l
++)
{
pinfile
=
new
String
(
dataDir
+
"plain"
+
l
+
".txt"
)
;
pinfile
=
dataDir
+
"plain"
+
l
+
".txt"
;
for
(
int
i
=
0
;
i
<
crypts
.
length
;
i
++)
{
for
(
int
j
=
0
;
j
<
modes
.
length
;
j
++)
{
for
(
int
k
=
0
;
k
<
paddings
.
length
;
k
++)
{
...
...
@@ -89,14 +90,12 @@ public class PaddingTest {
System
.
out
.
println
(
crypts
[
i
]+
" "
+
modes
[
j
]+
" "
+
paddings
[
k
]+
" "
+
"plain"
+
l
+
" test"
);
cfile
=
new
String
(
"c"
+
l
+
"_"
+
cfile
=
"c"
+
l
+
"_"
+
crypts
[
i
]
+
"_"
+
modes
[
j
]
+
"_"
+
paddings
[
k
]
+
".bin"
);
poutfile
=
new
String
(
"p"
+
l
+
"_"
+
crypts
[
i
]
+
modes
[
j
]
+
paddings
[
k
]
+
".txt"
);
paddings
[
k
]
+
".bin"
;
poutfile
=
"p"
+
l
+
"_"
+
crypts
[
i
]
+
modes
[
j
]
+
paddings
[
k
]
+
".txt"
;
init
(
crypts
[
i
],
modes
[
j
],
paddings
[
k
]);
padding
=
paddings
[
k
];
...
...
@@ -108,10 +107,7 @@ public class PaddingTest {
}
public
void
init
(
String
crypt
,
String
mode
,
String
padding
)
throws
Exception
{
SunJCE
jce
=
new
SunJCE
();
Security
.
addProvider
(
jce
);
throws
Exception
{
KeySpec
desKeySpec
=
null
;
SecretKeyFactory
factory
=
null
;
...
...
@@ -148,82 +144,60 @@ public class PaddingTest {
int
len
;
int
totalInputLen
=
0
;
BufferedInputStream
pin
=
null
;
BufferedOutputStream
cout
=
null
;
BufferedInputStream
cin
=
null
;
BufferedOutputStream
pout
=
null
;
try
{
pin
=
new
BufferedInputStream
(
new
FileInputStream
(
pinfile
));
cout
=
new
BufferedOutputStream
(
new
FileOutputStream
(
cfile
));
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
cipherKey
,
params
);
while
((
len
=
pin
.
read
(
input
,
0
,
bufferLen
))
>
0
)
{
totalInputLen
+=
len
;
byte
[]
output
=
cipher
.
update
(
input
,
0
,
len
);
cout
.
write
(
output
,
0
,
output
.
length
);
cout
.
flush
();
}
try
(
FileInputStream
fin
=
new
FileInputStream
(
pinfile
);
BufferedInputStream
pin
=
new
BufferedInputStream
(
fin
);
FileOutputStream
fout
=
new
FileOutputStream
(
cfile
);
BufferedOutputStream
cout
=
new
BufferedOutputStream
(
fout
))
{
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
cipherKey
,
params
);
while
((
len
=
pin
.
read
(
input
,
0
,
bufferLen
))
>
0
)
{
totalInputLen
+=
len
;
byte
[]
output
=
cipher
.
update
(
input
,
0
,
len
);
cout
.
write
(
output
,
0
,
output
.
length
);
}
len
=
cipher
.
getOutputSize
(
0
);
len
=
cipher
.
getOutputSize
(
0
);
byte
[]
out
=
new
byte
[
len
];
len
=
cipher
.
doFinal
(
out
,
0
);
cout
.
write
(
out
,
0
,
len
);
cout
.
flush
();
byte
[]
out
=
new
byte
[
len
];
len
=
cipher
.
doFinal
(
out
,
0
);
cout
.
write
(
out
,
0
,
len
);
}
try
(
FileInputStream
fin
=
new
FileInputStream
(
cfile
);
BufferedInputStream
cin
=
new
BufferedInputStream
(
fin
);
FileOutputStream
fout
=
new
FileOutputStream
(
poutfile
);
BufferedOutputStream
pout
=
new
BufferedOutputStream
(
fout
))
{
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
cipherKey
,
params
);
cin
=
new
BufferedInputStream
(
new
FileInputStream
(
cfile
));
pout
=
new
BufferedOutputStream
(
new
FileOutputStream
(
poutfile
));
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
cipherKey
,
params
);
byte
[]
output
=
null
;
while
((
len
=
cin
.
read
(
input
,
0
,
bufferLen
))
>
0
)
{
output
=
cipher
.
update
(
input
,
0
,
len
);
pout
.
write
(
output
,
0
,
output
.
length
);
}
byte
[]
output
=
null
;
while
((
len
=
cin
.
read
(
input
,
0
,
bufferLen
))
>
0
)
{
output
=
cipher
.
update
(
input
,
0
,
len
);
pout
.
write
(
output
,
0
,
output
.
length
);
pout
.
flush
();
len
=
cipher
.
getOutputSize
(
0
);
byte
[]
out
=
new
byte
[
len
];
len
=
cipher
.
doFinal
(
out
,
0
);
pout
.
write
(
out
,
0
,
len
);
}
len
=
cipher
.
getOutputSize
(
0
);
out
=
new
byte
[
len
];
len
=
cipher
.
doFinal
(
out
,
0
);
pout
.
write
(
out
,
0
,
len
);
pout
.
flush
();
Process
child
=
Runtime
.
getRuntime
().
exec
(
"diff "
+
pinfile
+
" "
+
poutfile
);
InputStream
in
=
child
.
getInputStream
();
byte
[]
data
=
new
byte
[
64
];
while
((
len
=
in
.
read
(
data
))
!=
-
1
)
System
.
out
.
write
(
data
,
0
,
len
);
in
.
close
();
child
.
waitFor
();
System
.
out
.
println
(
"child exited with "
+
child
.
exitValue
());
}
catch
(
IllegalBlockSizeException
ex
)
{
if
((
totalInputLen
%
8
!=
0
)
&&
(
padding
.
equals
(
"NoPadding"
)))
diff
(
pinfile
,
poutfile
);
}
catch
(
IllegalBlockSizeException
ex
)
{
if
((
totalInputLen
%
8
!=
0
)
&&
(
padding
.
equals
(
"NoPadding"
)))
{
return
;
else
{
}
else
{
System
.
out
.
println
(
"Test failed!"
);
throw
ex
;
}
}
finally
{
try
{
if
(
pin
!=
null
)
pin
.
close
();
if
(
pout
!=
null
)
pout
.
close
();
if
(
cin
!=
null
)
cin
.
close
();
if
(
cout
!=
null
)
cout
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
return
;
}
}
}
private
static
void
diff
(
String
fname1
,
String
fname2
)
throws
Exception
{
if
(!
Arrays
.
equals
(
Files
.
readAllBytes
(
Paths
.
get
(
fname1
)),
Files
.
readAllBytes
(
Paths
.
get
(
fname1
))))
{
throw
new
Exception
(
"files "
+
fname1
+
" and "
+
fname2
+
" differ"
);
}
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录