Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
3309e088
提交
3309e088
authored
8月 22, 2010
作者:
Thomas Mueller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
New experimental pseudo-encryption algorithm "FOG".
上级
560d0380
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
98 行增加
和
2 行删除
+98
-2
changelog.html
h2/src/docsrc/html/changelog.html
+10
-1
AES.java
h2/src/main/org/h2/security/AES.java
+1
-1
BlockCipher.java
h2/src/main/org/h2/security/BlockCipher.java
+1
-0
CipherFactory.java
h2/src/main/org/h2/security/CipherFactory.java
+2
-0
Fog.java
h2/src/main/org/h2/security/Fog.java
+84
-0
没有找到文件。
h2/src/docsrc/html/changelog.html
浏览文件 @
3309e088
...
@@ -18,7 +18,16 @@ Change Log
...
@@ -18,7 +18,16 @@ Change Log
<h1>
Change Log
</h1>
<h1>
Change Log
</h1>
<h2>
Next Version (unreleased)
</h2>
<h2>
Next Version (unreleased)
</h2>
<ul><li>
Password hash: in addition to connecting with the plain text password,
<ul><li>
-
</li></ul>
<h2>
Version 1.2.141 (2010-08-22)
</h2>
<ul><li>
New experimental pseudo-encryption algorithm "FOG".
It makes the data appear to be encrypted. This algorithm is cryptographically extremely weak,
and should only be used to hide data from reading the plain text using a text editor.
Please let us know if you think this is useful or not.
</li><li>
Documentation: the grammar and function documentation can now be easier translated.
</li><li>
Password hash: in addition to connecting with the plain text password,
H2 now supports connecting with the password hash.
H2 now supports connecting with the password hash.
Like this you don't have to store plain text passwords in config files.
Like this you don't have to store plain text passwords in config files.
For details, see the documentation at Advanced / Password Hash.
For details, see the documentation at Advanced / Password Hash.
...
...
h2/src/main/org/h2/security/AES.java
浏览文件 @
3309e088
...
@@ -244,7 +244,7 @@ public class AES implements BlockCipher {
...
@@ -244,7 +244,7 @@ public class AES implements BlockCipher {
}
}
public
int
getKeyLength
()
{
public
int
getKeyLength
()
{
return
4
*
4
;
return
16
;
}
}
}
}
h2/src/main/org/h2/security/BlockCipher.java
浏览文件 @
3309e088
...
@@ -50,4 +50,5 @@ public interface BlockCipher {
...
@@ -50,4 +50,5 @@ public interface BlockCipher {
* @return the length of the key
* @return the length of the key
*/
*/
int
getKeyLength
();
int
getKeyLength
();
}
}
h2/src/main/org/h2/security/CipherFactory.java
浏览文件 @
3309e088
...
@@ -63,6 +63,8 @@ public class CipherFactory {
...
@@ -63,6 +63,8 @@ public class CipherFactory {
return
new
XTEA
();
return
new
XTEA
();
}
else
if
(
"AES"
.
equalsIgnoreCase
(
algorithm
))
{
}
else
if
(
"AES"
.
equalsIgnoreCase
(
algorithm
))
{
return
new
AES
();
return
new
AES
();
}
else
if
(
"FOG"
.
equalsIgnoreCase
(
algorithm
))
{
return
new
Fog
();
}
}
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_CIPHER
,
algorithm
);
throw
DbException
.
get
(
ErrorCode
.
UNSUPPORTED_CIPHER
,
algorithm
);
}
}
...
...
h2/src/main/org/h2/security/Fog.java
0 → 100644
浏览文件 @
3309e088
/*
* Copyright 2004-2010 H2 Group. Multiple-Licensed under the H2 License,
* Version 1.0, and under the Eclipse Public License, Version 1.0
* (http://h2database.com/html/license.html).
* Initial Developer: H2 Group
*/
package
org
.
h2
.
security
;
import
org.h2.util.Utils
;
/**
* A pseudo-encryption algorithm that makes the data appear to be
* encrypted. This algorithm is cryptographically extremely weak, and should
* only be used to hide data from reading the plain text using a text editor.
*/
public
class
Fog
implements
BlockCipher
{
private
int
key
;
public
void
encrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
16
)
{
encryptBlock
(
bytes
,
bytes
,
i
);
}
}
public
void
decrypt
(
byte
[]
bytes
,
int
off
,
int
len
)
{
for
(
int
i
=
off
;
i
<
off
+
len
;
i
+=
16
)
{
decryptBlock
(
bytes
,
bytes
,
i
);
}
}
private
void
encryptBlock
(
byte
[]
in
,
byte
[]
out
,
int
off
)
{
int
x0
=
(
in
[
off
]
<<
24
)
|
((
in
[
off
+
1
]
&
255
)
<<
16
)
|
((
in
[
off
+
2
]
&
255
)
<<
8
)
|
(
in
[
off
+
3
]
&
255
);
int
x1
=
(
in
[
off
+
4
]
<<
24
)
|
((
in
[
off
+
5
]
&
255
)
<<
16
)
|
((
in
[
off
+
6
]
&
255
)
<<
8
)
|
(
in
[
off
+
7
]
&
255
);
int
x2
=
(
in
[
off
+
8
]
<<
24
)
|
((
in
[
off
+
9
]
&
255
)
<<
16
)
|
((
in
[
off
+
10
]
&
255
)
<<
8
)
|
(
in
[
off
+
11
]
&
255
);
int
x3
=
(
in
[
off
+
12
]
<<
24
)
|
((
in
[
off
+
13
]
&
255
)
<<
16
)
|
((
in
[
off
+
14
]
&
255
)
<<
8
)
|
(
in
[
off
+
15
]
&
255
);
int
k
=
key
;
int
s
=
x1
&
31
;
x0
^=
k
;
x0
=
(
x0
<<
s
)
|
(
x0
>>>
(
32
-
s
));
x2
^=
k
;
x2
=
(
x2
<<
s
)
|
(
x2
>>>
(
32
-
s
));
s
=
x0
&
31
;
x1
^=
k
;
x1
=
(
x1
<<
s
)
|
(
x1
>>>
(
32
-
s
));
x3
^=
k
;
x3
=
(
x3
<<
s
)
|
(
x3
>>>
(
32
-
s
));
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
private
void
decryptBlock
(
byte
[]
in
,
byte
[]
out
,
int
off
)
{
int
x0
=
(
in
[
off
]
<<
24
)
|
((
in
[
off
+
1
]
&
255
)
<<
16
)
|
((
in
[
off
+
2
]
&
255
)
<<
8
)
|
(
in
[
off
+
3
]
&
255
);
int
x1
=
(
in
[
off
+
4
]
<<
24
)
|
((
in
[
off
+
5
]
&
255
)
<<
16
)
|
((
in
[
off
+
6
]
&
255
)
<<
8
)
|
(
in
[
off
+
7
]
&
255
);
int
x2
=
(
in
[
off
+
8
]
<<
24
)
|
((
in
[
off
+
9
]
&
255
)
<<
16
)
|
((
in
[
off
+
10
]
&
255
)
<<
8
)
|
(
in
[
off
+
11
]
&
255
);
int
x3
=
(
in
[
off
+
12
]
<<
24
)
|
((
in
[
off
+
13
]
&
255
)
<<
16
)
|
((
in
[
off
+
14
]
&
255
)
<<
8
)
|
(
in
[
off
+
15
]
&
255
);
int
k
=
key
;
int
s
=
32
-
(
x0
&
31
);
x1
=
(
x1
<<
s
)
|
(
x1
>>>
(
32
-
s
));
x1
^=
k
;
x3
=
(
x3
<<
s
)
|
(
x3
>>>
(
32
-
s
));
x3
^=
k
;
s
=
32
-
(
x1
&
31
);
x0
=
(
x0
<<
s
)
|
(
x0
>>>
(
32
-
s
));
x0
^=
k
;
x2
=
(
x2
<<
s
)
|
(
x2
>>>
(
32
-
s
));
x2
^=
k
;
out
[
off
]
=
(
byte
)
(
x0
>>
24
);
out
[
off
+
1
]
=
(
byte
)
(
x0
>>
16
);
out
[
off
+
2
]
=
(
byte
)
(
x0
>>
8
);
out
[
off
+
3
]
=
(
byte
)
x0
;
out
[
off
+
4
]
=
(
byte
)
(
x1
>>
24
);
out
[
off
+
5
]
=
(
byte
)
(
x1
>>
16
);
out
[
off
+
6
]
=
(
byte
)
(
x1
>>
8
);
out
[
off
+
7
]
=
(
byte
)
x1
;
out
[
off
+
8
]
=
(
byte
)
(
x2
>>
24
);
out
[
off
+
9
]
=
(
byte
)
(
x2
>>
16
);
out
[
off
+
10
]
=
(
byte
)
(
x2
>>
8
);
out
[
off
+
11
]
=
(
byte
)
x2
;
out
[
off
+
12
]
=
(
byte
)
(
x3
>>
24
);
out
[
off
+
13
]
=
(
byte
)
(
x3
>>
16
);
out
[
off
+
14
]
=
(
byte
)
(
x3
>>
8
);
out
[
off
+
15
]
=
(
byte
)
x3
;
}
public
int
getKeyLength
()
{
return
16
;
}
public
void
setKey
(
byte
[]
key
)
{
this
.
key
=
(
int
)
Utils
.
readLong
(
key
,
0
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论