Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
085ea803
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
1 年多 前同步成功
通知
10
Star
18
Fork
1
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
Third Party Openssl
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
085ea803
编写于
1月 05, 2008
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
engine/ccgost Win32 portability fixes.
上级
ab0ff062
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
45 addition
and
17 deletion
+45
-17
engines/ccgost/gost89.c
engines/ccgost/gost89.c
+17
-10
engines/ccgost/gost_crypt.c
engines/ccgost/gost_crypt.c
+8
-2
engines/ccgost/gost_keywrap.c
engines/ccgost/gost_keywrap.c
+8
-2
engines/ccgost/gosthash.c
engines/ccgost/gosthash.c
+2
-2
engines/ccgost/gosthash.h
engines/ccgost/gosthash.h
+10
-1
未找到文件。
engines/ccgost/gost89.c
浏览文件 @
085ea803
...
...
@@ -164,8 +164,10 @@ void gostcrypt(gost_ctx *c, const byte *in, byte *out)
n2
^=
f
(
c
,
n1
+
c
->
k
[
3
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
2
]);
n2
^=
f
(
c
,
n1
+
c
->
k
[
1
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
0
]);
out
[
0
]
=
(
n2
&
0xff
);
out
[
1
]
=
(
n2
>>
8
)
&
0xff
;
out
[
2
]
=
(
n2
>>
16
)
&
0xff
;
out
[
3
]
=
n2
>>
24
;
out
[
4
]
=
(
n1
&
0xff
);
out
[
5
]
=
(
n1
>>
8
)
&
0xff
;
out
[
6
]
=
(
n1
>>
16
)
&
0xff
;
out
[
7
]
=
n1
>>
24
;
out
[
0
]
=
(
byte
)(
n2
&
0xff
);
out
[
1
]
=
(
byte
)((
n2
>>
8
)
&
0xff
);
out
[
2
]
=
(
byte
)((
n2
>>
16
)
&
0xff
);
out
[
3
]
=
(
byte
)(
n2
>>
24
);
out
[
4
]
=
(
byte
)(
n1
&
0xff
);
out
[
5
]
=
(
byte
)((
n1
>>
8
)
&
0xff
);
out
[
6
]
=
(
byte
)((
n1
>>
16
)
&
0xff
);
out
[
7
]
=
(
byte
)(
n1
>>
24
);
}
/* Low-level decryption routine. Decrypts one 64-bit block */
void
gostdecrypt
(
gost_ctx
*
c
,
const
byte
*
in
,
byte
*
out
)
...
...
@@ -193,8 +195,11 @@ void gostdecrypt(gost_ctx *c, const byte *in,byte *out)
n2
^=
f
(
c
,
n1
+
c
->
k
[
5
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
4
]);
n2
^=
f
(
c
,
n1
+
c
->
k
[
3
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
2
]);
n2
^=
f
(
c
,
n1
+
c
->
k
[
1
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
0
]);
out
[
0
]
=
(
n2
&
0xff
);
out
[
1
]
=
(
n2
>>
8
)
&
0xff
;
out
[
2
]
=
(
n2
>>
16
)
&
0xff
;
out
[
3
]
=
n2
>>
24
;
out
[
4
]
=
(
n1
&
0xff
);
out
[
5
]
=
(
n1
>>
8
)
&
0xff
;
out
[
6
]
=
(
n1
>>
16
)
&
0xff
;
out
[
7
]
=
n1
>>
24
;
out
[
0
]
=
(
byte
)(
n2
&
0xff
);
out
[
1
]
=
(
byte
)((
n2
>>
8
)
&
0xff
);
out
[
2
]
=
(
byte
)((
n2
>>
16
)
&
0xff
);
out
[
3
]
=
(
byte
)(
n2
>>
24
);
out
[
4
]
=
(
byte
)(
n1
&
0xff
);
out
[
5
]
=
(
byte
)((
n1
>>
8
)
&
0xff
);
out
[
6
]
=
(
byte
)((
n1
>>
16
)
&
0xff
);
out
[
7
]
=
(
byte
)(
n1
>>
24
);
}
/* Encrypts several blocks in ECB mode */
...
...
@@ -280,10 +285,10 @@ void gost_get_key(gost_ctx *c, byte *k)
int
i
,
j
;
for
(
i
=
0
,
j
=
0
;
i
<
8
;
i
++
,
j
+=
4
)
{
k
[
j
]
=
c
->
k
[
i
]
&
0xFF
;
k
[
j
+
1
]
=
(
c
->
k
[
i
]
>>
8
)
&
0xFF
;
k
[
j
+
2
]
=
(
c
->
k
[
i
]
>>
16
)
&
0xFF
;
k
[
j
+
3
]
=
(
c
->
k
[
i
]
>>
24
)
&
0xFF
;
k
[
j
]
=
(
byte
)(
c
->
k
[
i
]
&
0xFF
)
;
k
[
j
+
1
]
=
(
byte
)((
c
->
k
[
i
]
>>
8
)
&
0xFF
)
;
k
[
j
+
2
]
=
(
byte
)((
c
->
k
[
i
]
>>
16
)
&
0xFF
)
;
k
[
j
+
3
]
=
(
byte
)((
c
->
k
[
i
]
>>
24
)
&
0xFF
)
;
}
}
...
...
@@ -332,8 +337,10 @@ void mac_block(gost_ctx *c,byte *buffer,const byte *block)
n2
^=
f
(
c
,
n1
+
c
->
k
[
4
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
5
]);
n2
^=
f
(
c
,
n1
+
c
->
k
[
6
]);
n1
^=
f
(
c
,
n2
+
c
->
k
[
7
]);
buffer
[
0
]
=
(
n1
&
0xff
);
buffer
[
1
]
=
(
n1
>>
8
)
&
0xff
;
buffer
[
2
]
=
(
n1
>>
16
)
&
0xff
;
buffer
[
3
]
=
n1
>>
24
;
buffer
[
4
]
=
(
n2
&
0xff
);
buffer
[
5
]
=
(
n2
>>
8
)
&
0xff
;
buffer
[
6
]
=
(
n2
>>
16
)
&
0xff
;
buffer
[
7
]
=
n2
>>
24
;
buffer
[
0
]
=
(
byte
)(
n1
&
0xff
);
buffer
[
1
]
=
(
byte
)((
n1
>>
8
)
&
0xff
);
buffer
[
2
]
=
(
byte
)((
n1
>>
16
)
&
0xff
);
buffer
[
3
]
=
(
byte
)(
n1
>>
24
);
buffer
[
4
]
=
(
byte
)(
n2
&
0xff
);
buffer
[
5
]
=
(
byte
)((
n2
>>
8
)
&
0xff
);
buffer
[
6
]
=
(
byte
)((
n2
>>
16
)
&
0xff
);
buffer
[
7
]
=
(
byte
)(
n2
>>
24
);
}
/* Get mac with specified number of bits from MAC state buffer */
...
...
engines/ccgost/gost_crypt.c
浏览文件 @
085ea803
...
...
@@ -233,13 +233,19 @@ static void gost_cnt_next (void *ctx, unsigned char *iv, unsigned char *buf)
}
g
=
buf1
[
0
]
|
(
buf1
[
1
]
<<
8
)
|
(
buf1
[
2
]
<<
16
)
|
(
buf1
[
3
]
<<
24
);
g
+=
0x01010101
;
buf1
[
0
]
=
g
&
0xff
;
buf1
[
1
]
=
(
g
>>
8
)
&
0xff
;
buf1
[
2
]
=
(
g
>>
16
)
&
0xff
;
buf1
[
3
]
=
(
g
>>
24
)
&
0xff
;
buf1
[
0
]
=
(
unsigned
char
)(
g
&
0xff
);
buf1
[
1
]
=
(
unsigned
char
)((
g
>>
8
)
&
0xff
);
buf1
[
2
]
=
(
unsigned
char
)((
g
>>
16
)
&
0xff
);
buf1
[
3
]
=
(
unsigned
char
)((
g
>>
24
)
&
0xff
);
g
=
buf1
[
4
]
|
(
buf1
[
5
]
<<
8
)
|
(
buf1
[
6
]
<<
16
)
|
(
buf1
[
7
]
<<
24
);
go
=
g
;
g
+=
0x01010104
;
if
(
go
>
g
)
/* overflow*/
g
++
;
buf1
[
4
]
=
g
&
0xff
;
buf1
[
5
]
=
(
g
>>
8
)
&
0xff
;
buf1
[
6
]
=
(
g
>>
16
)
&
0xff
;
buf1
[
7
]
=
(
g
>>
24
)
&
0xff
;
buf1
[
4
]
=
(
unsigned
char
)(
g
&
0xff
);
buf1
[
5
]
=
(
unsigned
char
)((
g
>>
8
)
&
0xff
);
buf1
[
6
]
=
(
unsigned
char
)((
g
>>
16
)
&
0xff
);
buf1
[
7
]
=
(
unsigned
char
)((
g
>>
24
)
&
0xff
);
memcpy
(
iv
,
buf1
,
8
);
gostcrypt
(
&
(
c
->
cctx
),
buf1
,
buf
);
c
->
count
+=
8
;
...
...
engines/ccgost/gost_keywrap.c
浏览文件 @
085ea803
...
...
@@ -44,8 +44,14 @@ void keyDiversifyCryptoPro(gost_ctx *ctx,const unsigned char *inputKey, const un
s2
+=
k
;
}
}
S
[
0
]
=
s1
&
0xff
;
S
[
1
]
=
(
s1
>>
8
)
&
0xff
;
S
[
2
]
=
(
s1
>>
16
)
&
0xff
;
S
[
3
]
=
(
s1
>>
24
)
&
0xff
;
S
[
4
]
=
s2
&
0xff
;
S
[
5
]
=
(
s2
>>
8
)
&
0xff
;
S
[
6
]
=
(
s2
>>
16
)
&
0xff
;
S
[
7
]
=
(
s2
>>
24
)
&
0xff
;
S
[
0
]
=
(
unsigned
char
)(
s1
&
0xff
);
S
[
1
]
=
(
unsigned
char
)((
s1
>>
8
)
&
0xff
);
S
[
2
]
=
(
unsigned
char
)((
s1
>>
16
)
&
0xff
);
S
[
3
]
=
(
unsigned
char
)((
s1
>>
24
)
&
0xff
);
S
[
4
]
=
(
unsigned
char
)(
s2
&
0xff
);
S
[
5
]
=
(
unsigned
char
)((
s2
>>
8
)
&
0xff
);
S
[
6
]
=
(
unsigned
char
)((
s2
>>
16
)
&
0xff
);
S
[
7
]
=
(
unsigned
char
)((
s2
>>
24
)
&
0xff
);
gost_key
(
ctx
,
outputKey
);
gost_enc_cfb
(
ctx
,
S
,
outputKey
,
outputKey
,
4
);
}
...
...
engines/ccgost/gosthash.c
浏览文件 @
085ea803
...
...
@@ -228,7 +228,7 @@ int finish_hash(gost_hash_ctx *ctx,byte *hashval)
byte
buf
[
32
];
byte
H
[
32
];
byte
S
[
32
];
long
long
fin_len
=
ctx
->
len
;
ghosthash_len
fin_len
=
ctx
->
len
;
byte
*
bptr
;
memcpy
(
H
,
ctx
->
H
,
32
);
memcpy
(
S
,
ctx
->
S
,
32
);
...
...
@@ -245,7 +245,7 @@ int finish_hash(gost_hash_ctx *ctx,byte *hashval)
fin_len
<<=
3
;
/* Hash length in BITS!!*/
while
(
fin_len
>
0
)
{
*
(
bptr
++
)
=
fin_len
&
0xFF
;
*
(
bptr
++
)
=
(
byte
)(
fin_len
&
0xFF
)
;
fin_len
>>=
8
;
};
hash_step
(
ctx
->
cipher_ctx
,
H
,
buf
);
...
...
engines/ccgost/gosthash.h
浏览文件 @
085ea803
...
...
@@ -10,8 +10,17 @@
#define GOSTHASH_H
#include "gost89.h"
#include <stdlib.h>
#if (defined(_WIN32) || defined(_WIN64)) && !defined(__MINGW32__)
typedef
__int64
ghosthash_len
;
#elif defined(__arch64__)
typedef
long
ghosthash_len
;
#else
typedef
long
long
ghosthash_len
;
#endif
typedef
struct
gost_hash_ctx
{
long
long
len
;
ghosthash_len
len
;
gost_ctx
*
cipher_ctx
;
int
left
;
byte
H
[
32
];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录