Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Third Party Openssl
提交
203b1cdf
T
Third Party Openssl
项目概览
OpenHarmony
/
Third Party Openssl
接近 2 年 前同步成功
通知
12
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看板
提交
203b1cdf
编写于
10月 27, 2016
作者:
M
Matt Caswell
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add a test for the supported_versions extension
Reviewed-by:
N
Rich Salz
<
rsalz@openssl.org
>
上级
619d8336
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
149 addition
and
0 deletion
+149
-0
test/recipes/70-test_sslversions.t
test/recipes/70-test_sslversions.t
+148
-0
util/TLSProxy/Message.pm
util/TLSProxy/Message.pm
+1
-0
未找到文件。
test/recipes/70-test_sslversions.t
0 → 100755
浏览文件 @
203b1cdf
#! /usr/bin/env perl
# Copyright 2015-2016 The OpenSSL Project Authors. All Rights Reserved.
#
# Licensed under the OpenSSL license (the "License"). You may not use
# this file except in compliance with the License. You can obtain a copy
# in the file LICENSE in the source distribution or at
# https://www.openssl.org/source/license.html
use
strict
;
use
OpenSSL::
Test
qw/:DEFAULT cmdstr srctop_file bldtop_dir/
;
use
OpenSSL::Test::
Utils
;
use
TLSProxy::
Proxy
;
use
File::
Temp
qw(tempfile)
;
use
constant
{
REVERSE_ORDER_VERSIONS
=>
1
,
UNRECOGNISED_VERSIONS
=>
2
,
NO_EXTENSION
=>
3
,
EMPTY_EXTENSION
=>
4
,
NO_TLS1_3
=>
5
};
my
$testtype
;
my
$test_name
=
"
test_sslversions
";
setup
(
$test_name
);
plan
skip_all
=>
"
TLSProxy isn't usable on $^O
"
if
$^O
=~
/^(VMS|MSWin32)$/
;
plan
skip_all
=>
"
$test_name
needs the dynamic engine feature enabled
"
if
disabled
("
engine
")
||
disabled
("
dynamic-engine
");
plan
skip_all
=>
"
$test_name
needs the sock feature enabled
"
if
disabled
("
sock
");
plan
skip_all
=>
"
$test_name
needs TLS1.3, TLS1.2 and TLS1.1 enabled
"
if
disabled
("
tls1_3
")
||
disabled
("
tls1_2
")
||
disabled
("
tls1_1
");
$ENV
{
OPENSSL_ia32cap
}
=
'
~0x200000200000000
';
my
$proxy
=
TLSProxy::
Proxy
->
new
(
undef
,
cmdstr
(
app
(["
openssl
"]),
display
=>
1
),
srctop_file
("
apps
",
"
server.pem
"),
(
!
$ENV
{
HARNESS_ACTIVE
}
||
$ENV
{
HARNESS_VERBOSE
})
);
#We're just testing various negative and unusual scenarios here. ssltest with
#02-protocol-version.conf should check all the various combinations of normal
#version neg
#Test 1: An empty supported_versions extension should not succeed
$testtype
=
EMPTY_EXTENSION
;
$proxy
->
filter
(
\
&modify_supported_versions_filter
);
$proxy
->
start
()
or
plan
skip_all
=>
"
Unable to start up Proxy for tests
";
plan
tests
=>
6
;
ok
(
TLSProxy::
Message
->
fail
(),
"
Empty supported versions
");
#Test 2: supported_versions extension with no recognised versions should not
#succeed
$proxy
->
clear
();
$testtype
=
UNRECOGNISED_VERSIONS
;
$proxy
->
start
();
ok
(
TLSProxy::
Message
->
fail
(),
"
No recognised versions
");
#Test 3: No supported versions extensions should succeed and select TLSv1.2
$proxy
->
clear
();
$testtype
=
NO_EXTENSION
;
$proxy
->
start
();
my
$record
=
pop
@
{
$proxy
->
record_list
};
ok
(
TLSProxy::
Message
->
success
()
&&
$record
->
version
()
==
TLSProxy::Record::
VERS_TLS_1_2
,
"
No supported versions extension
");
#Test 4: No supported versions extensions should fail if only TLS1.3 available
$proxy
->
clear
();
$proxy
->
serverflags
("
-tls1_3
");
$proxy
->
start
();
ok
(
TLSProxy::
Message
->
fail
(),
"
No supported versions extension (only TLS1.3)
");
#Test 5: supported versions extension with best version last should succeed
#and select TLSv1.3
$proxy
->
clear
();
$testtype
=
REVERSE_ORDER_VERSIONS
;
$proxy
->
start
();
$record
=
pop
@
{
$proxy
->
record_list
};
ok
(
TLSProxy::
Message
->
success
()
&&
$record
->
version
()
==
TLSProxy::Record::
VERS_TLS_1_3
,
"
Reverse order versions
");
#Test 6: no TLSv1.3 or TLSv1.2 version in supported versions extension, but
#TLSv1.1 and TLSv1.0 are present. Should just use TLSv1.1 and succeed
$proxy
->
clear
();
$testtype
=
NO_TLS1_3
;
$proxy
->
start
();
$record
=
pop
@
{
$proxy
->
record_list
};
ok
(
TLSProxy::
Message
->
success
()
&&
$record
->
version
()
==
TLSProxy::Record::
VERS_TLS_1_1
,
"
No TLS1.3 in supported versions extension
");
sub
modify_supported_versions_filter
{
my
$proxy
=
shift
;
# We're only interested in the initial ClientHello
if
(
$proxy
->
flight
!=
0
)
{
return
;
}
foreach
my
$message
(
@
{
$proxy
->
message_list
})
{
if
(
$message
->
mt
==
TLSProxy::Message::
MT_CLIENT_HELLO
)
{
my
$ext
;
if
(
$testtype
==
REVERSE_ORDER_VERSIONS
)
{
$ext
=
pack
"
C5
",
0x04
,
# Length
0x03
,
0x03
,
#TLSv1.2
0x03
,
0x04
;
#TLSv1.3
}
elsif
(
$testtype
==
UNRECOGNISED_VERSIONS
)
{
$ext
=
pack
"
C5
",
0x04
,
# Length
0x04
,
0x04
,
#Some unrecognised version
0x04
,
0x03
;
#Another unrecognised version
}
elsif
(
$testtype
==
NO_TLS1_3
)
{
$ext
=
pack
"
C5
",
0x04
,
# Length
0x03
,
0x02
,
#TLSv1.1
0x03
,
0x01
;
#TLSv1.0
}
if
(
$testtype
==
REVERSE_ORDER_VERSIONS
||
$testtype
==
UNRECOGNISED_VERSIONS
||
$testtype
==
NO_TLS1_3
)
{
$message
->
set_extension
(
TLSProxy::Message::
EXT_SUPPORTED_VERSIONS
,
$ext
);
}
elsif
(
$testtype
==
EMPTY_EXTENSION
)
{
$message
->
set_extension
(
TLSProxy::Message::
EXT_SUPPORTED_VERSIONS
,
"");
}
else
{
$message
->
delete_extension
(
TLSProxy::Message::
EXT_SUPPORTED_VERSIONS
);
}
$message
->
repack
();
}
}
}
util/TLSProxy/Message.pm
浏览文件 @
203b1cdf
...
...
@@ -62,6 +62,7 @@ use constant {
EXT_ENCRYPT_THEN_MAC
=>
22
,
EXT_EXTENDED_MASTER_SECRET
=>
23
,
EXT_SESSION_TICKET
=>
35
,
EXT_SUPPORTED_VERSIONS
=>
43
,
# This extension does not exist and isn't recognised by OpenSSL.
# We use it to test handling of duplicate extensions.
EXT_DUPLICATE_EXTENSION
=>
1234
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录