Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
5bfd1cd2
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看板
提交
5bfd1cd2
编写于
6月 10, 2014
作者:
A
ascarpino
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8039212: SecretKeyBasic.sh needs to avoid NSS libnss3 and libsoftokn3 version mismatches
Reviewed-by: vinnie
上级
1d49124c
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
56 addition
and
7 deletion
+56
-7
test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
+8
-1
test/sun/security/pkcs11/PKCS11Test.java
test/sun/security/pkcs11/PKCS11Test.java
+48
-6
未找到文件。
test/sun/security/pkcs11/KeyStore/SecretKeysBasic.java
浏览文件 @
5bfd1cd2
/*
/*
* Copyright (c) 2008, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2008, 201
4
, 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
...
@@ -139,6 +139,13 @@ public class SecretKeysBasic extends PKCS11Test {
...
@@ -139,6 +139,13 @@ public class SecretKeysBasic extends PKCS11Test {
}
}
private
static
void
doTest
()
throws
Exception
{
private
static
void
doTest
()
throws
Exception
{
// Make sure both NSS libraries are the same version.
if
(
isNSS
(
provider
)
&&
(
getLibsoftokn3Version
()
!=
getLibnss3Version
()))
{
System
.
out
.
println
(
"libsoftokn3 and libnss3 versions do not match. Aborting test..."
);
return
;
}
if
(
ks
==
null
)
{
if
(
ks
==
null
)
{
ks
=
KeyStore
.
getInstance
(
KS_TYPE
,
provider
);
ks
=
KeyStore
.
getInstance
(
KS_TYPE
,
provider
);
ks
.
load
(
null
,
tokenPwd
);
ks
.
load
(
null
,
tokenPwd
);
...
...
test/sun/security/pkcs11/PKCS11Test.java
浏览文件 @
5bfd1cd2
...
@@ -66,6 +66,11 @@ public abstract class PKCS11Test {
...
@@ -66,6 +66,11 @@ public abstract class PKCS11Test {
// The other is "libnss3.so", listed as "nss3".
// The other is "libnss3.so", listed as "nss3".
static
String
nss_library
=
"softokn3"
;
static
String
nss_library
=
"softokn3"
;
// NSS versions of each library. It is simplier to keep nss_version
// for quick checking for generic testing than many if-else statements.
static
double
softoken3_version
=
-
1
;
static
double
nss3_version
=
-
1
;
static
Provider
getSunPKCS11
(
String
config
)
throws
Exception
{
static
Provider
getSunPKCS11
(
String
config
)
throws
Exception
{
Class
clazz
=
Class
.
forName
(
"sun.security.pkcs11.SunPKCS11"
);
Class
clazz
=
Class
.
forName
(
"sun.security.pkcs11.SunPKCS11"
);
Constructor
cons
=
clazz
.
getConstructor
(
new
Class
[]
{
String
.
class
});
Constructor
cons
=
clazz
.
getConstructor
(
new
Class
[]
{
String
.
class
});
...
@@ -175,6 +180,10 @@ public abstract class PKCS11Test {
...
@@ -175,6 +180,10 @@ public abstract class PKCS11Test {
}
}
public
static
String
getNSSLibDir
()
throws
Exception
{
public
static
String
getNSSLibDir
()
throws
Exception
{
return
getNSSLibDir
(
nss_library
);
}
static
String
getNSSLibDir
(
String
library
)
throws
Exception
{
Properties
props
=
System
.
getProperties
();
Properties
props
=
System
.
getProperties
();
String
osName
=
props
.
getProperty
(
"os.name"
);
String
osName
=
props
.
getProperty
(
"os.name"
);
if
(
osName
.
startsWith
(
"Win"
))
{
if
(
osName
.
startsWith
(
"Win"
))
{
...
@@ -195,7 +204,7 @@ public abstract class PKCS11Test {
...
@@ -195,7 +204,7 @@ public abstract class PKCS11Test {
String
nssLibDir
=
null
;
String
nssLibDir
=
null
;
for
(
String
dir
:
nssLibDirs
)
{
for
(
String
dir
:
nssLibDirs
)
{
if
(
new
File
(
dir
).
exists
()
&&
if
(
new
File
(
dir
).
exists
()
&&
new
File
(
dir
+
System
.
mapLibraryName
(
nss_
library
)).
exists
())
{
new
File
(
dir
+
System
.
mapLibraryName
(
library
)).
exists
())
{
nssLibDir
=
dir
;
nssLibDir
=
dir
;
System
.
setProperty
(
"pkcs11test.nss.libdir"
,
nssLibDir
);
System
.
setProperty
(
"pkcs11test.nss.libdir"
,
nssLibDir
);
break
;
break
;
...
@@ -241,16 +250,37 @@ public abstract class PKCS11Test {
...
@@ -241,16 +250,37 @@ public abstract class PKCS11Test {
return
nss_ecc_status
;
return
nss_ecc_status
;
}
}
public
static
double
getLibsoftokn3Version
()
{
if
(
softoken3_version
==
-
1
)
return
getNSSInfo
(
"softokn3"
);
return
softoken3_version
;
}
public
static
double
getLibnss3Version
()
{
if
(
nss3_version
==
-
1
)
return
getNSSInfo
(
"nss3"
);
return
nss3_version
;
}
/* Read the library to find out the verison */
/* Read the library to find out the verison */
static
void
getNSSInfo
()
{
static
void
getNSSInfo
()
{
getNSSInfo
(
nss_library
);
}
static
double
getNSSInfo
(
String
library
)
{
String
nssHeader
=
"$Header: NSS"
;
String
nssHeader
=
"$Header: NSS"
;
boolean
found
=
false
;
boolean
found
=
false
;
String
s
=
null
;
String
s
=
null
;
int
i
=
0
;
int
i
=
0
;
String
libfile
=
""
;
String
libfile
=
""
;
if
(
library
.
compareTo
(
"softokn3"
)
==
0
&&
softoken3_version
>
-
1
)
return
softoken3_version
;
if
(
library
.
compareTo
(
"nss3"
)
==
0
&&
nss3_version
>
-
1
)
return
nss3_version
;
try
{
try
{
libfile
=
getNSSLibDir
()
+
System
.
mapLibraryName
(
nss_
library
);
libfile
=
getNSSLibDir
()
+
System
.
mapLibraryName
(
library
);
FileInputStream
is
=
new
FileInputStream
(
libfile
);
FileInputStream
is
=
new
FileInputStream
(
libfile
);
byte
[]
data
=
new
byte
[
1000
];
byte
[]
data
=
new
byte
[
1000
];
int
read
=
0
;
int
read
=
0
;
...
@@ -284,9 +314,10 @@ public abstract class PKCS11Test {
...
@@ -284,9 +314,10 @@ public abstract class PKCS11Test {
}
}
if
(!
found
)
{
if
(!
found
)
{
System
.
out
.
println
(
"NSS version not found, set to 0.0: "
+
libfile
);
System
.
out
.
println
(
"lib"
+
library
+
" version not found, set to 0.0: "
+
libfile
);
nss_version
=
0.0
;
nss_version
=
0.0
;
return
;
return
nss_version
;
}
}
// the index after whitespace after nssHeader
// the index after whitespace after nssHeader
...
@@ -306,11 +337,12 @@ public abstract class PKCS11Test {
...
@@ -306,11 +337,12 @@ public abstract class PKCS11Test {
try
{
try
{
nss_version
=
Double
.
parseDouble
(
version
);
nss_version
=
Double
.
parseDouble
(
version
);
}
catch
(
NumberFormatException
e
)
{
}
catch
(
NumberFormatException
e
)
{
System
.
out
.
println
(
"Failed to parse NSS version. Set to 0.0"
);
System
.
out
.
println
(
"Failed to parse lib"
+
library
+
" version. Set to 0.0"
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
System
.
out
.
print
(
"
NSS
version = "
+
version
+
". "
);
System
.
out
.
print
(
"
lib"
+
library
+
"
version = "
+
version
+
". "
);
// Check for ECC
// Check for ECC
if
(
s
.
indexOf
(
"Basic"
)
>
0
)
{
if
(
s
.
indexOf
(
"Basic"
)
>
0
)
{
...
@@ -319,7 +351,17 @@ public abstract class PKCS11Test {
...
@@ -319,7 +351,17 @@ public abstract class PKCS11Test {
}
else
if
(
s
.
indexOf
(
"Extended"
)
>
0
)
{
}
else
if
(
s
.
indexOf
(
"Extended"
)
>
0
)
{
nss_ecc_status
=
ECCState
.
Extended
;
nss_ecc_status
=
ECCState
.
Extended
;
System
.
out
.
println
(
"ECC Extended."
);
System
.
out
.
println
(
"ECC Extended."
);
}
else
{
System
.
out
.
println
(
"ECC None."
);
}
}
if
(
library
.
compareTo
(
"softokn3"
)
==
0
)
{
softoken3_version
=
nss_version
;
}
else
if
(
library
.
compareTo
(
"nss3"
)
==
0
)
{
nss3_version
=
nss_version
;
}
return
nss_version
;
}
}
// Used to set the nss_library file to search for libsoftokn3.so
// Used to set the nss_library file to search for libsoftokn3.so
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录