Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
bbebd0de
提交
bbebd0de
authored
14 年前
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Opening and closing encrypted databases is now much faster.
上级
40ee48c6
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
26 行增加
和
36 行删除
+26
-36
AES.java
h2/src/main/org/h2/security/AES.java
+8
-4
SecureFileStore.java
h2/src/main/org/h2/security/SecureFileStore.java
+10
-27
XTEA.java
h2/src/main/org/h2/security/XTEA.java
+8
-4
FileStore.java
h2/src/main/org/h2/store/FileStore.java
+0
-1
没有找到文件。
h2/src/main/org/h2/security/AES.java
浏览文件 @
bbebd0de
...
...
@@ -122,18 +122,22 @@ public class AES implements BlockCipher {
}
public
void
encrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
if
(
SysProperties
.
CHECK
&&
(
len
%
ALIGN
!=
0
))
{
if
(
SysProperties
.
CHECK
)
{
if
(
len
%
ALIGN
!=
0
)
{
DbException
.
throwInternalError
(
"unaligned len "
+
len
);
}
}
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
16
)
{
encryptBlock
(
bytes
,
bytes
,
i
);
}
}
public
void
decrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
if
(
SysProperties
.
CHECK
&&
(
len
%
ALIGN
!=
0
))
{
if
(
SysProperties
.
CHECK
)
{
if
(
len
%
ALIGN
!=
0
)
{
DbException
.
throwInternalError
(
"unaligned len "
+
len
);
}
}
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
16
)
{
decryptBlock
(
bytes
,
bytes
,
i
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/SecureFileStore.java
浏览文件 @
bbebd0de
...
...
@@ -12,8 +12,9 @@ import org.h2.store.FileStore;
import
org.h2.util.MathUtils
;
/**
* A file store that encrypts all data before writing,
* and decrypts all data after reading.
* A file store that encrypts all data before writing, and decrypts all data
* after reading. Areas that were never written to (for example after calling
* setLength to enlarge the file) are not encrypted (contains 0 bytes).
*/
public
class
SecureFileStore
extends
FileStore
{
...
...
@@ -72,8 +73,13 @@ public class SecureFileStore extends FileStore {
public
void
readFully
(
byte
[]
b
,
int
off
,
int
len
)
{
super
.
readFully
(
b
,
off
,
len
);
for
(
int
i
=
0
;
i
<
len
;
i
++)
{
if
(
b
[
i
]
!=
0
)
{
cipher
.
decrypt
(
b
,
off
,
len
);
xorInitVector
(
b
,
off
,
len
,
pos
);
break
;
}
}
pos
+=
len
;
}
...
...
@@ -82,29 +88,6 @@ public class SecureFileStore extends FileStore {
super
.
seek
(
x
);
}
public
void
setLength
(
long
newLength
)
{
long
oldPos
=
pos
;
long
length
=
length
();
if
(
newLength
>
length
)
{
seek
(
length
);
if
(
empty
==
null
)
{
empty
=
new
byte
[
16
*
1024
];
}
byte
[]
e
=
empty
;
while
(
true
)
{
int
p
=
(
int
)
Math
.
min
(
newLength
-
length
,
e
.
length
);
if
(
p
<=
0
)
{
break
;
}
write
(
e
,
0
,
p
);
length
+=
p
;
}
seek
(
oldPos
);
}
else
{
super
.
setLength
(
newLength
);
}
}
private
void
xorInitVector
(
byte
[]
b
,
int
off
,
int
len
,
long
p
)
{
byte
[]
iv
=
bufferForInitVector
;
while
(
len
>
0
)
{
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/security/XTEA.java
浏览文件 @
bbebd0de
...
...
@@ -42,18 +42,22 @@ public class XTEA implements BlockCipher {
}
public
void
encrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
if
(
SysProperties
.
CHECK
&&
(
len
%
ALIGN
!=
0
))
{
if
(
SysProperties
.
CHECK
)
{
if
(
len
%
ALIGN
!=
0
)
{
DbException
.
throwInternalError
(
"unaligned len "
+
len
);
}
}
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
8
)
{
encryptBlock
(
bytes
,
bytes
,
i
);
}
}
public
void
decrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
if
(
SysProperties
.
CHECK
&&
(
len
%
ALIGN
!=
0
))
{
if
(
SysProperties
.
CHECK
)
{
if
(
len
%
ALIGN
!=
0
)
{
DbException
.
throwInternalError
(
"unaligned len "
+
len
);
}
}
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
8
)
{
decryptBlock
(
bytes
,
bytes
,
i
);
}
...
...
This diff is collapsed.
Click to expand it.
h2/src/main/org/h2/store/FileStore.java
浏览文件 @
bbebd0de
...
...
@@ -529,5 +529,4 @@ public class FileStore {
file
.
releaseLock
();
}
}
This diff is collapsed.
Click to expand it.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论