Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
563f1503
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,发现更多精彩内容 >>
提交
563f1503
编写于
3月 13, 2000
作者:
B
Bodo Möller
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Connection timings (using ISO C function clock()).
上级
88f17a5e
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
104 addition
and
29 deletion
+104
-29
ssl/ssltest.c
ssl/ssltest.c
+98
-28
test/testssl
test/testssl
+6
-1
未找到文件。
ssl/ssltest.c
浏览文件 @
563f1503
...
@@ -62,11 +62,13 @@
...
@@ -62,11 +62,13 @@
#include <stdio.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdlib.h>
#include <string.h>
#include <string.h>
#include <time.h>
#include "openssl/e_os.h"
#include "openssl/e_os.h"
#include <openssl/bio.h>
#include <openssl/bio.h>
#include <openssl/crypto.h>
#include <openssl/crypto.h>
#include <openssl/evp.h>
#include <openssl/x509.h>
#include <openssl/x509.h>
#include <openssl/ssl.h>
#include <openssl/ssl.h>
#include <openssl/err.h>
#include <openssl/err.h>
...
@@ -108,7 +110,7 @@ static int s_nbio=0;
...
@@ -108,7 +110,7 @@ static int s_nbio=0;
static
const
char
rnd_seed
[]
=
"string to make the random number generator think it has entropy"
;
static
const
char
rnd_seed
[]
=
"string to make the random number generator think it has entropy"
;
int
doit_biopair
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
bytes
);
int
doit_biopair
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
bytes
,
clock_t
*
s_time
,
clock_t
*
c_time
);
int
doit
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
bytes
);
int
doit
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
bytes
);
static
void
sv_usage
(
void
)
static
void
sv_usage
(
void
)
{
{
...
@@ -143,6 +145,51 @@ static void sv_usage(void)
...
@@ -143,6 +145,51 @@ static void sv_usage(void)
fprintf
(
stderr
,
" -cipher arg - The cipher list
\n
"
);
fprintf
(
stderr
,
" -cipher arg - The cipher list
\n
"
);
fprintf
(
stderr
,
" -bio_pair - Use BIO pairs
\n
"
);
fprintf
(
stderr
,
" -bio_pair - Use BIO pairs
\n
"
);
fprintf
(
stderr
,
" -f - Test even cases that can't work
\n
"
);
fprintf
(
stderr
,
" -f - Test even cases that can't work
\n
"
);
fprintf
(
stderr
,
" -time - measure processor time used by client and server
\n
"
);
}
static
void
print_details
(
SSL
*
c_ssl
,
const
char
*
prefix
)
{
SSL_CIPHER
*
ciph
;
X509
*
cert
;
ciph
=
SSL_get_current_cipher
(
c_ssl
);
BIO_printf
(
bio_stdout
,
"%s%s, cipher %s %s"
,
prefix
,
SSL_get_version
(
c_ssl
),
SSL_CIPHER_get_version
(
ciph
),
SSL_CIPHER_get_name
(
ciph
));
cert
=
SSL_get_peer_certificate
(
c_ssl
);
if
(
cert
!=
NULL
)
{
EVP_PKEY
*
pkey
=
X509_get_pubkey
(
cert
);
if
(
pkey
!=
NULL
)
{
if
(
0
)
;
#ifndef NO_RSA
else
if
(
pkey
->
type
==
EVP_PKEY_RSA
&&
pkey
->
pkey
.
rsa
!=
NULL
&&
pkey
->
pkey
.
rsa
->
n
!=
NULL
)
{
BIO_printf
(
bio_stdout
,
", %d bit RSA"
,
BN_num_bits
(
pkey
->
pkey
.
rsa
->
n
));
}
#endif
#ifndef NO_DSA
else
if
(
pkey
->
type
==
EVP_PKEY_DSA
&&
pkey
->
pkey
.
dsa
!=
NULL
&&
pkey
->
pkey
.
dsa
->
p
!=
NULL
)
{
BIO_printf
(
bio_stdout
,
", %d bit DSA"
,
BN_num_bits
(
pkey
->
pkey
.
dsa
->
p
));
}
#endif
EVP_PKEY_free
(
pkey
);
}
X509_free
(
cert
);
}
/* The SSL API does not allow us to look at temporary RSA/DH keys,
* otherwise we should print their lengths too */
BIO_printf
(
bio_stdout
,
"
\n
"
);
}
}
int
main
(
int
argc
,
char
*
argv
[])
int
main
(
int
argc
,
char
*
argv
[])
...
@@ -162,12 +209,14 @@ int main(int argc, char *argv[])
...
@@ -162,12 +209,14 @@ int main(int argc, char *argv[])
SSL
*
c_ssl
,
*
s_ssl
;
SSL
*
c_ssl
,
*
s_ssl
;
int
number
=
1
,
reuse
=
0
;
int
number
=
1
,
reuse
=
0
;
long
bytes
=
1L
;
long
bytes
=
1L
;
SSL_CIPHER
*
ciph
;
#ifndef NO_DH
#ifndef NO_DH
DH
*
dh
;
DH
*
dh
;
int
dhe1024
=
0
,
dhe1024dsa
=
0
;
int
dhe1024
=
0
,
dhe1024dsa
=
0
;
#endif
#endif
int
no_dhe
=
0
;
int
no_dhe
=
0
;
int
print_time
=
0
;
clock_t
s_time
=
0
,
c_time
=
0
;
verbose
=
0
;
verbose
=
0
;
debug
=
0
;
debug
=
0
;
cipher
=
0
;
cipher
=
0
;
...
@@ -261,6 +310,10 @@ int main(int argc, char *argv[])
...
@@ -261,6 +310,10 @@ int main(int argc, char *argv[])
{
{
force
=
1
;
force
=
1
;
}
}
else
if
(
strcmp
(
*
argv
,
"-time"
)
==
0
)
{
print_time
=
1
;
}
else
else
{
{
fprintf
(
stderr
,
"unknown option %s
\n
"
,
*
argv
);
fprintf
(
stderr
,
"unknown option %s
\n
"
,
*
argv
);
...
@@ -279,15 +332,24 @@ bad:
...
@@ -279,15 +332,24 @@ bad:
if
(
!
ssl2
&&
!
ssl3
&&
!
tls1
&&
number
>
1
&&
!
reuse
&&
!
force
)
if
(
!
ssl2
&&
!
ssl3
&&
!
tls1
&&
number
>
1
&&
!
reuse
&&
!
force
)
{
{
fprintf
(
stderr
,
"This case cannot work. Use -f switch to perform "
fprintf
(
stderr
,
"This case cannot work. Use -f to perform "
"the test anyway
\n
"
"the test anyway (and
\n
-d to see what happens), "
"(and -d to see what happens, "
"or add one of -ssl2, -ssl3, -tls1, -reuse
\n
"
"and -bio_pair to really make it happen :-)
\n
"
"to avoid protocol mismatch.
\n
"
);
"or add one of -ssl2, -ssl3, -tls1, -reuse to "
"avoid protocol mismatch.
\n
"
);
exit
(
1
);
exit
(
1
);
}
}
if
(
print_time
)
{
if
(
!
bio_pair
)
{
fprintf
(
stderr
,
"Using BIO pair (-bio_pair)
\n
"
);
bio_pair
=
1
;
}
if
(
number
<
50
&&
!
force
)
fprintf
(
stderr
,
"Warning: For accurate timings, use more connections (e.g. -num 1000)
\n
"
);
}
/* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */
/* if (cipher == NULL) cipher=getenv("SSL_CIPHER"); */
SSL_library_init
();
SSL_library_init
();
...
@@ -405,21 +467,24 @@ bad:
...
@@ -405,21 +467,24 @@ bad:
{
{
if
(
!
reuse
)
SSL_set_session
(
c_ssl
,
NULL
);
if
(
!
reuse
)
SSL_set_session
(
c_ssl
,
NULL
);
if
(
bio_pair
)
if
(
bio_pair
)
ret
=
doit_biopair
(
s_ssl
,
c_ssl
,
bytes
);
ret
=
doit_biopair
(
s_ssl
,
c_ssl
,
bytes
,
&
s_time
,
&
c_time
);
else
else
ret
=
doit
(
s_ssl
,
c_ssl
,
bytes
);
ret
=
doit
(
s_ssl
,
c_ssl
,
bytes
);
}
}
if
(
!
verbose
)
if
(
!
verbose
)
{
{
ciph
=
SSL_get_current_cipher
(
c_ssl
);
print_details
(
c_ssl
,
""
);
BIO_printf
(
bio_stdout
,
"Protocol %s, cipher %s, %s
\n
"
,
SSL_get_version
(
c_ssl
),
SSL_CIPHER_get_version
(
ciph
),
SSL_CIPHER_get_name
(
ciph
));
}
}
if
((
number
>
1
)
||
(
bytes
>
1L
))
if
((
number
>
1
)
||
(
bytes
>
1L
))
BIO_printf
(
bio_stdout
,
"%d handshakes of %ld bytes done
\n
"
,
number
,
bytes
);
BIO_printf
(
bio_stdout
,
"%d handshakes of %ld bytes done
\n
"
,
number
,
bytes
);
if
(
print_time
)
{
BIO_printf
(
bio_stdout
,
"Approximate total server time: %6.2f s
\n
"
"Approximate total client time: %6.2f s
\n
"
,
(
double
)
s_time
/
CLOCKS_PER_SEC
,
(
double
)
c_time
/
CLOCKS_PER_SEC
);
}
SSL_free
(
s_ssl
);
SSL_free
(
s_ssl
);
SSL_free
(
c_ssl
);
SSL_free
(
c_ssl
);
...
@@ -438,12 +503,12 @@ end:
...
@@ -438,12 +503,12 @@ end:
EXIT
(
ret
);
EXIT
(
ret
);
}
}
int
doit_biopair
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
count
)
int
doit_biopair
(
SSL
*
s_ssl
,
SSL
*
c_ssl
,
long
count
,
clock_t
*
s_time
,
clock_t
*
c_time
)
{
{
long
cw_num
=
count
,
cr_num
=
count
,
sw_num
=
count
,
sr_num
=
count
;
long
cw_num
=
count
,
cr_num
=
count
,
sw_num
=
count
,
sr_num
=
count
;
BIO
*
s_ssl_bio
=
NULL
,
*
c_ssl_bio
=
NULL
;
BIO
*
s_ssl_bio
=
NULL
,
*
c_ssl_bio
=
NULL
;
BIO
*
server
=
NULL
,
*
server_io
=
NULL
,
*
client
=
NULL
,
*
client_io
=
NULL
;
BIO
*
server
=
NULL
,
*
server_io
=
NULL
,
*
client
=
NULL
,
*
client_io
=
NULL
;
SSL_CIPHER
*
ciph
;
int
ret
=
1
;
int
ret
=
1
;
size_t
bufsiz
=
256
;
/* small buffer for testing */
size_t
bufsiz
=
256
;
/* small buffer for testing */
...
@@ -516,6 +581,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -516,6 +581,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
MS_STATIC
char
cbuf
[
1024
*
8
];
MS_STATIC
char
cbuf
[
1024
*
8
];
int
i
,
r
;
int
i
,
r
;
clock_t
c_clock
=
clock
();
if
(
debug
)
if
(
debug
)
if
(
SSL_in_init
(
c_ssl
))
if
(
SSL_in_init
(
c_ssl
))
...
@@ -582,6 +648,16 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -582,6 +648,16 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
cr_num
-=
r
;
cr_num
-=
r
;
}
}
}
}
/* c_time and s_time increments will typically be very small
* (depending on machine speed and clock tick intervals),
* but sampling over a large number of connections should
* result in fairly accurate figures. We cannot guarantee
* a lot, however -- if each connection lasts for exactly
* one clock tick, it will be counted only for the client
* or only for the server or even not at all.
*/
*
c_time
+=
(
clock
()
-
c_clock
);
}
}
{
{
...
@@ -589,6 +665,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -589,6 +665,7 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
MS_STATIC
char
sbuf
[
1024
*
8
];
MS_STATIC
char
sbuf
[
1024
*
8
];
int
i
,
r
;
int
i
,
r
;
clock_t
s_clock
=
clock
();
if
(
debug
)
if
(
debug
)
if
(
SSL_in_init
(
s_ssl
))
if
(
SSL_in_init
(
s_ssl
))
...
@@ -652,6 +729,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -652,6 +729,8 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
sr_num
-=
r
;
sr_num
-=
r
;
}
}
}
}
*
s_time
+=
(
clock
()
-
s_clock
);
}
}
{
{
...
@@ -777,13 +856,9 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -777,13 +856,9 @@ int doit_biopair(SSL *s_ssl, SSL *c_ssl, long count)
}
}
while
(
cw_num
>
0
||
cr_num
>
0
||
sw_num
>
0
||
sr_num
>
0
);
while
(
cw_num
>
0
||
cr_num
>
0
||
sw_num
>
0
||
sr_num
>
0
);
ciph
=
SSL_get_current_cipher
(
c_ssl
);
if
(
verbose
)
if
(
verbose
)
fprintf
(
stdout
,
"DONE via BIO pair, protocol %s, cipher %s, %s
\n
"
,
print_details
(
c_ssl
,
"DONE via BIO pair: "
);
SSL_get_version
(
c_ssl
),
end:
SSL_CIPHER_get_version
(
ciph
),
SSL_CIPHER_get_name
(
ciph
));
end:
ret
=
0
;
ret
=
0
;
err:
err:
...
@@ -827,7 +902,6 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -827,7 +902,6 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
int
done
=
0
;
int
done
=
0
;
int
c_write
,
s_write
;
int
c_write
,
s_write
;
int
do_server
=
0
,
do_client
=
0
;
int
do_server
=
0
,
do_client
=
0
;
SSL_CIPHER
*
ciph
;
c_to_s
=
BIO_new
(
BIO_s_mem
());
c_to_s
=
BIO_new
(
BIO_s_mem
());
s_to_c
=
BIO_new
(
BIO_s_mem
());
s_to_c
=
BIO_new
(
BIO_s_mem
());
...
@@ -1077,12 +1151,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
...
@@ -1077,12 +1151,8 @@ int doit(SSL *s_ssl, SSL *c_ssl, long count)
if
((
done
&
S_DONE
)
&&
(
done
&
C_DONE
))
break
;
if
((
done
&
S_DONE
)
&&
(
done
&
C_DONE
))
break
;
}
}
ciph
=
SSL_get_current_cipher
(
c_ssl
);
if
(
verbose
)
if
(
verbose
)
fprintf
(
stdout
,
"DONE, protocol %s, cipher %s, %s
\n
"
,
print_details
(
c_ssl
,
"DONE: "
);
SSL_get_version
(
c_ssl
),
SSL_CIPHER_get_version
(
ciph
),
SSL_CIPHER_get_name
(
ciph
));
ret
=
0
;
ret
=
0
;
err:
err:
/* We have to set the BIO's to NULL otherwise they will be
/* We have to set the BIO's to NULL otherwise they will be
...
...
test/testssl
浏览文件 @
563f1503
...
@@ -66,7 +66,7 @@ echo test sslv2/sslv3 via BIO pair
...
@@ -66,7 +66,7 @@ echo test sslv2/sslv3 via BIO pair
echo test
sslv2/sslv3 w/o DHE via BIO pair
echo test
sslv2/sslv3 w/o DHE via BIO pair
./ssltest
-bio_pair
-no_dhe
||
exit
1
./ssltest
-bio_pair
-no_dhe
||
exit
1
echo test
sslv2/sslv3 with 1024bit DHE
echo test
sslv2/sslv3 with 1024bit DHE
via BIO pair
./ssltest
-bio_pair
-dhe1024dsa
-v
||
exit
1
./ssltest
-bio_pair
-dhe1024dsa
-v
||
exit
1
echo test
sslv2/sslv3 with server authentication
echo test
sslv2/sslv3 with server authentication
...
@@ -78,4 +78,9 @@ echo test sslv2/sslv3 with client authentication via BIO pair
...
@@ -78,4 +78,9 @@ echo test sslv2/sslv3 with client authentication via BIO pair
echo test
sslv2/sslv3 with both client and server authentication via BIO pair
echo test
sslv2/sslv3 with both client and server authentication via BIO pair
./ssltest
-bio_pair
-server_auth
-client_auth
-CApath
../certs
||
exit
1
./ssltest
-bio_pair
-server_auth
-client_auth
-CApath
../certs
||
exit
1
echo test
tls1 with 1024bit RSA, no DHE, multiple handshakes
./ssltest
-v
-bio_pair
-tls1
-cert
../apps/server2.pem
-no_dhe
-num
10
-f
-time
||
exit
1
echo test
tls1 with 1024bit RSA, 1024bit DHE, multiple handshakes
./ssltest
-v
-bio_pair
-tls1
-cert
../apps/server2.pem
-dhe1024dsa
-num
10
-f
-time
||
exit
1
exit
0
exit
0
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录