Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
2141e6f3
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
2141e6f3
编写于
2月 08, 2013
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
e_aes_cbc_hmac_sha1.c: align calculated MAC at cache line.
It also ensures that valgring is happy.
上级
dd7e60bd
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
36 deletion
+43
-36
crypto/evp/e_aes_cbc_hmac_sha1.c
crypto/evp/e_aes_cbc_hmac_sha1.c
+43
-36
未找到文件。
crypto/evp/e_aes_cbc_hmac_sha1.c
浏览文件 @
2141e6f3
...
...
@@ -243,7 +243,10 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
}
else
{
union
{
unsigned
int
u
[
SHA_DIGEST_LENGTH
/
sizeof
(
unsigned
int
)];
unsigned
char
c
[
SHA_DIGEST_LENGTH
];
}
mac
;
unsigned
char
c
[
32
+
SHA_DIGEST_LENGTH
];
}
mac
,
*
pmac
;
/* arrange cache line alignment */
pmac
=
(
void
*
)(((
size_t
)
mac
.
c
+
31
)
&
((
size_t
)
0
-
32
));
/* decrypt HMAC|padding at once */
aesni_cbc_encrypt
(
in
,
out
,
len
,
...
...
@@ -299,17 +302,21 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
/* but pretend as if we hashed padded payload */
bitlen
=
key
->
md
.
Nl
+
(
inp_len
<<
3
);
/* at most 18 bits */
#ifdef BSWAP
bitlen
=
BSWAP
(
bitlen
);
#else
mac
.
c
[
0
]
=
0
;
mac
.
c
[
1
]
=
(
unsigned
char
)(
bitlen
>>
16
);
mac
.
c
[
2
]
=
(
unsigned
char
)(
bitlen
>>
8
);
mac
.
c
[
3
]
=
(
unsigned
char
)
bitlen
;
bitlen
=
mac
.
u
[
0
];
#endif
mac
.
u
[
0
]
=
0
;
mac
.
u
[
1
]
=
0
;
mac
.
u
[
2
]
=
0
;
mac
.
u
[
3
]
=
0
;
mac
.
u
[
4
]
=
0
;
pmac
->
u
[
0
]
=
0
;
pmac
->
u
[
1
]
=
0
;
pmac
->
u
[
2
]
=
0
;
pmac
->
u
[
3
]
=
0
;
pmac
->
u
[
4
]
=
0
;
for
(
res
=
key
->
md
.
num
,
j
=
0
;
j
<
len
;
j
++
)
{
size_t
c
=
out
[
j
];
...
...
@@ -324,11 +331,11 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
data
->
u
[
SHA_LBLOCK
-
1
]
|=
bitlen
&
mask
;
sha1_block_data_order
(
&
key
->
md
,
data
,
1
);
mask
&=
0
-
((
j
-
inp_len
-
73
)
>>
(
sizeof
(
j
)
*
8
-
1
));
mac
.
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
mac
.
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
mac
.
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
mac
.
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
mac
.
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
pmac
->
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
pmac
->
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
pmac
->
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
pmac
->
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
pmac
->
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
res
=
0
;
}
...
...
@@ -339,11 +346,11 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
data
->
u
[
SHA_LBLOCK
-
1
]
|=
bitlen
&
mask
;
sha1_block_data_order
(
&
key
->
md
,
data
,
1
);
mask
&=
0
-
((
j
-
inp_len
-
73
)
>>
(
sizeof
(
j
)
*
8
-
1
));
mac
.
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
mac
.
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
mac
.
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
mac
.
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
mac
.
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
pmac
->
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
pmac
->
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
pmac
->
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
pmac
->
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
pmac
->
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
memset
(
data
,
0
,
SHA_CBLOCK
);
j
+=
64
;
...
...
@@ -351,32 +358,32 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
data
->
u
[
SHA_LBLOCK
-
1
]
=
bitlen
;
sha1_block_data_order
(
&
key
->
md
,
data
,
1
);
mask
=
0
-
((
j
-
inp_len
-
73
)
>>
(
sizeof
(
j
)
*
8
-
1
));
mac
.
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
mac
.
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
mac
.
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
mac
.
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
mac
.
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
pmac
->
u
[
0
]
|=
key
->
md
.
h0
&
mask
;
pmac
->
u
[
1
]
|=
key
->
md
.
h1
&
mask
;
pmac
->
u
[
2
]
|=
key
->
md
.
h2
&
mask
;
pmac
->
u
[
3
]
|=
key
->
md
.
h3
&
mask
;
pmac
->
u
[
4
]
|=
key
->
md
.
h4
&
mask
;
#ifdef BSWAP
mac
.
u
[
0
]
=
BSWAP
(
mac
.
u
[
0
]);
mac
.
u
[
1
]
=
BSWAP
(
mac
.
u
[
1
]);
mac
.
u
[
2
]
=
BSWAP
(
mac
.
u
[
2
]);
mac
.
u
[
3
]
=
BSWAP
(
mac
.
u
[
3
]);
mac
.
u
[
4
]
=
BSWAP
(
mac
.
u
[
4
]);
pmac
->
u
[
0
]
=
BSWAP
(
pmac
->
u
[
0
]);
pmac
->
u
[
1
]
=
BSWAP
(
pmac
->
u
[
1
]);
pmac
->
u
[
2
]
=
BSWAP
(
pmac
->
u
[
2
]);
pmac
->
u
[
3
]
=
BSWAP
(
pmac
->
u
[
3
]);
pmac
->
u
[
4
]
=
BSWAP
(
pmac
->
u
[
4
]);
#else
for
(
i
=
0
;
i
<
5
;
i
++
)
{
res
=
mac
.
u
[
i
];
mac
.
c
[
4
*
i
+
0
]
=
(
unsigned
char
)(
res
>>
24
);
mac
.
c
[
4
*
i
+
1
]
=
(
unsigned
char
)(
res
>>
16
);
mac
.
c
[
4
*
i
+
2
]
=
(
unsigned
char
)(
res
>>
8
);
mac
.
c
[
4
*
i
+
3
]
=
(
unsigned
char
)
res
;
res
=
pmac
->
u
[
i
];
pmac
->
c
[
4
*
i
+
0
]
=
(
unsigned
char
)(
res
>>
24
);
pmac
->
c
[
4
*
i
+
1
]
=
(
unsigned
char
)(
res
>>
16
);
pmac
->
c
[
4
*
i
+
2
]
=
(
unsigned
char
)(
res
>>
8
);
pmac
->
c
[
4
*
i
+
3
]
=
(
unsigned
char
)
res
;
}
#endif
len
+=
SHA_DIGEST_LENGTH
;
#else
SHA1_Update
(
&
key
->
md
,
out
,
inp_len
);
res
=
key
->
md
.
num
;
SHA1_Final
(
mac
.
c
,
&
key
->
md
);
SHA1_Final
(
pmac
->
c
,
&
key
->
md
);
{
unsigned
int
inp_blocks
,
pad_blocks
;
...
...
@@ -392,8 +399,8 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
#endif
key
->
md
=
key
->
tail
;
SHA1_Update
(
&
key
->
md
,
mac
.
c
,
SHA_DIGEST_LENGTH
);
SHA1_Final
(
mac
.
c
,
&
key
->
md
);
SHA1_Update
(
&
key
->
md
,
pmac
->
c
,
SHA_DIGEST_LENGTH
);
SHA1_Final
(
pmac
->
c
,
&
key
->
md
);
/* verify HMAC */
out
+=
inp_len
;
...
...
@@ -410,7 +417,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
cmask
=
((
int
)(
j
-
off
-
SHA_DIGEST_LENGTH
))
>>
(
sizeof
(
int
)
*
8
-
1
);
res
|=
(
c
^
pad
)
&~
cmask
;
/* ... and padding */
cmask
&=
((
int
)(
off
-
1
-
j
))
>>
(
sizeof
(
int
)
*
8
-
1
);
res
|=
(
c
^
mac
.
c
[
i
])
&
cmask
;
res
|=
(
c
^
pmac
->
c
[
i
])
&
cmask
;
i
+=
1
&
cmask
;
}
maxpad
-=
SHA_DIGEST_LENGTH
;
...
...
@@ -420,7 +427,7 @@ static int aesni_cbc_hmac_sha1_cipher(EVP_CIPHER_CTX *ctx, unsigned char *out,
}
#else
for
(
res
=
0
,
i
=
0
;
i
<
SHA_DIGEST_LENGTH
;
i
++
)
res
|=
out
[
i
]
^
mac
.
c
[
i
];
res
|=
out
[
i
]
^
pmac
->
c
[
i
];
res
=
0
-
((
0
-
res
)
>>
(
sizeof
(
res
)
*
8
-
1
));
ret
&=
(
int
)
~
res
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录