Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
9ce1e8c8
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看板
提交
9ce1e8c8
编写于
6月 24, 2010
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6844907: krb5 etype order should be from strong to weak
Reviewed-by: valeriep
上级
242bd913
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
70 addition
and
104 deletion
+70
-104
src/share/classes/sun/security/krb5/Credentials.java
src/share/classes/sun/security/krb5/Credentials.java
+1
-56
src/share/classes/sun/security/krb5/internal/crypto/EType.java
...hare/classes/sun/security/krb5/internal/crypto/EType.java
+11
-11
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
...share/classes/sun/security/krb5/internal/ktab/KeyTab.java
+5
-33
test/sun/security/krb5/etype/ETypeOrder.java
test/sun/security/krb5/etype/ETypeOrder.java
+52
-0
test/sun/security/krb5/ktab/HighestKvno.java
test/sun/security/krb5/ktab/HighestKvno.java
+1
-4
未找到文件。
src/share/classes/sun/security/krb5/Credentials.java
浏览文件 @
9ce1e8c8
/*
* Copyright (c) 2000, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
10
, 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
...
...
@@ -33,9 +33,7 @@ package sun.security.krb5;
import
sun.security.krb5.internal.*
;
import
sun.security.krb5.internal.ccache.CredentialsCache
;
import
sun.security.krb5.internal.ktab.*
;
import
sun.security.krb5.internal.crypto.EType
;
import
java.io.File
;
import
java.io.IOException
;
import
java.util.Date
;
import
java.net.InetAddress
;
...
...
@@ -506,59 +504,6 @@ public class Credentials {
return
result
;
}
/**
* Gets service credential from key table. The credential is used to
* decrypt the received client message
* and authenticate the client by verifying the client's credential.
*
* @param serviceName the name of service, using format component@realm
* @param keyTabFile the file of key table.
* @return a <code>KrbCreds</code> object.
*/
public
static
Credentials
getServiceCreds
(
String
serviceName
,
File
keyTabFile
)
{
EncryptionKey
k
=
null
;
PrincipalName
service
=
null
;
Credentials
result
=
null
;
try
{
service
=
new
PrincipalName
(
serviceName
);
if
(
service
.
getRealm
()
==
null
)
{
String
realm
=
Config
.
getInstance
().
getDefaultRealm
();
if
(
realm
==
null
)
{
return
null
;
}
else
{
service
.
setRealm
(
realm
);
}
}
}
catch
(
RealmException
e
)
{
if
(
DEBUG
)
{
e
.
printStackTrace
();
}
return
null
;
}
catch
(
KrbException
e
)
{
if
(
DEBUG
)
{
e
.
printStackTrace
();
}
return
null
;
}
KeyTab
kt
;
if
(
keyTabFile
==
null
)
{
kt
=
KeyTab
.
getInstance
();
}
else
{
kt
=
KeyTab
.
getInstance
(
keyTabFile
);
}
if
((
kt
!=
null
)
&&
(
kt
.
findServiceEntry
(
service
)))
{
k
=
kt
.
readServiceKey
(
service
);
result
=
new
Credentials
(
null
,
service
,
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
);
result
.
serviceKey
=
k
;
}
return
result
;
}
/**
* Acquires credentials for a specified service using initial credential.
* When the service has a different realm
...
...
src/share/classes/sun/security/krb5/internal/crypto/EType.java
浏览文件 @
9ce1e8c8
...
...
@@ -185,20 +185,20 @@ public abstract class EType {
// is set to false.
private
static
final
int
[]
BUILTIN_ETYPES
=
new
int
[]
{
EncryptedData
.
ETYPE_DES_CBC_MD5
,
EncryptedData
.
ETYPE_DES_CBC_CRC
,
EncryptedData
.
ETYPE_ARCFOUR_HMAC
,
EncryptedData
.
ETYPE_DES3_CBC_HMAC_SHA1_KD
,
EncryptedData
.
ETYPE_AES128_CTS_HMAC_SHA1_96
,
EncryptedData
.
ETYPE_AES256_CTS_HMAC_SHA1_96
,
EncryptedData
.
ETYPE_AES128_CTS_HMAC_SHA1_96
,
EncryptedData
.
ETYPE_DES3_CBC_HMAC_SHA1_KD
,
EncryptedData
.
ETYPE_ARCFOUR_HMAC
,
EncryptedData
.
ETYPE_DES_CBC_CRC
,
EncryptedData
.
ETYPE_DES_CBC_MD5
,
};
private
static
final
int
[]
BUILTIN_ETYPES_NOAES256
=
new
int
[]
{
EncryptedData
.
ETYPE_DES_CBC_MD5
,
EncryptedData
.
ETYPE_DES_CBC_CRC
,
EncryptedData
.
ETYPE_ARCFOUR_HMAC
,
EncryptedData
.
ETYPE_DES3_CBC_HMAC_SHA1_KD
,
EncryptedData
.
ETYPE_AES128_CTS_HMAC_SHA1_96
,
EncryptedData
.
ETYPE_DES3_CBC_HMAC_SHA1_KD
,
EncryptedData
.
ETYPE_ARCFOUR_HMAC
,
EncryptedData
.
ETYPE_DES_CBC_CRC
,
EncryptedData
.
ETYPE_DES_CBC_MD5
,
};
...
...
@@ -217,8 +217,8 @@ public abstract class EType {
result
=
BUILTIN_ETYPES
;
}
if
(!
ALLOW_WEAK_CRYPTO
)
{
// The
fir
st 2 etypes are now weak ones
return
Arrays
.
copyOfRange
(
result
,
2
,
result
.
length
);
// The
la
st 2 etypes are now weak ones
return
Arrays
.
copyOfRange
(
result
,
0
,
result
.
length
-
2
);
}
return
result
;
}
...
...
src/share/classes/sun/security/krb5/internal/ktab/KeyTab.java
浏览文件 @
9ce1e8c8
/*
* Copyright (c) 2000, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 20
10
, 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
...
...
@@ -227,37 +227,6 @@ public class KeyTab implements KeyTabConstants {
}
}
/**
* Reads the service key from the keytab file.
* @param service the PrincipalName of the requested service.
* @return the last service key in the keytab with the highest kvno
*/
public
EncryptionKey
readServiceKey
(
PrincipalName
service
)
{
KeyTabEntry
entry
=
null
;
EncryptionKey
key
=
null
;
if
(
entries
!=
null
)
{
// Find latest entry for this service that has an etype
// that has been configured for use
for
(
int
i
=
entries
.
size
()-
1
;
i
>=
0
;
i
--)
{
entry
=
entries
.
elementAt
(
i
);
if
(
entry
.
service
.
match
(
service
))
{
if
(
EType
.
isSupported
(
entry
.
keyType
))
{
if
(
key
==
null
||
entry
.
keyVersion
>
key
.
getKeyVersionNumber
())
{
key
=
new
EncryptionKey
(
entry
.
keyblock
,
entry
.
keyType
,
new
Integer
(
entry
.
keyVersion
));
}
}
else
if
(
DEBUG
)
{
System
.
out
.
println
(
"Found unsupported keytype ("
+
entry
.
keyType
+
") for "
+
service
);
}
}
}
}
return
key
;
}
/**
* Reads all keys for a service from the keytab file that have
* etypes that have been configured for use. If there are multiple
...
...
@@ -309,7 +278,7 @@ public class KeyTab implements KeyTabConstants {
Arrays
.
sort
(
retVal
,
new
Comparator
<
EncryptionKey
>()
{
@Override
public
int
compare
(
EncryptionKey
o1
,
EncryptionKey
o2
)
{
if
(
etypes
!=
null
&&
etypes
!=
EType
.
getBuiltInDefaults
()
)
{
if
(
etypes
!=
null
)
{
int
o1EType
=
o1
.
getEType
();
int
o2EType
=
o2
.
getEType
();
if
(
o1EType
!=
o2EType
)
{
...
...
@@ -320,6 +289,9 @@ public class KeyTab implements KeyTabConstants {
return
1
;
}
}
// Neither o1EType nor o2EType in default_tkt_enctypes,
// therefore won't be used in AS-REQ. We do not care
// about their order, use kvno is OK.
}
}
return
o2
.
getKeyVersionNumber
().
intValue
()
...
...
test/sun/security/krb5/etype/ETypeOrder.java
0 → 100644
浏览文件 @
9ce1e8c8
/*
* Copyright (c) 2010, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6844907
* @summary krb5 etype order should be from strong to weak
*/
import
sun.security.krb5.internal.crypto.EType
;
public
class
ETypeOrder
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
// File does not exist, so that the system-default one won't be used
System
.
setProperty
(
"java.security.krb5.conf"
,
"no_such_file"
);
int
[]
etypes
=
EType
.
getBuiltInDefaults
();
// Reference order, note that 2 is not implemented in Java
int
correct
[]
=
{
18
,
17
,
16
,
23
,
1
,
3
,
2
};
int
match
=
0
;
loopi:
for
(
int
i
=
0
;
i
<
etypes
.
length
;
i
++)
{
for
(;
match
<
correct
.
length
;
match
++)
{
if
(
etypes
[
i
]
==
correct
[
match
])
{
System
.
out
.
println
(
"Find "
+
etypes
[
i
]
+
" at #"
+
match
);
continue
loopi
;
}
}
throw
new
Exception
(
"No match or bad order for "
+
etypes
[
i
]);
}
}
}
test/sun/security/krb5/ktab/HighestKvno.java
浏览文件 @
9ce1e8c8
/*
* Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2009,
2010,
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
...
...
@@ -227,9 +227,6 @@ public class HighestKvno {
if
(
keys
[
0
].
getKeyVersionNumber
()
!=
5
)
{
throw
new
Exception
(
"Highest not first"
);
}
if
(
ktab
.
readServiceKey
(
pn
).
getKeyVersionNumber
()
!=
5
)
{
throw
new
Exception
(
"Highest not chosen"
);
}
new
File
(
"kt"
).
delete
();
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录