Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
f1e27b5f
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看板
提交
f1e27b5f
编写于
12月 07, 2009
作者:
W
weijun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
6879540: enable empty password for kerberos 5
Reviewed-by: valeriep, wetmore
上级
d9038e38
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
34 addition
and
9 deletion
+34
-9
src/share/classes/com/sun/crypto/provider/HmacCore.java
src/share/classes/com/sun/crypto/provider/HmacCore.java
+2
-2
src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
+32
-7
未找到文件。
src/share/classes/com/sun/crypto/provider/HmacCore.java
浏览文件 @
f1e27b5f
...
...
@@ -36,7 +36,7 @@ import java.security.spec.*;
/**
* This class constitutes the core of HMAC-<MD> algorithms, where
* <MD> can be SHA1 or MD5, etc.
* <MD> can be SHA1 or MD5, etc.
See RFC 2104 for spec.
*
* It also contains the implementation classes for the SHA-256,
* SHA-384, and SHA-512 HMACs.
...
...
@@ -116,7 +116,7 @@ final class HmacCore implements Cloneable {
}
byte
[]
secret
=
key
.
getEncoded
();
if
(
secret
==
null
||
secret
.
length
==
0
)
{
if
(
secret
==
null
)
{
throw
new
InvalidKeyException
(
"Missing key data"
);
}
...
...
src/share/classes/com/sun/crypto/provider/PBKDF2KeyImpl.java
浏览文件 @
f1e27b5f
/*
* Copyright 2005-200
8
Sun Microsystems, Inc. All Rights Reserved.
* Copyright 2005-200
9
Sun Microsystems, Inc. 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
...
...
@@ -25,21 +25,19 @@
package
com.sun.crypto.provider
;
import
java.io.
*
;
import
java.io.
ObjectStreamException
;
import
java.nio.ByteBuffer
;
import
java.nio.CharBuffer
;
import
java.nio.charset.Charset
;
import
java.util.Arrays
;
import
java.security.KeyRep
;
import
java.security.GeneralSecurityException
;
import
java.security.InvalidKeyException
;
import
java.security.NoSuchAlgorithmException
;
import
java.security.NoSuchProviderException
;
import
java.security.spec.InvalidKeySpecException
;
import
javax.crypto.Mac
;
import
javax.crypto.SecretKey
;
import
javax.crypto.spec.PBEKeySpec
;
import
javax.crypto.spec.SecretKeySpec
;
/**
* This class represents a PBE key derived using PBKDF2 defined
...
...
@@ -123,7 +121,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
this
.
key
=
deriveKey
(
prf
,
passwdBytes
,
salt
,
iterCount
,
keyLength
);
}
private
static
byte
[]
deriveKey
(
Mac
prf
,
byte
[]
password
,
byte
[]
salt
,
private
static
byte
[]
deriveKey
(
final
Mac
prf
,
final
byte
[]
password
,
byte
[]
salt
,
int
iterCount
,
int
keyLengthInBit
)
{
int
keyLength
=
keyLengthInBit
/
8
;
byte
[]
key
=
new
byte
[
keyLength
];
...
...
@@ -133,7 +131,34 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
int
intR
=
keyLength
-
(
intL
-
1
)*
hlen
;
// residue
byte
[]
ui
=
new
byte
[
hlen
];
byte
[]
ti
=
new
byte
[
hlen
];
SecretKey
macKey
=
new
SecretKeySpec
(
password
,
prf
.
getAlgorithm
());
// SecretKeySpec cannot be used, since password can be empty here.
SecretKey
macKey
=
new
SecretKey
()
{
@Override
public
String
getAlgorithm
()
{
return
prf
.
getAlgorithm
();
}
@Override
public
String
getFormat
()
{
return
"RAW"
;
}
@Override
public
byte
[]
getEncoded
()
{
return
password
;
}
@Override
public
int
hashCode
()
{
return
Arrays
.
hashCode
(
password
)
*
41
+
prf
.
getAlgorithm
().
toLowerCase
().
hashCode
();
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
this
.
getClass
()
!=
obj
.
getClass
())
return
false
;
SecretKey
sk
=
(
SecretKey
)
obj
;
return
prf
.
getAlgorithm
().
equalsIgnoreCase
(
sk
.
getAlgorithm
())
&&
Arrays
.
equals
(
password
,
sk
.
getEncoded
());
}
};
prf
.
init
(
macKey
);
byte
[]
ibytes
=
new
byte
[
4
];
...
...
@@ -230,7 +255,7 @@ final class PBKDF2KeyImpl implements javax.crypto.interfaces.PBEKey {
* @throws ObjectStreamException if a new object representing
* this PBE key could not be created
*/
private
Object
writeReplace
()
throws
java
.
io
.
ObjectStreamException
{
private
Object
writeReplace
()
throws
ObjectStreamException
{
return
new
KeyRep
(
KeyRep
.
Type
.
SECRET
,
getAlgorithm
(),
getFormat
(),
getEncoded
());
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录