Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openanolis
dragonwell8_jdk
提交
46f365dd
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看板
提交
46f365dd
编写于
3月 23, 2017
作者:
I
igerasim
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
8171252: Improve exception checking
8158517: Minor optimizations to ISO10126PADDING Reviewed-by: ascarpino, mschoene
上级
088a356d
变更
10
展开全部
隐藏空白更改
内联
并排
Showing
10 changed file
with
60 addition
and
592 deletion
+60
-592
src/share/classes/com/sun/crypto/provider/AESCipher.java
src/share/classes/com/sun/crypto/provider/AESCipher.java
+5
-5
src/share/classes/com/sun/crypto/provider/AESWrapCipher.java
src/share/classes/com/sun/crypto/provider/AESWrapCipher.java
+4
-4
src/share/classes/com/sun/crypto/provider/ARCFOURCipher.java
src/share/classes/com/sun/crypto/provider/ARCFOURCipher.java
+2
-2
src/share/classes/com/sun/crypto/provider/BlowfishCipher.java
...share/classes/com/sun/crypto/provider/BlowfishCipher.java
+2
-2
src/share/classes/com/sun/crypto/provider/CipherCore.java
src/share/classes/com/sun/crypto/provider/CipherCore.java
+22
-20
src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java
...are/classes/com/sun/crypto/provider/DESedeWrapCipher.java
+4
-4
src/share/classes/com/sun/crypto/provider/ISO10126Padding.java
...hare/classes/com/sun/crypto/provider/ISO10126Padding.java
+9
-7
src/share/classes/com/sun/crypto/provider/PBECipherCore.java
src/share/classes/com/sun/crypto/provider/PBECipherCore.java
+0
-535
src/share/classes/com/sun/crypto/provider/PBES1Core.java
src/share/classes/com/sun/crypto/provider/PBES1Core.java
+2
-2
src/share/classes/com/sun/crypto/provider/PKCS5Padding.java
src/share/classes/com/sun/crypto/provider/PKCS5Padding.java
+10
-11
未找到文件。
src/share/classes/com/sun/crypto/provider/AESCipher.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2002, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
7
, 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
...
@@ -156,7 +156,7 @@ abstract class AESCipher extends CipherSpi {
...
@@ -156,7 +156,7 @@ abstract class AESCipher extends CipherSpi {
throw
new
InvalidKeyException
(
"Key encoding must not be null"
);
throw
new
InvalidKeyException
(
"Key encoding must not be null"
);
}
else
if
(
value
.
length
!=
fixedKeySize
)
{
}
else
if
(
value
.
length
!=
fixedKeySize
)
{
throw
new
InvalidKeyException
(
"The key must be "
+
throw
new
InvalidKeyException
(
"The key must be "
+
fixedKeySize
*
8
+
" bit
s"
);
fixedKeySize
+
" byte
s"
);
}
}
}
}
}
}
...
@@ -509,7 +509,7 @@ abstract class AESCipher extends CipherSpi {
...
@@ -509,7 +509,7 @@ abstract class AESCipher extends CipherSpi {
throw
new
InvalidKeyException
(
"Invalid AES key length: "
+
throw
new
InvalidKeyException
(
"Invalid AES key length: "
+
encoded
.
length
+
" bytes"
);
encoded
.
length
+
" bytes"
);
}
}
return
encoded
.
length
*
8
;
return
Math
.
multiplyExact
(
encoded
.
length
,
8
)
;
}
}
/**
/**
...
@@ -628,9 +628,9 @@ abstract class AESCipher extends CipherSpi {
...
@@ -628,9 +628,9 @@ abstract class AESCipher extends CipherSpi {
}
}
if
(
src
!=
null
)
{
if
(
src
!=
null
)
{
int
aadLen
=
src
.
limit
()
-
src
.
position
();
int
aadLen
=
src
.
limit
()
-
src
.
position
();
if
(
aadLen
!=
0
)
{
if
(
aadLen
>
0
)
{
if
(
src
.
hasArray
())
{
if
(
src
.
hasArray
())
{
int
aadOfs
=
src
.
arrayOffset
()
+
src
.
position
(
);
int
aadOfs
=
Math
.
addExact
(
src
.
arrayOffset
(),
src
.
position
()
);
core
.
updateAAD
(
src
.
array
(),
aadOfs
,
aadLen
);
core
.
updateAAD
(
src
.
array
(),
aadOfs
,
aadLen
);
src
.
position
(
src
.
limit
());
src
.
position
(
src
.
limit
());
}
else
{
}
else
{
...
...
src/share/classes/com/sun/crypto/provider/AESWrapCipher.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2004, 201
2
, 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.
* 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
...
@@ -156,7 +156,7 @@ abstract class AESWrapCipher extends CipherSpi {
...
@@ -156,7 +156,7 @@ abstract class AESWrapCipher extends CipherSpi {
if
(
decrypting
)
{
if
(
decrypting
)
{
result
=
inputLen
-
8
;
result
=
inputLen
-
8
;
}
else
{
}
else
{
result
=
inputLen
+
8
;
result
=
Math
.
addExact
(
inputLen
,
8
)
;
}
}
return
(
result
<
0
?
0
:
result
);
return
(
result
<
0
?
0
:
result
);
}
}
...
@@ -378,7 +378,7 @@ abstract class AESWrapCipher extends CipherSpi {
...
@@ -378,7 +378,7 @@ abstract class AESWrapCipher extends CipherSpi {
throw
new
InvalidKeyException
(
"Invalid key length: "
+
throw
new
InvalidKeyException
(
"Invalid key length: "
+
encoded
.
length
+
" bytes"
);
encoded
.
length
+
" bytes"
);
}
}
return
encoded
.
length
*
8
;
return
Math
.
multiplyExact
(
encoded
.
length
,
8
)
;
}
}
/**
/**
...
@@ -404,7 +404,7 @@ abstract class AESWrapCipher extends CipherSpi {
...
@@ -404,7 +404,7 @@ abstract class AESWrapCipher extends CipherSpi {
throw
new
InvalidKeyException
(
"Cannot get an encoding of "
+
throw
new
InvalidKeyException
(
"Cannot get an encoding of "
+
"the key to be wrapped"
);
"the key to be wrapped"
);
}
}
byte
[]
out
=
new
byte
[
keyVal
.
length
+
8
];
byte
[]
out
=
new
byte
[
Math
.
addExact
(
keyVal
.
length
,
8
)
];
if
(
keyVal
.
length
==
8
)
{
if
(
keyVal
.
length
==
8
)
{
System
.
arraycopy
(
IV
,
0
,
out
,
0
,
IV
.
length
);
System
.
arraycopy
(
IV
,
0
,
out
,
0
,
IV
.
length
);
...
...
src/share/classes/com/sun/crypto/provider/ARCFOURCipher.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2003, 201
0
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
7
, 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
...
@@ -257,7 +257,7 @@ public final class ARCFOURCipher extends CipherSpi {
...
@@ -257,7 +257,7 @@ public final class ARCFOURCipher extends CipherSpi {
// see JCE spec
// see JCE spec
protected
int
engineGetKeySize
(
Key
key
)
throws
InvalidKeyException
{
protected
int
engineGetKeySize
(
Key
key
)
throws
InvalidKeyException
{
byte
[]
encodedKey
=
getEncodedKey
(
key
);
byte
[]
encodedKey
=
getEncodedKey
(
key
);
return
encodedKey
.
length
<<
3
;
return
Math
.
multiplyExact
(
encodedKey
.
length
,
8
)
;
}
}
}
}
src/share/classes/com/sun/crypto/provider/BlowfishCipher.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 1998, 20
09
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 20
17
, 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
...
@@ -373,7 +373,7 @@ public final class BlowfishCipher extends CipherSpi {
...
@@ -373,7 +373,7 @@ public final class BlowfishCipher extends CipherSpi {
* @exception InvalidKeyException if <code>key</code> is invalid.
* @exception InvalidKeyException if <code>key</code> is invalid.
*/
*/
protected
int
engineGetKeySize
(
Key
key
)
throws
InvalidKeyException
{
protected
int
engineGetKeySize
(
Key
key
)
throws
InvalidKeyException
{
return
(
key
.
getEncoded
().
length
*
8
);
return
Math
.
multiplyExact
(
key
.
getEncoded
().
length
,
8
);
}
}
/**
/**
...
...
src/share/classes/com/sun/crypto/provider/CipherCore.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2002, 201
6
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
7
, 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
...
@@ -324,13 +324,14 @@ final class CipherCore {
...
@@ -324,13 +324,14 @@ final class CipherCore {
}
}
private
int
getOutputSizeByOperation
(
int
inputLen
,
boolean
isDoFinal
)
{
private
int
getOutputSizeByOperation
(
int
inputLen
,
boolean
isDoFinal
)
{
int
totalLen
=
buffered
+
inputLen
+
cipher
.
getBufferedLength
();
int
totalLen
=
Math
.
addExact
(
buffered
,
cipher
.
getBufferedLength
());
totalLen
=
Math
.
addExact
(
totalLen
,
inputLen
);
switch
(
cipherMode
)
{
switch
(
cipherMode
)
{
case
GCM_MODE:
case
GCM_MODE:
if
(
isDoFinal
)
{
if
(
isDoFinal
)
{
int
tagLen
=
((
GaloisCounterMode
)
cipher
).
getTagLen
();
int
tagLen
=
((
GaloisCounterMode
)
cipher
).
getTagLen
();
if
(!
decrypting
)
{
if
(!
decrypting
)
{
totalLen
+=
tagLen
;
totalLen
=
Math
.
addExact
(
totalLen
,
tagLen
)
;
}
else
{
}
else
{
totalLen
-=
tagLen
;
totalLen
-=
tagLen
;
}
}
...
@@ -346,10 +347,10 @@ final class CipherCore {
...
@@ -346,10 +347,10 @@ final class CipherCore {
totalLen
=
diffBlocksize
;
totalLen
=
diffBlocksize
;
}
else
{
}
else
{
int
residue
=
(
totalLen
-
diffBlocksize
)
%
blockSize
;
int
residue
=
(
totalLen
-
diffBlocksize
)
%
blockSize
;
totalLen
+=
(
blockSize
-
residue
);
totalLen
=
Math
.
addExact
(
totalLen
,
(
blockSize
-
residue
)
);
}
}
}
else
{
}
else
{
totalLen
+=
padding
.
padLength
(
totalLen
);
totalLen
=
Math
.
addExact
(
totalLen
,
padding
.
padLength
(
totalLen
)
);
}
}
}
}
break
;
break
;
...
@@ -711,7 +712,8 @@ final class CipherCore {
...
@@ -711,7 +712,8 @@ final class CipherCore {
}
}
// figure out how much can be sent to crypto function
// figure out how much can be sent to crypto function
int
len
=
buffered
+
inputLen
-
minBytes
;
int
len
=
Math
.
addExact
(
buffered
,
inputLen
);
len
-=
minBytes
;
if
(
padding
!=
null
&&
decrypting
)
{
if
(
padding
!=
null
&&
decrypting
)
{
// do not include the padding bytes when decrypting
// do not include the padding bytes when decrypting
len
-=
blockSize
;
len
-=
blockSize
;
...
@@ -730,12 +732,12 @@ final class CipherCore {
...
@@ -730,12 +732,12 @@ final class CipherCore {
int
outLen
=
0
;
int
outLen
=
0
;
if
(
len
!=
0
)
{
// there is some work to do
if
(
len
!=
0
)
{
// there is some work to do
if
((
input
==
output
)
if
((
input
==
output
)
&&
(
outputOffset
<
(
inputOffset
+
inputLen
)
)
&&
(
outputOffset
-
inputOffset
<
inputLen
)
&&
(
inputOffset
<
(
outputOffset
+
buffer
.
length
)
))
{
&&
(
inputOffset
-
outputOffset
<
buffer
.
length
))
{
// copy 'input' out to avoid its content being
// copy 'input' out to avoid its content being
// overwritten prematurely.
// overwritten prematurely.
input
=
Arrays
.
copyOfRange
(
input
,
inputOffset
,
input
=
Arrays
.
copyOfRange
(
input
,
inputOffset
,
inputOffset
+
inputLen
);
Math
.
addExact
(
inputOffset
,
inputLen
)
);
inputOffset
=
0
;
inputOffset
=
0
;
}
}
if
(
len
<=
buffered
)
{
if
(
len
<=
buffered
)
{
...
@@ -757,13 +759,13 @@ final class CipherCore {
...
@@ -757,13 +759,13 @@ final class CipherCore {
if
(
bufferCapacity
!=
0
)
{
if
(
bufferCapacity
!=
0
)
{
temp
=
Math
.
min
(
bufferCapacity
,
inputConsumed
);
temp
=
Math
.
min
(
bufferCapacity
,
inputConsumed
);
if
(
unitBytes
!=
blockSize
)
{
if
(
unitBytes
!=
blockSize
)
{
temp
-=
(
(
buffered
+
temp
)
%
unitBytes
);
temp
-=
(
Math
.
addExact
(
buffered
,
temp
)
%
unitBytes
);
}
}
System
.
arraycopy
(
input
,
inputOffset
,
buffer
,
buffered
,
temp
);
System
.
arraycopy
(
input
,
inputOffset
,
buffer
,
buffered
,
temp
);
inputOffset
+=
temp
;
inputOffset
=
Math
.
addExact
(
inputOffset
,
temp
)
;
inputConsumed
-=
temp
;
inputConsumed
-=
temp
;
inputLen
-=
temp
;
inputLen
-=
temp
;
buffered
+=
temp
;
buffered
=
Math
.
addExact
(
buffered
,
temp
)
;
}
}
// process 'buffer'
// process 'buffer'
if
(
decrypting
)
{
if
(
decrypting
)
{
...
@@ -771,7 +773,7 @@ final class CipherCore {
...
@@ -771,7 +773,7 @@ final class CipherCore {
}
else
{
}
else
{
outLen
=
cipher
.
encrypt
(
buffer
,
0
,
buffered
,
output
,
outputOffset
);
outLen
=
cipher
.
encrypt
(
buffer
,
0
,
buffered
,
output
,
outputOffset
);
}
}
outputOffset
+=
outLen
;
outputOffset
=
Math
.
addExact
(
outputOffset
,
outLen
)
;
buffered
=
0
;
buffered
=
0
;
}
}
if
(
inputConsumed
>
0
)
{
// still has input to process
if
(
inputConsumed
>
0
)
{
// still has input to process
...
@@ -802,7 +804,7 @@ final class CipherCore {
...
@@ -802,7 +804,7 @@ final class CipherCore {
if
(
inputLen
>
0
)
{
if
(
inputLen
>
0
)
{
System
.
arraycopy
(
input
,
inputOffset
,
buffer
,
buffered
,
System
.
arraycopy
(
input
,
inputOffset
,
buffer
,
buffered
,
inputLen
);
inputLen
);
buffered
+=
inputLen
;
buffered
=
Math
.
addExact
(
buffered
,
inputLen
)
;
}
}
return
outLen
;
return
outLen
;
}
}
...
@@ -912,10 +914,10 @@ final class CipherCore {
...
@@ -912,10 +914,10 @@ final class CipherCore {
}
}
// calculate total input length
// calculate total input length
int
len
=
buffered
+
inputLen
;
int
len
=
Math
.
addExact
(
buffered
,
inputLen
)
;
// calculate padding length
// calculate padding length
int
totalLen
=
len
+
cipher
.
getBufferedLength
(
);
int
totalLen
=
Math
.
addExact
(
len
,
cipher
.
getBufferedLength
()
);
int
paddingLen
=
0
;
int
paddingLen
=
0
;
// will the total input length be a multiple of blockSize?
// will the total input length be a multiple of blockSize?
if
(
unitBytes
!=
blockSize
)
{
if
(
unitBytes
!=
blockSize
)
{
...
@@ -948,12 +950,12 @@ final class CipherCore {
...
@@ -948,12 +950,12 @@ final class CipherCore {
int
finalBufLen
=
inputLen
;
int
finalBufLen
=
inputLen
;
if
((
buffered
!=
0
)
||
(!
decrypting
&&
padding
!=
null
)
||
if
((
buffered
!=
0
)
||
(!
decrypting
&&
padding
!=
null
)
||
((
input
==
output
)
((
input
==
output
)
&&
(
outputOffset
<
(
inputOffset
+
inputLen
)
)
&&
(
outputOffset
-
inputOffset
<
inputLen
)
&&
(
inputOffset
<
(
outputOffset
+
buffer
.
length
)
)))
{
&&
(
inputOffset
-
outputOffset
<
buffer
.
length
)))
{
if
(
decrypting
||
padding
==
null
)
{
if
(
decrypting
||
padding
==
null
)
{
paddingLen
=
0
;
paddingLen
=
0
;
}
}
finalBuf
=
new
byte
[
len
+
paddingLen
];
finalBuf
=
new
byte
[
Math
.
addExact
(
len
,
paddingLen
)
];
finalOffset
=
0
;
finalOffset
=
0
;
if
(
buffered
!=
0
)
{
if
(
buffered
!=
0
)
{
System
.
arraycopy
(
buffer
,
0
,
finalBuf
,
0
,
buffered
);
System
.
arraycopy
(
buffer
,
0
,
finalBuf
,
0
,
buffered
);
...
@@ -963,7 +965,7 @@ final class CipherCore {
...
@@ -963,7 +965,7 @@ final class CipherCore {
buffered
,
inputLen
);
buffered
,
inputLen
);
}
}
if
(
paddingLen
!=
0
)
{
if
(
paddingLen
!=
0
)
{
padding
.
padWithLen
(
finalBuf
,
(
buffered
+
inputLen
),
paddingLen
);
padding
.
padWithLen
(
finalBuf
,
Math
.
addExact
(
buffered
,
inputLen
),
paddingLen
);
}
}
finalBufLen
=
finalBuf
.
length
;
finalBufLen
=
finalBuf
.
length
;
}
}
...
...
src/share/classes/com/sun/crypto/provider/DESedeWrapCipher.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2004, 201
3
, 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.
* 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
...
@@ -140,7 +140,7 @@ public final class DESedeWrapCipher extends CipherSpi {
...
@@ -140,7 +140,7 @@ public final class DESedeWrapCipher extends CipherSpi {
if
(
decrypting
)
{
if
(
decrypting
)
{
result
=
inputLen
-
16
;
// CHECKSUM_LEN + IV_LEN;
result
=
inputLen
-
16
;
// CHECKSUM_LEN + IV_LEN;
}
else
{
}
else
{
result
=
inputLen
+
16
;
result
=
Math
.
addExact
(
inputLen
,
16
)
;
}
}
return
(
result
<
0
?
0
:
result
);
return
(
result
<
0
?
0
:
result
);
}
}
...
@@ -452,11 +452,11 @@ public final class DESedeWrapCipher extends CipherSpi {
...
@@ -452,11 +452,11 @@ public final class DESedeWrapCipher extends CipherSpi {
}
}
byte
[]
cks
=
getChecksum
(
keyVal
);
byte
[]
cks
=
getChecksum
(
keyVal
);
byte
[]
in
=
new
byte
[
keyVal
.
length
+
CHECKSUM_LEN
];
byte
[]
in
=
new
byte
[
Math
.
addExact
(
keyVal
.
length
,
CHECKSUM_LEN
)
];
System
.
arraycopy
(
keyVal
,
0
,
in
,
0
,
keyVal
.
length
);
System
.
arraycopy
(
keyVal
,
0
,
in
,
0
,
keyVal
.
length
);
System
.
arraycopy
(
cks
,
0
,
in
,
keyVal
.
length
,
CHECKSUM_LEN
);
System
.
arraycopy
(
cks
,
0
,
in
,
keyVal
.
length
,
CHECKSUM_LEN
);
byte
[]
out
=
new
byte
[
iv
.
length
+
in
.
length
];
byte
[]
out
=
new
byte
[
Math
.
addExact
(
iv
.
length
,
in
.
length
)
];
System
.
arraycopy
(
iv
,
0
,
out
,
0
,
iv
.
length
);
System
.
arraycopy
(
iv
,
0
,
out
,
0
,
iv
.
length
);
cipher
.
encrypt
(
in
,
0
,
in
.
length
,
out
,
iv
.
length
);
cipher
.
encrypt
(
in
,
0
,
in
.
length
,
out
,
iv
.
length
);
...
...
src/share/classes/com/sun/crypto/provider/ISO10126Padding.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2003, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2003, 201
7
, 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
...
@@ -63,15 +63,16 @@ final class ISO10126Padding implements Padding {
...
@@ -63,15 +63,16 @@ final class ISO10126Padding implements Padding {
if
(
in
==
null
)
if
(
in
==
null
)
return
;
return
;
if
((
off
+
len
)
>
in
.
length
)
{
int
idx
=
Math
.
addExact
(
off
,
len
);
if
(
idx
>
in
.
length
)
{
throw
new
ShortBufferException
(
"Buffer too small to hold padding"
);
throw
new
ShortBufferException
(
"Buffer too small to hold padding"
);
}
}
byte
paddingOctet
=
(
byte
)
(
len
&
0xff
);
byte
paddingOctet
=
(
byte
)
(
len
&
0xff
);
byte
[]
padding
=
new
byte
[
len
];
byte
[]
padding
=
new
byte
[
len
-
1
];
SunJCE
.
getRandom
().
nextBytes
(
padding
);
SunJCE
.
getRandom
().
nextBytes
(
padding
);
padding
[
len
-
1
]
=
paddingOctet
;
System
.
arraycopy
(
padding
,
0
,
in
,
off
,
len
-
1
)
;
System
.
arraycopy
(
padding
,
0
,
in
,
off
,
len
)
;
in
[
idx
-
1
]
=
paddingOctet
;
return
;
return
;
}
}
...
@@ -94,14 +95,15 @@ final class ISO10126Padding implements Padding {
...
@@ -94,14 +95,15 @@ final class ISO10126Padding implements Padding {
return
0
;
return
0
;
}
}
byte
lastByte
=
in
[
off
+
len
-
1
];
int
idx
=
Math
.
addExact
(
off
,
len
);
byte
lastByte
=
in
[
idx
-
1
];
int
padValue
=
(
int
)
lastByte
&
0x0ff
;
int
padValue
=
(
int
)
lastByte
&
0x0ff
;
if
((
padValue
<
0x01
)
if
((
padValue
<
0x01
)
||
(
padValue
>
blockSize
))
{
||
(
padValue
>
blockSize
))
{
return
-
1
;
return
-
1
;
}
}
int
start
=
off
+
len
-
((
int
)
lastByte
&
0x0ff
)
;
int
start
=
idx
-
padValue
;
if
(
start
<
off
)
{
if
(
start
<
off
)
{
return
-
1
;
return
-
1
;
}
}
...
...
src/share/classes/com/sun/crypto/provider/PBECipherCore.java
已删除
100644 → 0
浏览文件 @
088a356d
此差异已折叠。
点击以展开。
src/share/classes/com/sun/crypto/provider/PBES1Core.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 2002, 201
3
, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 201
7
, 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
...
@@ -260,7 +260,7 @@ final class PBES1Core {
...
@@ -260,7 +260,7 @@ final class PBES1Core {
if
(
algo
.
equals
(
"DES"
))
{
if
(
algo
.
equals
(
"DES"
))
{
// P || S (password concatenated with salt)
// P || S (password concatenated with salt)
byte
[]
concat
=
new
byte
[
passwdBytes
.
length
+
salt
.
length
];
byte
[]
concat
=
new
byte
[
Math
.
addExact
(
passwdBytes
.
length
,
salt
.
length
)
];
System
.
arraycopy
(
passwdBytes
,
0
,
concat
,
0
,
passwdBytes
.
length
);
System
.
arraycopy
(
passwdBytes
,
0
,
concat
,
0
,
passwdBytes
.
length
);
java
.
util
.
Arrays
.
fill
(
passwdBytes
,
(
byte
)
0x00
);
java
.
util
.
Arrays
.
fill
(
passwdBytes
,
(
byte
)
0x00
);
System
.
arraycopy
(
salt
,
0
,
concat
,
passwdBytes
.
length
,
salt
.
length
);
System
.
arraycopy
(
salt
,
0
,
concat
,
passwdBytes
.
length
,
salt
.
length
);
...
...
src/share/classes/com/sun/crypto/provider/PKCS5Padding.java
浏览文件 @
46f365dd
/*
/*
* Copyright (c) 1997, 20
0
7, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 20
1
7, 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
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
package
com.sun.crypto.provider
;
package
com.sun.crypto.provider
;
import
javax.crypto.ShortBufferException
;
import
javax.crypto.ShortBufferException
;
import
java.util.Arrays
;
/**
/**
* This class implements padding as specified in the PKCS#5 standard.
* This class implements padding as specified in the PKCS#5 standard.
...
@@ -63,14 +64,13 @@ final class PKCS5Padding implements Padding {
...
@@ -63,14 +64,13 @@ final class PKCS5Padding implements Padding {
if
(
in
==
null
)
if
(
in
==
null
)
return
;
return
;
if
((
off
+
len
)
>
in
.
length
)
{
int
idx
=
Math
.
addExact
(
off
,
len
);
if
(
idx
>
in
.
length
)
{
throw
new
ShortBufferException
(
"Buffer too small to hold padding"
);
throw
new
ShortBufferException
(
"Buffer too small to hold padding"
);
}
}
byte
paddingOctet
=
(
byte
)
(
len
&
0xff
);
byte
paddingOctet
=
(
byte
)
(
len
&
0xff
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
Arrays
.
fill
(
in
,
off
,
idx
,
paddingOctet
);
in
[
i
+
off
]
=
paddingOctet
;
}
return
;
return
;
}
}
...
@@ -92,25 +92,24 @@ final class PKCS5Padding implements Padding {
...
@@ -92,25 +92,24 @@ final class PKCS5Padding implements Padding {
(
len
==
0
))
{
// this can happen if input is really a padded buffer
(
len
==
0
))
{
// this can happen if input is really a padded buffer
return
0
;
return
0
;
}
}
int
idx
=
Math
.
addExact
(
off
,
len
);
byte
lastByte
=
in
[
off
+
len
-
1
];
byte
lastByte
=
in
[
idx
-
1
];
int
padValue
=
(
int
)
lastByte
&
0x0ff
;
int
padValue
=
(
int
)
lastByte
&
0x0ff
;
if
((
padValue
<
0x01
)
if
((
padValue
<
0x01
)
||
(
padValue
>
blockSize
))
{
||
(
padValue
>
blockSize
))
{
return
-
1
;
return
-
1
;
}
}
int
start
=
off
+
len
-
((
int
)
lastByte
&
0x0ff
)
;
int
start
=
idx
-
padValue
;
if
(
start
<
off
)
{
if
(
start
<
off
)
{
return
-
1
;
return
-
1
;
}
}
for
(
int
i
=
0
;
i
<
((
int
)
lastByte
&
0x0ff
)
;
i
++)
{
for
(
int
i
=
start
;
i
<
idx
;
i
++)
{
if
(
in
[
start
+
i
]
!=
lastByte
)
{
if
(
in
[
i
]
!=
lastByte
)
{
return
-
1
;
return
-
1
;
}
}
}
}
return
start
;
return
start
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录