Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
2441b8c1
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看板
提交
2441b8c1
编写于
1月 11, 2020
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8186831: Kerberos ignores PA-DATA with a non-null s2kparams
Reviewed-by: xuelei
上级
85ccacb3
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
140 addition
and
15 deletion
+140
-15
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
+5
-7
src/share/classes/sun/security/krb5/internal/PAData.java
src/share/classes/sun/security/krb5/internal/PAData.java
+7
-5
src/share/classes/sun/security/krb5/internal/crypto/EType.java
...hare/classes/sun/security/krb5/internal/crypto/EType.java
+21
-1
test/sun/security/krb5/auto/DiffSaltParams.java
test/sun/security/krb5/auto/DiffSaltParams.java
+50
-0
test/sun/security/krb5/auto/KDC.java
test/sun/security/krb5/auto/KDC.java
+57
-2
未找到文件。
src/share/classes/sun/security/jgss/krb5/CipherHelper.java
浏览文件 @
2441b8c1
/*
* Copyright (c) 2004, 201
1
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2004, 201
7
, 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
...
...
@@ -44,6 +44,7 @@ import sun.security.krb5.internal.crypto.Des3;
import
sun.security.krb5.internal.crypto.Aes128
;
import
sun.security.krb5.internal.crypto.Aes256
;
import
sun.security.krb5.internal.crypto.ArcFourHmac
;
import
sun.security.krb5.internal.crypto.EType
;
class
CipherHelper
{
...
...
@@ -77,10 +78,6 @@ class CipherHelper {
private
int
sgnAlg
,
sealAlg
;
private
byte
[]
keybytes
;
// new token format from draft-ietf-krb-wg-gssapi-cfx-07
// proto is used to determine new GSS token format for "newer" etypes
private
int
proto
=
0
;
CipherHelper
(
EncryptionKey
key
)
throws
GSSException
{
etype
=
key
.
getEType
();
keybytes
=
key
.
getBytes
();
...
...
@@ -106,7 +103,6 @@ class CipherHelper {
case
EncryptedData
.
ETYPE_AES256_CTS_HMAC_SHA1_96
:
sgnAlg
=
-
1
;
sealAlg
=
-
1
;
proto
=
1
;
break
;
default
:
...
...
@@ -123,8 +119,10 @@ class CipherHelper {
return
sealAlg
;
}
// new token format from draft-ietf-krb-wg-gssapi-cfx-07
// proto is used to determine new GSS token format for "newer" etypes
int
getProto
()
{
return
proto
;
return
EType
.
isNewer
(
etype
)
?
1
:
0
;
}
int
getEType
()
{
...
...
src/share/classes/sun/security/krb5/internal/PAData.java
浏览文件 @
2441b8c1
/*
* Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2017, 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
...
...
@@ -31,7 +32,7 @@
package
sun.security.krb5.internal
;
import
sun.security.krb5.
KrbException
;
import
sun.security.krb5.
internal.crypto.EType
;
import
sun.security.util.*
;
import
sun.security.krb5.Asn1Exception
;
import
java.io.IOException
;
...
...
@@ -207,8 +208,8 @@ public class PAData {
while
(
d2
.
data
.
available
()
>
0
)
{
DerValue
value
=
d2
.
data
.
getDerValue
();
ETypeInfo2
tmp
=
new
ETypeInfo2
(
value
);
if
(
tmp
.
getParams
()
==
null
)
{
// we don't support non-null s2kparams
if
(
EType
.
isNewer
(
tmp
.
getEType
())
||
tmp
.
getParams
()
==
null
)
{
// we don't support non-null s2kparams
for old etypes
return
tmp
.
getEType
();
}
}
...
...
@@ -274,8 +275,9 @@ public class PAData {
while
(
d2
.
data
.
available
()
>
0
)
{
DerValue
value
=
d2
.
data
.
getDerValue
();
ETypeInfo2
tmp
=
new
ETypeInfo2
(
value
);
if
(
tmp
.
getParams
()
==
null
&&
tmp
.
getEType
()
==
eType
)
{
// we don't support non-null s2kparams
if
(
tmp
.
getEType
()
==
eType
&&
(
EType
.
isNewer
(
eType
)
||
tmp
.
getParams
()
==
null
))
{
// we don't support non-null s2kparams for old etypes
return
new
SaltAndParams
(
tmp
.
getSalt
(),
tmp
.
getParams
());
}
}
...
...
src/share/classes/sun/security/krb5/internal/crypto/EType.java
浏览文件 @
2441b8c1
/*
* Copyright (c) 2000, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 201
7
, 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
...
...
@@ -301,6 +301,26 @@ public abstract class EType {
return
isSupported
(
eTypeConst
,
enabledETypes
);
}
/**
* https://tools.ietf.org/html/rfc4120#section-3.1.3:
*
* A "newer" enctype is any enctype first officially
* specified concurrently with or subsequent to the issue of this RFC.
* The enctypes DES, 3DES, or RC4 and any defined in [RFC1510] are not
* "newer" enctypes.
*
* @param eTypeConst the encryption type
* @return true if "newer"
*/
public
static
boolean
isNewer
(
int
eTypeConst
)
{
return
eTypeConst
!=
EncryptedData
.
ETYPE_DES_CBC_CRC
&&
eTypeConst
!=
EncryptedData
.
ETYPE_DES_CBC_MD4
&&
eTypeConst
!=
EncryptedData
.
ETYPE_DES_CBC_MD5
&&
eTypeConst
!=
EncryptedData
.
ETYPE_DES3_CBC_HMAC_SHA1_KD
&&
eTypeConst
!=
EncryptedData
.
ETYPE_ARCFOUR_HMAC
&&
eTypeConst
!=
EncryptedData
.
ETYPE_ARCFOUR_HMAC_EXP
;
}
public
static
String
toString
(
int
type
)
{
switch
(
type
)
{
case
0
:
...
...
test/sun/security/krb5/auto/DiffSaltParams.java
0 → 100644
浏览文件 @
2441b8c1
/*
* Copyright (c) 2017, 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 8186831
* @summary Kerberos ignores PA-DATA with a non-null s2kparams
* @compile -XDignore.symbol.file DiffSaltParams.java
* @run main/othervm -Dsun.security.krb5.debug=true -Dsun.net.spi.nameservice.provider.1=ns,mock DiffSaltParams
*/
public
class
DiffSaltParams
{
public
static
void
main
(
String
[]
args
)
throws
Exception
{
OneKDC
kdc
=
new
OneKDC
(
null
).
writeJAASConf
();
kdc
.
addPrincipal
(
"user1"
,
"user1pass"
.
toCharArray
(),
"hello"
,
new
byte
[]{
0
,
0
,
1
,
0
});
kdc
.
addPrincipal
(
"user2"
,
"user2pass"
.
toCharArray
(),
"hello"
,
null
);
kdc
.
addPrincipal
(
"user3"
,
"user3pass"
.
toCharArray
(),
null
,
new
byte
[]{
0
,
0
,
1
,
0
});
kdc
.
addPrincipal
(
"user4"
,
"user4pass"
.
toCharArray
());
Context
.
fromUserPass
(
"user1"
,
"user1pass"
.
toCharArray
(),
true
);
Context
.
fromUserPass
(
"user2"
,
"user2pass"
.
toCharArray
(),
true
);
Context
.
fromUserPass
(
"user3"
,
"user3pass"
.
toCharArray
(),
true
);
Context
.
fromUserPass
(
"user4"
,
"user4pass"
.
toCharArray
(),
true
);
}
}
test/sun/security/krb5/auto/KDC.java
浏览文件 @
2441b8c1
...
...
@@ -149,6 +149,17 @@ public class KDC {
private
TreeMap
<
String
,
PrincipalName
>
alias2Principals
=
new
TreeMap
<>
(
String
.
CASE_INSENSITIVE_ORDER
);
// Non default salts. Precisely, there should be different salts for
// different etypes, pretend they are the same at the moment.
private
TreeMap
<
String
,
String
>
salts
=
new
TreeMap
<>
(
String
.
CASE_INSENSITIVE_ORDER
);
// Non default s2kparams for newer etypes. Precisely, there should be
// different s2kparams for different etypes, pretend they are the same
// at the moment.
private
TreeMap
<
String
,
byte
[]>
s2kparamses
=
new
TreeMap
<>
(
String
.
CASE_INSENSITIVE_ORDER
);
// Realm name
private
String
realm
;
// KDC
...
...
@@ -370,10 +381,28 @@ public class KDC {
* @param pass the password for the principal
*/
public
void
addPrincipal
(
String
user
,
char
[]
pass
)
{
addPrincipal
(
user
,
pass
,
null
,
null
);
}
/**
* Adds a new principal to this realm with a given password.
* @param user the principal's name. For a service principal, use the
* form of host/f.q.d.n
* @param pass the password for the principal
* @param salt the salt, or null if a default value will be used
* @param s2kparams the s2kparams, or null if a default value will be used
*/
public
void
addPrincipal
(
String
user
,
char
[]
pass
,
String
salt
,
byte
[]
s2kparams
)
{
if
(
user
.
indexOf
(
'@'
)
<
0
)
{
user
=
user
+
"@"
+
realm
;
}
passwords
.
put
(
user
,
pass
);
if
(
salt
!=
null
)
{
salts
.
put
(
user
,
salt
);
}
if
(
s2kparams
!=
null
)
{
s2kparamses
.
put
(
user
,
s2kparams
);
}
}
/**
...
...
@@ -611,6 +640,9 @@ public class KDC {
if
(
p
.
getRealmString
()
==
null
)
{
pn
=
pn
+
"@"
+
getRealm
();
}
if
(
salts
.
containsKey
(
pn
))
{
return
salts
.
get
(
pn
);
}
if
(
passwords
.
containsKey
(
pn
))
{
try
{
// Find the principal name with correct case.
...
...
@@ -627,6 +659,29 @@ public class KDC {
return
s
;
}
/**
* Returns the s2kparams for the principal given the etype.
* @param p principal
* @param etype encryption type
* @return the s2kparams, might be null
*/
protected
byte
[]
getParams
(
PrincipalName
p
,
int
etype
)
{
switch
(
etype
)
{
case
EncryptedData
.
ETYPE_AES128_CTS_HMAC_SHA1_96
:
case
EncryptedData
.
ETYPE_AES256_CTS_HMAC_SHA1_96
:
String
pn
=
p
.
toString
();
if
(
p
.
getRealmString
()
==
null
)
{
pn
=
pn
+
"@"
+
getRealm
();
}
if
(
s2kparamses
.
containsKey
(
pn
))
{
return
s2kparamses
.
get
(
pn
);
}
return
new
byte
[]
{
0
,
0
,
0x10
,
0
};
default
:
return
null
;
}
}
/**
* Returns the key for a given principal of the given encryption type
* @param p the principal
...
...
@@ -650,7 +705,7 @@ public class KDC {
}
}
return
new
EncryptionKey
(
EncryptionKeyDotStringToKey
(
getPassword
(
p
,
server
),
getSalt
(
p
),
null
,
etype
),
getPassword
(
p
,
server
),
getSalt
(
p
),
getParams
(
p
,
etype
)
,
etype
),
etype
,
kvno
);
}
catch
(
KrbException
ke
)
{
throw
ke
;
...
...
@@ -1116,7 +1171,7 @@ public class KDC {
epas
[
i
],
epas
[
i
]
==
EncryptedData
.
ETYPE_ARCFOUR_HMAC
?
null
:
getSalt
(
body
.
cname
),
null
).
asn1Encode
());
getParams
(
body
.
cname
,
epas
[
i
])
).
asn1Encode
());
}
boolean
allOld
=
true
;
for
(
int
i:
eTypes
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录