Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
375a64e3
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
大约 1 年 前同步成功
通知
9
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,发现更多精彩内容 >>
提交
375a64e3
编写于
7月 05, 2014
作者:
A
Andy Polyakov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
apps/speed.c: add multi-block benchmark.
上级
fdea4fff
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
124 addition
and
0 deletion
+124
-0
apps/speed.c
apps/speed.c
+124
-0
未找到文件。
apps/speed.c
浏览文件 @
375a64e3
...
...
@@ -357,6 +357,7 @@ static void *KDF1_SHA1(const void *in, size_t inlen, void *out, size_t *outlen)
}
#endif
/* OPENSSL_NO_ECDH */
static
void
multiblock_speed
(
const
EVP_CIPHER
*
evp_cipher
);
int
MAIN
(
int
,
char
**
);
...
...
@@ -641,6 +642,7 @@ int MAIN(int argc, char **argv)
#ifndef NO_FORK
int
multi
=
0
;
#endif
int
multiblock
=
0
;
#ifndef TIMES
usertime
=-
1
;
...
...
@@ -791,6 +793,11 @@ int MAIN(int argc, char **argv)
j
--
;
/* Otherwise, -mr gets confused with
an algorithm. */
}
else
if
(
argc
>
0
&&
!
strcmp
(
*
argv
,
"-mb"
))
{
multiblock
=
1
;
j
--
;
}
else
#ifndef OPENSSL_NO_MD2
if
(
strcmp
(
*
argv
,
"md2"
)
==
0
)
doit
[
D_MD2
]
=
1
;
...
...
@@ -1993,6 +2000,19 @@ int MAIN(int argc, char **argv)
if
(
doit
[
D_EVP
])
{
#ifdef EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
if
(
multiblock
&&
evp_cipher
)
{
if
(
!
(
EVP_CIPHER_flags
(
evp_cipher
)
&
EVP_CIPH_FLAG_TLS1_1_MULTIBLOCK
))
{
fprintf
(
stderr
,
"%s is not multi-block capable
\n
"
,
OBJ_nid2ln
(
evp_cipher
->
nid
));
goto
end
;
}
multiblock_speed
(
evp_cipher
);
mret
=
0
;
goto
end
;
}
#endif
for
(
j
=
0
;
j
<
SIZE_NUM
;
j
++
)
{
if
(
evp_cipher
)
...
...
@@ -2968,4 +2988,108 @@ static int do_multi(int multi)
return
1
;
}
#endif
static
void
multiblock_speed
(
const
EVP_CIPHER
*
evp_cipher
)
{
static
int
mblengths
[]
=
{
8
*
1024
,
2
*
8
*
1024
,
4
*
8
*
1024
,
8
*
8
*
1024
,
8
*
16
*
1024
};
int
j
,
count
,
num
=
sizeof
(
lengths
)
/
sizeof
(
lengths
[
0
]);
const
char
*
alg_name
;
unsigned
char
*
inp
,
*
out
,
no_key
[
32
],
no_iv
[
16
];
EVP_CIPHER_CTX
ctx
;
double
d
=
0
.
0
;
inp
=
OPENSSL_malloc
(
mblengths
[
num
-
1
]);
out
=
OPENSSL_malloc
(
mblengths
[
num
-
1
]
+
1024
);
EVP_CIPHER_CTX_init
(
&
ctx
);
EVP_EncryptInit_ex
(
&
ctx
,
evp_cipher
,
NULL
,
no_key
,
no_iv
);
EVP_CIPHER_CTX_ctrl
(
&
ctx
,
EVP_CTRL_AEAD_SET_MAC_KEY
,
sizeof
(
no_key
),
no_key
);
alg_name
=
OBJ_nid2ln
(
evp_cipher
->
nid
);
for
(
j
=
0
;
j
<
num
;
j
++
)
{
print_message
(
alg_name
,
0
,
mblengths
[
j
]);
Time_F
(
START
);
for
(
count
=
0
,
run
=
1
;
run
&&
count
<
0x7fffffff
;
count
++
)
{
unsigned
char
aad
[
13
];
EVP_CTRL_TLS1_1_MULTIBLOCK_PARAM
mb_param
=
{
NULL
,
aad
,
sizeof
(
aad
),
0
};
size_t
len
=
mblengths
[
j
];
int
packlen
;
aad
[
8
]
=
23
;
aad
[
9
]
=
3
;
aad
[
10
]
=
2
;
aad
[
11
]
=
0
;
aad
[
12
]
=
0
;
mb_param
.
out
=
NULL
;
mb_param
.
inp
=
aad
;
mb_param
.
len
=
len
;
mb_param
.
interleave
=
8
;
packlen
=
EVP_CIPHER_CTX_ctrl
(
&
ctx
,
EVP_CTRL_TLS1_1_MULTIBLOCK_AAD
,
sizeof
(
mb_param
),
&
mb_param
);
if
(
packlen
>
0
)
{
mb_param
.
out
=
out
;
mb_param
.
inp
=
inp
;
mb_param
.
len
=
len
;
EVP_CIPHER_CTX_ctrl
(
&
ctx
,
EVP_CTRL_TLS1_1_MULTIBLOCK_ENCRYPT
,
sizeof
(
mb_param
),
&
mb_param
);
}
else
{
int
pad
;
RAND_bytes
(
out
,
16
);
len
+=
16
;
aad
[
11
]
=
len
>>
8
;
aad
[
12
]
=
len
;
pad
=
EVP_CIPHER_CTX_ctrl
(
&
ctx
,
EVP_CTRL_AEAD_TLS1_AAD
,
13
,
aad
);
EVP_Cipher
(
&
ctx
,
out
,
inp
,
len
+
pad
);
}
}
d
=
Time_F
(
STOP
);
BIO_printf
(
bio_err
,
mr
?
"+R:%d:%s:%f
\n
"
:
"%d %s's in %.2fs
\n
"
,
count
,
"evp"
,
d
);
results
[
D_EVP
][
j
]
=
((
double
)
count
)
/
d
*
mblengths
[
j
];
}
if
(
mr
)
{
fprintf
(
stdout
,
"+H"
);
for
(
j
=
0
;
j
<
num
;
j
++
)
fprintf
(
stdout
,
":%d"
,
mblengths
[
j
]);
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
"+F:%d:%s"
,
D_EVP
,
alg_name
);
for
(
j
=
0
;
j
<
num
;
j
++
)
fprintf
(
stdout
,
":%.2f"
,
results
[
D_EVP
][
j
]);
fprintf
(
stdout
,
"
\n
"
);
}
else
{
fprintf
(
stdout
,
"The 'numbers' are in 1000s of bytes per second processed.
\n
"
);
fprintf
(
stdout
,
"type "
);
for
(
j
=
0
;
j
<
num
;
j
++
)
fprintf
(
stdout
,
"%7d bytes"
,
mblengths
[
j
]);
fprintf
(
stdout
,
"
\n
"
);
fprintf
(
stdout
,
"%-24s"
,
alg_name
);
for
(
j
=
0
;
j
<
num
;
j
++
)
{
if
(
results
[
D_EVP
][
j
]
>
10000
)
fprintf
(
stdout
,
" %11.2fk"
,
results
[
D_EVP
][
j
]
/
1e3
);
else
fprintf
(
stdout
,
" %11.2f "
,
results
[
D_EVP
][
j
]);
}
fprintf
(
stdout
,
"
\n
"
);
}
OPENSSL_free
(
inp
);
OPENSSL_free
(
out
);
}
#endif
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录