Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
7687f525
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看板
提交
7687f525
编写于
2月 12, 2016
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
evp/e_des[3].c: address compiler warnings, fix formatting.
RT#4210 Reviewed-by:
N
Richard Levitte
<
levitte@openssl.org
>
上级
5e4bbeb4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
41 addition
and
25 deletion
+41
-25
crypto/evp/e_des.c
crypto/evp/e_des.c
+22
-13
crypto/evp/e_des3.c
crypto/evp/e_des3.c
+19
-12
未找到文件。
crypto/evp/e_des.c
浏览文件 @
7687f525
...
...
@@ -70,12 +70,13 @@ typedef struct {
DES_key_schedule
ks
;
}
ks
;
union
{
void
(
*
cbc
)
(
const
void
*
,
void
*
,
size_t
,
const
void
*
,
void
*
);
void
(
*
cbc
)
(
const
void
*
,
void
*
,
size_t
,
const
DES_key_schedule
*
,
unsigned
char
*
);
}
stream
;
}
EVP_DES_KEY
;
# if defined(AES_ASM) && (defined(__sparc) || defined(__sparc__))
/* ---------^^^ this is not a typo, just a way to detect that
/* ---------
-
^^^ this is not a typo, just a way to detect that
* assembler support was in general requested... */
# include "sparc_arch.h"
...
...
@@ -85,9 +86,9 @@ extern unsigned int OPENSSL_sparcv9cap_P[];
void
des_t4_key_expand
(
const
void
*
key
,
DES_key_schedule
*
ks
);
void
des_t4_cbc_encrypt
(
const
void
*
inp
,
void
*
out
,
size_t
len
,
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
const
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
void
des_t4_cbc_decrypt
(
const
void
*
inp
,
void
*
out
,
size_t
len
,
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
const
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
# endif
static
int
des_init_key
(
EVP_CIPHER_CTX
*
ctx
,
const
unsigned
char
*
key
,
...
...
@@ -136,20 +137,24 @@ static int des_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
{
EVP_DES_KEY
*
dat
=
(
EVP_DES_KEY
*
)
EVP_CIPHER_CTX_cipher_data
(
ctx
);
if
(
dat
->
stream
.
cbc
)
{
(
*
dat
->
stream
.
cbc
)
(
in
,
out
,
inl
,
&
dat
->
ks
.
ks
,
EVP_CIPHER_CTX_iv_noconst
(
ctx
));
if
(
dat
->
stream
.
cbc
!=
NULL
)
{
(
*
dat
->
stream
.
cbc
)
(
in
,
out
,
inl
,
&
dat
->
ks
.
ks
,
EVP_CIPHER_CTX_iv_noconst
(
ctx
));
return
1
;
}
while
(
inl
>=
EVP_MAXCHUNK
)
{
DES_ncbc_encrypt
(
in
,
out
,
(
long
)
EVP_MAXCHUNK
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
DES_ncbc_encrypt
(
in
,
out
,
(
long
)
EVP_MAXCHUNK
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
inl
-=
EVP_MAXCHUNK
;
in
+=
EVP_MAXCHUNK
;
out
+=
EVP_MAXCHUNK
;
}
if
(
inl
)
DES_ncbc_encrypt
(
in
,
out
,
(
long
)
inl
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
return
1
;
}
...
...
@@ -194,7 +199,8 @@ static int des_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
for
(
n
=
0
;
n
<
chunk
*
8
;
++
n
)
{
c
[
0
]
=
(
in
[
n
/
8
]
&
(
1
<<
(
7
-
n
%
8
)))
?
0x80
:
0
;
DES_cfb_encrypt
(
c
,
d
,
1
,
1
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
out
[
n
/
8
]
=
(
out
[
n
/
8
]
&
~
(
0x80
>>
(
unsigned
int
)(
n
%
8
)))
|
((
d
[
0
]
&
0x80
)
>>
(
unsigned
int
)(
n
%
8
));
...
...
@@ -213,15 +219,18 @@ static int des_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
const
unsigned
char
*
in
,
size_t
inl
)
{
while
(
inl
>=
EVP_MAXCHUNK
)
{
DES_cfb_encrypt
(
in
,
out
,
8
,
(
long
)
EVP_MAXCHUNK
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
DES_cfb_encrypt
(
in
,
out
,
8
,
(
long
)
EVP_MAXCHUNK
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
inl
-=
EVP_MAXCHUNK
;
in
+=
EVP_MAXCHUNK
;
out
+=
EVP_MAXCHUNK
;
}
if
(
inl
)
DES_cfb_encrypt
(
in
,
out
,
8
,
(
long
)
inl
,
EVP_CIPHER_CTX_cipher_data
(
ctx
),
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
return
1
;
}
...
...
crypto/evp/e_des3.c
浏览文件 @
7687f525
...
...
@@ -70,7 +70,8 @@ typedef struct {
DES_key_schedule
ks
[
3
];
}
ks
;
union
{
void
(
*
cbc
)
(
const
void
*
,
void
*
,
size_t
,
const
void
*
,
void
*
);
void
(
*
cbc
)
(
const
void
*
,
void
*
,
size_t
,
const
DES_key_schedule
*
,
unsigned
char
*
);
}
stream
;
}
DES_EDE_KEY
;
# define ks1 ks.ks[0]
...
...
@@ -88,9 +89,9 @@ extern unsigned int OPENSSL_sparcv9cap_P[];
void
des_t4_key_expand
(
const
void
*
key
,
DES_key_schedule
*
ks
);
void
des_t4_ede3_cbc_encrypt
(
const
void
*
inp
,
void
*
out
,
size_t
len
,
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
const
DES_key_schedule
ks
[
3
]
,
unsigned
char
iv
[
8
]);
void
des_t4_ede3_cbc_decrypt
(
const
void
*
inp
,
void
*
out
,
size_t
len
,
DES_key_schedule
*
ks
,
unsigned
char
iv
[
8
]);
const
DES_key_schedule
ks
[
3
]
,
unsigned
char
iv
[
8
]);
# endif
static
int
des_ede_init_key
(
EVP_CIPHER_CTX
*
ctx
,
const
unsigned
char
*
key
,
...
...
@@ -151,15 +152,17 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
{
DES_EDE_KEY
*
dat
=
data
(
ctx
);
if
(
dat
->
stream
.
cbc
)
{
(
*
dat
->
stream
.
cbc
)
(
in
,
out
,
inl
,
&
dat
->
ks
,
EVP_CIPHER_CTX_iv_noconst
(
ctx
));
if
(
dat
->
stream
.
cbc
!=
NULL
)
{
(
*
dat
->
stream
.
cbc
)
(
in
,
out
,
inl
,
dat
->
ks
.
ks
,
EVP_CIPHER_CTX_iv_noconst
(
ctx
));
return
1
;
}
while
(
inl
>=
EVP_MAXCHUNK
)
{
DES_ede3_cbc_encrypt
(
in
,
out
,
(
long
)
EVP_MAXCHUNK
,
&
dat
->
ks1
,
&
dat
->
ks2
,
&
dat
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
inl
-=
EVP_MAXCHUNK
;
in
+=
EVP_MAXCHUNK
;
out
+=
EVP_MAXCHUNK
;
...
...
@@ -167,7 +170,8 @@ static int des_ede_cbc_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
if
(
inl
)
DES_ede3_cbc_encrypt
(
in
,
out
,
(
long
)
inl
,
&
dat
->
ks1
,
&
dat
->
ks2
,
&
dat
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
return
1
;
}
...
...
@@ -212,7 +216,8 @@ static int des_ede3_cfb1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
c
[
0
]
=
(
in
[
n
/
8
]
&
(
1
<<
(
7
-
n
%
8
)))
?
0x80
:
0
;
DES_ede3_cfb_encrypt
(
c
,
d
,
1
,
1
,
&
data
(
ctx
)
->
ks1
,
&
data
(
ctx
)
->
ks2
,
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
out
[
n
/
8
]
=
(
out
[
n
/
8
]
&
~
(
0x80
>>
(
unsigned
int
)(
n
%
8
)))
|
((
d
[
0
]
&
0x80
)
>>
(
unsigned
int
)(
n
%
8
));
...
...
@@ -227,7 +232,8 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
while
(
inl
>=
EVP_MAXCHUNK
)
{
DES_ede3_cfb_encrypt
(
in
,
out
,
8
,
(
long
)
EVP_MAXCHUNK
,
&
data
(
ctx
)
->
ks1
,
&
data
(
ctx
)
->
ks2
,
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
inl
-=
EVP_MAXCHUNK
;
in
+=
EVP_MAXCHUNK
;
...
...
@@ -236,7 +242,8 @@ static int des_ede3_cfb8_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
if
(
inl
)
DES_ede3_cfb_encrypt
(
in
,
out
,
8
,
(
long
)
inl
,
&
data
(
ctx
)
->
ks1
,
&
data
(
ctx
)
->
ks2
,
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
&
data
(
ctx
)
->
ks3
,
(
DES_cblock
*
)
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
EVP_CIPHER_CTX_encrypting
(
ctx
));
return
1
;
}
...
...
@@ -358,7 +365,7 @@ static int des_ede3_unwrap(EVP_CIPHER_CTX *ctx, unsigned char *out,
int
rv
=
-
1
;
if
(
inl
<
24
)
return
-
1
;
if
(
!
out
)
if
(
out
==
NULL
)
return
inl
-
16
;
memcpy
(
EVP_CIPHER_CTX_iv_noconst
(
ctx
),
wrap_iv
,
8
);
/* Decrypt first block which will end up as icv */
...
...
@@ -401,7 +408,7 @@ static int des_ede3_wrap(EVP_CIPHER_CTX *ctx, unsigned char *out,
const
unsigned
char
*
in
,
size_t
inl
)
{
unsigned
char
sha1tmp
[
SHA_DIGEST_LENGTH
];
if
(
!
out
)
if
(
out
==
NULL
)
return
inl
+
16
;
/* Copy input to output buffer + 8 so we have space for IV */
memmove
(
out
+
8
,
in
,
inl
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录