Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
ce1932f2
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
11 个月 前同步成功
通知
8
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ce1932f2
编写于
5月 02, 2017
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
sha/sha512.c: fix formatting.
Reviewed-by:
N
Richard Levitte
<
levitte@openssl.org
>
上级
c47aea8a
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
42 addition
and
28 deletion
+42
-28
crypto/sha/sha512.c
crypto/sha/sha512.c
+42
-28
未找到文件。
crypto/sha/sha512.c
浏览文件 @
ce1932f2
...
...
@@ -143,7 +143,7 @@ int SHA512_Final(unsigned char *md, SHA512_CTX *c)
return
0
;
switch
(
c
->
md_len
)
{
/* Let compiler decide if it's appropriate to unroll... */
/* Let compiler decide if it's appropriate to unroll... */
case
SHA384_DIGEST_LENGTH
:
for
(
n
=
0
;
n
<
SHA384_DIGEST_LENGTH
/
8
;
n
++
)
{
SHA_LONG64
t
=
c
->
h
[
n
];
...
...
@@ -172,7 +172,7 @@ int SHA512_Final(unsigned char *md, SHA512_CTX *c)
*
(
md
++
)
=
(
unsigned
char
)(
t
);
}
break
;
/* ... as well as make sure md_len is not abused. */
/* ... as well as make sure md_len is not abused. */
default:
return
0
;
}
...
...
@@ -219,12 +219,12 @@ int SHA512_Update(SHA512_CTX *c, const void *_data, size_t len)
if
((
size_t
)
data
%
sizeof
(
c
->
u
.
d
[
0
])
!=
0
)
while
(
len
>=
sizeof
(
c
->
u
))
memcpy
(
p
,
data
,
sizeof
(
c
->
u
)),
sha512_block_data_order
(
c
,
p
,
1
),
len
-=
sizeof
(
c
->
u
),
data
+=
sizeof
(
c
->
u
);
sha512_block_data_order
(
c
,
p
,
1
),
len
-=
sizeof
(
c
->
u
),
data
+=
sizeof
(
c
->
u
);
else
#endif
sha512_block_data_order
(
c
,
data
,
len
/
sizeof
(
c
->
u
)),
data
+=
len
,
len
%=
sizeof
(
c
->
u
),
data
-=
len
;
data
+=
len
,
len
%=
sizeof
(
c
->
u
),
data
-=
len
;
}
if
(
len
!=
0
)
...
...
@@ -320,9 +320,10 @@ static const SHA_LONG64 K512[80] = {
};
# ifndef PEDANTIC
# if defined(__GNUC__) && __GNUC__>=2 && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
# if defined(__GNUC__) && __GNUC__>=2 && \
!defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
# if defined(__x86_64) || defined(__x86_64__)
# define ROTR(a,n) ({ SHA_LONG64 ret;
\
# define ROTR(a,n) ({ SHA_LONG64 ret; \
asm ("rorq %1,%0" \
: "=r"(ret) \
: "J"(n),"0"(a) \
...
...
@@ -336,37 +337,37 @@ static const SHA_LONG64 K512[80] = {
# elif (defined(__i386) || defined(__i386__)) && !defined(B_ENDIAN)
# if defined(I386_ONLY)
# define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\
unsigned int hi=p[0],lo=p[1]; \
unsigned int hi=p[0],lo=p[1]; \
asm("xchgb %%ah,%%al;xchgb %%dh,%%dl;"\
"roll $16,%%eax; roll $16,%%edx; "\
"xchgb %%ah,%%al;xchgb %%dh,%%dl;"
\
"xchgb %%ah,%%al;xchgb %%dh,%%dl;"\
: "=a"(lo),"=d"(hi) \
: "0"(lo),"1"(hi) : "cc"); \
((SHA_LONG64)hi)<<32|lo; })
# else
# define PULL64(x) ({ const unsigned int *p=(const unsigned int *)(&(x));\
unsigned int hi=p[0],lo=p[1];
\
unsigned int hi=p[0],lo=p[1];
\
asm ("bswapl %0; bswapl %1;" \
: "=r"(lo),"=r"(hi) \
: "0"(lo),"1"(hi)); \
((SHA_LONG64)hi)<<32|lo; })
# endif
# elif (defined(_ARCH_PPC) && defined(__64BIT__)) || defined(_ARCH_PPC64)
# define ROTR(a,n) ({ SHA_LONG64 ret;
\
# define ROTR(a,n) ({ SHA_LONG64 ret; \
asm ("rotrdi %0,%1,%2" \
: "=r"(ret) \
: "r"(a),"K"(n)); ret; })
# elif defined(__aarch64__)
# define ROTR(a,n) ({ SHA_LONG64 ret;
\
# define ROTR(a,n) ({ SHA_LONG64 ret; \
asm ("ror %0,%1,%2" \
: "=r"(ret) \
: "r"(a),"I"(n)); ret; })
# if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
__BYTE_ORDER__==__ORDER_LITTLE_ENDIAN__
# define PULL64(x) ({ SHA_LONG64 ret;
\
# define PULL64(x) ({ SHA_LONG64 ret; \
asm ("rev %0,%1" \
: "=r"(ret) \
: "r"(*((const SHA_LONG64 *)(&(x))))); ret;
})
: "r"(*((const SHA_LONG64 *)(&(x))))); ret; })
# endif
# endif
# elif defined(_MSC_VER)
...
...
@@ -374,21 +375,28 @@ static const SHA_LONG64 K512[80] = {
# pragma intrinsic(_rotr64)
# define ROTR(a,n) _rotr64((a),n)
# endif
# if defined(_M_IX86) && !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_NO_INLINE_ASM)
# if defined(_M_IX86) && !defined(OPENSSL_NO_ASM) && \
!defined(OPENSSL_NO_INLINE_ASM)
# if defined(I386_ONLY)
static
SHA_LONG64
__fastcall
__pull64be
(
const
void
*
x
)
{
_asm
mov
edx
,[
ecx
+
0
]
_asm
mov
eax
,[
ecx
+
4
]
_asm
xchg
dh
,
dl
_asm
xchg
ah
,
al
_asm
rol
edx
,
16
_asm
rol
eax
,
16
_asm
xchg
dh
,
dl
_asm
xchg
ah
,
al
}
_asm
mov
edx
,[
ecx
+
0
]
_asm
mov
eax
,[
ecx
+
4
]
_asm
xchg
dh
,
dl
_asm
xchg
ah
,
al
_asm
rol
edx
,
16
_asm
rol
eax
,
16
_asm
xchg
dh
,
dl
_asm
xchg
ah
,
al
}
# else
static
SHA_LONG64
__fastcall
__pull64be
(
const
void
*
x
)
{
_asm
mov
edx
,[
ecx
+
0
]
_asm
mov
eax
,[
ecx
+
4
]
_asm
bswap
edx
_asm
bswap
eax
}
_asm
mov
edx
,[
ecx
+
0
]
_asm
mov
eax
,[
ecx
+
4
]
_asm
bswap
edx
_asm
bswap
eax
}
# endif
# define PULL64(x) __pull64be(&(x))
# if _MSC_VER<=1200
...
...
@@ -410,12 +418,15 @@ _asm bswap edx _asm bswap eax}
# define sigma1(x) (ROTR((x),19) ^ ROTR((x),61) ^ ((x)>>6))
# define Ch(x,y,z) (((x) & (y)) ^ ((~(x)) & (z)))
# define Maj(x,y,z) (((x) & (y)) ^ ((x) & (z)) ^ ((y) & (z)))
# if defined(__i386) || defined(__i386__) || defined(_M_IX86)
/*
* This code should give better results on 32-bit CPU with less than
* ~24 registers, both size and performance wise...
*/
static
void
sha512_block_data_order
(
SHA512_CTX
*
ctx
,
const
void
*
in
,
size_t
num
)
*/
static
void
sha512_block_data_order
(
SHA512_CTX
*
ctx
,
const
void
*
in
,
size_t
num
)
{
const
SHA_LONG64
*
W
=
in
;
SHA_LONG64
A
,
E
,
T
;
...
...
@@ -475,6 +486,7 @@ _asm bswap edx _asm bswap eax}
}
# elif defined(OPENSSL_SMALL_FOOTPRINT)
static
void
sha512_block_data_order
(
SHA512_CTX
*
ctx
,
const
void
*
in
,
size_t
num
)
{
...
...
@@ -545,15 +557,17 @@ static void sha512_block_data_order(SHA512_CTX *ctx, const void *in,
}
# else
# define ROUND_00_15(i,a,b,c,d,e,f,g,h)
do { \
# define ROUND_00_15(i,a,b,c,d,e,f,g,h) do { \
T1 += h + Sigma1(e) + Ch(e,f,g) + K512[i]; \
h = Sigma0(a) + Maj(a,b,c); \
d += T1; h += T1; } while (0)
# define ROUND_16_80(i,j,a,b,c,d,e,f,g,h,X) do { \
d += T1; h += T1; } while (0)
# define ROUND_16_80(i,j,a,b,c,d,e,f,g,h,X) do { \
s0 = X[(j+1)&0x0f]; s0 = sigma0(s0); \
s1 = X[(j+14)&0x0f]; s1 = sigma1(s1); \
T1 = X[(j)&0x0f] += s0 + s1 + X[(j+9)&0x0f]; \
ROUND_00_15(i+j,a,b,c,d,e,f,g,h); } while (0)
static
void
sha512_block_data_order
(
SHA512_CTX
*
ctx
,
const
void
*
in
,
size_t
num
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录