echspec 0.0.8 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/README.md +17 -11
- data/lib/echspec/cli/grease.rb +1 -1
- data/lib/echspec/log.rb +0 -4
- data/lib/echspec/spec/{7-5.rb → 7-3.rb} +7 -11
- data/lib/echspec/spec/7.1-11.rb +61 -0
- data/lib/echspec/spec/7.1-14.2.1.rb +0 -20
- data/lib/echspec/spec/7.1.1-2.rb +130 -12
- data/lib/echspec/spec/7.1.1-5.rb +8 -14
- data/lib/echspec/spec/7.1.1-7.rb +152 -0
- data/lib/echspec/spec/7.2-1.rb +1 -4
- data/lib/echspec/spec.rb +21 -1
- data/lib/echspec/tls13_client.rb +21 -17
- data/lib/echspec/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8e07ddc58f010362c3d1cbf70aeaa0b89fb70c0ae6cad75f3c53dd4e64555986
|
|
4
|
+
data.tar.gz: 91f26f14e3520cc7761eb20b2f640a42ae22c2302c1372e5a59fec2ff3230a09
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 72bf8ce3e68f61c9a9ef325b004024453807a876cf2a4c654eb468041a3e44f07f555a9b9c04086451a9dc5ffa5b3021cf27dc43bc7279eb8b0fa6056623b8aa
|
|
7
|
+
data.tar.gz: b09ca3150563ca2745009ffc1baf63783ae6faa9da2a906ef103d8c7025c98dec78932ed39c74d5d5d986cab7967d339ae60cd3de25d7e7bbc565c87493ce46d
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
4.
|
|
1
|
+
4.1-dev
|
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -62,19 +62,23 @@ TLS Encrypted Client Hello Server
|
|
|
62
62
|
✔ MUST abort with an "illegal_parameter" alert, if any extension is referenced in OuterExtensions more than once. [5.1-10]
|
|
63
63
|
✔ MUST abort with an "illegal_parameter" alert, if "encrypted_client_hello" is referenced in OuterExtensions. [5.1-10]
|
|
64
64
|
✔ MUST abort with an "illegal_parameter" alert, if the extensions in ClientHelloOuter corresponding to those in OuterExtensions do not occur in the same order. [5.1-10]
|
|
65
|
-
✔ MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloInner. [7-
|
|
66
|
-
x MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloOuter. [7-
|
|
65
|
+
✔ MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloInner. [7-3]
|
|
66
|
+
x MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloOuter. [7-3]
|
|
67
67
|
✔ MUST abort with an "illegal_parameter" alert, if ClientHelloInner offers TLS 1.2 or below. [7.1-11]
|
|
68
|
+
✔ MUST abort with an "illegal_parameter" alert, if ClientHelloInner does not contain the "encrypted_client_hello" extension. [7.1-11]
|
|
68
69
|
✔ MUST include the "encrypted_client_hello" extension in its EncryptedExtensions with the "retry_configs" field set to one or more ECHConfig. [7.1-14.2.1]
|
|
69
70
|
✔ MUST abort with a "missing_extension" alert, if 2nd ClientHelloOuter does not contains the "encrypted_client_hello" extension. [7.1.1-2]
|
|
70
|
-
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is empty. [7.1.1-2]
|
|
71
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is not empty. [7.1.1-2]
|
|
72
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" config_id is changed. [7.1.1-2]
|
|
73
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" cipher_suite is changed. [7.1.1-2]
|
|
71
74
|
✔ MUST abort with a "decrypt_error" alert, if fails to decrypt 2nd ClientHelloOuter. [7.1.1-5]
|
|
75
|
+
✔ MUST include the "encrypted_client_hello" extension in its EncryptedExtensions with the "retry_configs" field set to one or more ECHConfig, if it rejected ECH with HelloRetryRequest. [7.1.1-7]
|
|
72
76
|
✔ MUST confirm ECH acceptance in ServerHello, if it confirmed ECH acceptance in HelloRetryRequest. [7.2-1]
|
|
73
77
|
|
|
74
78
|
Failures:
|
|
75
79
|
|
|
76
|
-
1) MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloOuter. [7-
|
|
77
|
-
https://datatracker.ietf.org/doc/html/rfc9849#section-7-
|
|
80
|
+
1) MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloOuter. [7-3]
|
|
81
|
+
https://datatracker.ietf.org/doc/html/rfc9849#section-7-3
|
|
78
82
|
did not send expected alert: illegal_parameter
|
|
79
83
|
|
|
80
84
|
1 failure
|
|
@@ -107,14 +111,16 @@ To run only specific test SECTIONS, use the `-s` option:
|
|
|
107
111
|
$ echspec run -f fixtures/echconfigs.pem -p 4433 -n -s 7.1.1-2,7.1.1-5 localhost
|
|
108
112
|
TLS Encrypted Client Hello Server
|
|
109
113
|
✔ MUST abort with a "missing_extension" alert, if 2nd ClientHelloOuter does not contains the "encrypted_client_hello" extension. [7.1.1-2]
|
|
110
|
-
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is empty. [7.1.1-2]
|
|
114
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is not empty. [7.1.1-2]
|
|
115
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" config_id is changed. [7.1.1-2]
|
|
116
|
+
✔ MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" cipher_suite is changed. [7.1.1-2]
|
|
111
117
|
✔ MUST abort with a "decrypt_error" alert, if fails to decrypt 2nd ClientHelloOuter. [7.1.1-5]
|
|
112
118
|
```
|
|
113
119
|
|
|
114
120
|
Using the `-v` or `--verbose` option provides a message stack if an error occurs. The message stack is formatted as JSON.
|
|
115
121
|
|
|
116
122
|
```sh-session
|
|
117
|
-
$ echspec run -s 7-
|
|
123
|
+
$ echspec run -s 7-3 -v research.cloudflare.com 2>&1 > /dev/null | jq .
|
|
118
124
|
````
|
|
119
125
|
|
|
120
126
|
<details>
|
|
@@ -289,18 +295,18 @@ $ echspec run -s 7-5 -v research.cloudflare.com 2>&1 > /dev/null | jq .
|
|
|
289
295
|
|
|
290
296
|
### gen_configs
|
|
291
297
|
|
|
292
|
-
You can generate an ECHConfig PEM file the following:
|
|
298
|
+
You can generate an ECHConfig PEM file, in the format defined in [RFC 9934](https://datatracker.ietf.org/doc/html/rfc9934), the following:
|
|
293
299
|
|
|
294
300
|
```sh-session
|
|
295
301
|
$ echspec gen_configs echconfigs.pem
|
|
296
302
|
```
|
|
297
303
|
```
|
|
298
304
|
-----BEGIN PRIVATE KEY-----
|
|
299
|
-
|
|
305
|
+
MC4CAQAwBQYDK2VuBCIEIJhqOprwiCzv3taJ6OfqCt9IDkso/9z8rShp6D+NbMpg
|
|
300
306
|
-----END PRIVATE KEY-----
|
|
301
307
|
-----BEGIN ECHCONFIG-----
|
|
302
|
-
|
|
303
|
-
|
|
308
|
+
ADz+DQA4ewAgACB/trzH8nCxAxVnGy4ZiFuTYKOtLw0X7FO8CQRbU8eZSAAEAAEA
|
|
309
|
+
ASAJbG9jYWxob3N0AAA=
|
|
304
310
|
-----END ECHCONFIG-----
|
|
305
311
|
```
|
|
306
312
|
|
data/lib/echspec/cli/grease.rb
CHANGED
|
@@ -8,7 +8,7 @@ module EchSpec
|
|
|
8
8
|
|
|
9
9
|
TTTLS13::Logging.logger.level = Logger::WARN
|
|
10
10
|
socket = TCPSocket.new(hostname, port)
|
|
11
|
-
recv = TLS13Client.send_ch_with_greased_ech(socket, hostname)
|
|
11
|
+
recv = TLS13Client.send_ch_with_greased_ech(socket, hostname, Log::MessageStack.new)
|
|
12
12
|
ex = recv.extensions[TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO]
|
|
13
13
|
|
|
14
14
|
if ex.nil? || ex.retry_configs.nil? || ex.retry_configs.empty?
|
data/lib/echspec/log.rb
CHANGED
|
@@ -17,7 +17,6 @@ module EchSpec
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# rubocop: disable Metrics/CyclomaticComplexity
|
|
20
|
-
# rubocop: disable Metrics/PerceivedComplexity
|
|
21
20
|
def self.msg2name(msg)
|
|
22
21
|
case msg
|
|
23
22
|
in TTTLS13::Message::ClientHello if msg.ch_inner?
|
|
@@ -49,10 +48,8 @@ module EchSpec
|
|
|
49
48
|
end
|
|
50
49
|
end
|
|
51
50
|
# rubocop: enable Metrics/CyclomaticComplexity
|
|
52
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
|
53
51
|
|
|
54
52
|
# rubocop: disable Metrics/CyclomaticComplexity
|
|
55
|
-
# rubocop: disable Metrics/PerceivedComplexity
|
|
56
53
|
def self.obj2json(obj)
|
|
57
54
|
case obj
|
|
58
55
|
in OpenSSL::X509::Certificate
|
|
@@ -83,7 +80,6 @@ module EchSpec
|
|
|
83
80
|
end
|
|
84
81
|
end
|
|
85
82
|
# rubocop: enable Metrics/CyclomaticComplexity
|
|
86
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
|
87
83
|
end
|
|
88
84
|
end
|
|
89
85
|
end
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
module EchSpec
|
|
2
2
|
module Spec
|
|
3
|
-
class
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
# A shared mode server which receives a ClientHello with
|
|
7
|
-
# ECHClientHello.type of inner MUST abort with an "illegal_parameter"
|
|
8
|
-
# alert, because such a ClientHello should never be received directly
|
|
9
|
-
# from the network.
|
|
3
|
+
class Spec7_3 < WithSocket
|
|
4
|
+
# If ECHClientHello.type is not a valid ECHClientHelloType, then the
|
|
5
|
+
# server MUST abort with an "illegal_parameter" alert.
|
|
10
6
|
#
|
|
11
|
-
# https://datatracker.ietf.org/doc/html/rfc9849#section-7-
|
|
7
|
+
# https://datatracker.ietf.org/doc/html/rfc9849#section-7-3
|
|
12
8
|
|
|
13
9
|
# @return [EchSpec::SpecGroup]
|
|
14
10
|
def self.spec_group
|
|
15
11
|
SpecGroup.new(
|
|
16
|
-
'7-
|
|
12
|
+
'7-3',
|
|
17
13
|
[
|
|
18
14
|
SpecCase.new(
|
|
19
15
|
'MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloInner.',
|
|
@@ -33,7 +29,7 @@ module EchSpec
|
|
|
33
29
|
#
|
|
34
30
|
# @return [EchSpec::Ok | Err]
|
|
35
31
|
def self.validate_illegal_inner_ech_type(hostname, port, ech_config)
|
|
36
|
-
|
|
32
|
+
Spec7_3.new.do_validate_illegal_ech_type(
|
|
37
33
|
hostname,
|
|
38
34
|
port,
|
|
39
35
|
ech_config,
|
|
@@ -47,7 +43,7 @@ module EchSpec
|
|
|
47
43
|
#
|
|
48
44
|
# @return [EchSpec::Ok | Err]
|
|
49
45
|
def self.validate_illegal_outer_ech_type(hostname, port, ech_config)
|
|
50
|
-
|
|
46
|
+
Spec7_3.new.do_validate_illegal_ech_type(
|
|
51
47
|
hostname,
|
|
52
48
|
port,
|
|
53
49
|
ech_config,
|
data/lib/echspec/spec/7.1-11.rb
CHANGED
|
@@ -17,6 +17,10 @@ module EchSpec
|
|
|
17
17
|
SpecCase.new(
|
|
18
18
|
'MUST abort with an "illegal_parameter" alert, if ClientHelloInner offers TLS 1.2 or below.',
|
|
19
19
|
method(:validate_ech_with_tls12)
|
|
20
|
+
),
|
|
21
|
+
SpecCase.new(
|
|
22
|
+
'MUST abort with an "illegal_parameter" alert, if ClientHelloInner does not contain the "encrypted_client_hello" extension.',
|
|
23
|
+
method(:validate_ch_inner_without_ech)
|
|
20
24
|
)
|
|
21
25
|
]
|
|
22
26
|
)
|
|
@@ -46,6 +50,30 @@ module EchSpec
|
|
|
46
50
|
end
|
|
47
51
|
end
|
|
48
52
|
|
|
53
|
+
# @param hostname [String]
|
|
54
|
+
# @param port [Integer]
|
|
55
|
+
# @param ech_config [ECHConfig]
|
|
56
|
+
#
|
|
57
|
+
# @return [EchSpec::Ok | Err]
|
|
58
|
+
def self.validate_ch_inner_without_ech(hostname, port, ech_config)
|
|
59
|
+
Spec7_1_11.new.do_validate_ch_inner_without_ech(hostname, port, ech_config)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# @param hostname [String]
|
|
63
|
+
# @param port [Integer]
|
|
64
|
+
# @param ech_config [ECHConfig]
|
|
65
|
+
#
|
|
66
|
+
# @return [EchSpec::Ok | Err]
|
|
67
|
+
def do_validate_ch_inner_without_ech(hostname, port, ech_config)
|
|
68
|
+
with_socket(hostname, port) do |socket|
|
|
69
|
+
recv = send_ch_inner_without_ech(socket, hostname, ech_config)
|
|
70
|
+
return Err.new('did not send expected alert: illegal_parameter', message_stack) \
|
|
71
|
+
unless Spec.expect_alert(recv, :illegal_parameter)
|
|
72
|
+
|
|
73
|
+
Ok.new(nil)
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
|
|
49
77
|
# rubocop: disable Metrics/MethodLength
|
|
50
78
|
def send_ch_ech_with_tls12(socket, hostname, ech_config)
|
|
51
79
|
conn = TLS13Client::Connection.new(socket, :client)
|
|
@@ -88,6 +116,39 @@ module EchSpec
|
|
|
88
116
|
recv
|
|
89
117
|
end
|
|
90
118
|
# rubocop: enable Metrics/MethodLength
|
|
119
|
+
|
|
120
|
+
def send_ch_inner_without_ech(socket, hostname, ech_config)
|
|
121
|
+
conn = TLS13Client::Connection.new(socket, :client)
|
|
122
|
+
exs, = TLS13Client.gen_ch_extensions(hostname)
|
|
123
|
+
# ClientHelloInner without "encrypted_client_hello"
|
|
124
|
+
inner = TTTLS13::Message::ClientHello.new(
|
|
125
|
+
cipher_suites: TTTLS13::CipherSuites.new(
|
|
126
|
+
[
|
|
127
|
+
TTTLS13::CipherSuite::TLS_AES_256_GCM_SHA384,
|
|
128
|
+
TTTLS13::CipherSuite::TLS_CHACHA20_POLY1305_SHA256,
|
|
129
|
+
TTTLS13::CipherSuite::TLS_AES_128_GCM_SHA256
|
|
130
|
+
]
|
|
131
|
+
),
|
|
132
|
+
extensions: exs
|
|
133
|
+
)
|
|
134
|
+
|
|
135
|
+
selector = proc { |x| TLS13Client.select_ech_hpke_cipher_suite(x) }
|
|
136
|
+
ch, inner, = TTTLS13::Ech.offer_ech(inner, ech_config, selector)
|
|
137
|
+
conn.send_record(
|
|
138
|
+
TTTLS13::Message::Record.new(
|
|
139
|
+
type: TTTLS13::Message::ContentType::HANDSHAKE,
|
|
140
|
+
messages: [ch],
|
|
141
|
+
cipher: TTTLS13::Cryptograph::Passer.new
|
|
142
|
+
)
|
|
143
|
+
)
|
|
144
|
+
@stack << inner
|
|
145
|
+
@stack << ch
|
|
146
|
+
|
|
147
|
+
recv, = conn.recv_message(TTTLS13::Cryptograph::Passer.new)
|
|
148
|
+
@stack << recv
|
|
149
|
+
|
|
150
|
+
recv
|
|
151
|
+
end
|
|
91
152
|
end
|
|
92
153
|
end
|
|
93
154
|
end
|
|
@@ -49,26 +49,6 @@ module EchSpec
|
|
|
49
49
|
Err.new('EncryptedExtensions "encrypted_client_hello" extension could not be decoded', message_stack)
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
|
-
|
|
53
|
-
# @param ee [TTTLS13::Message::EncryptedExtensions]
|
|
54
|
-
#
|
|
55
|
-
# @return [EchSpec::Ok | Err]
|
|
56
|
-
def validate_ee_ech(ee)
|
|
57
|
-
# Extensions#[] returns nil for UnknownExtension, so use super_fetch.
|
|
58
|
-
ex = ee.extensions.super_fetch(TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO, nil)
|
|
59
|
-
case ex
|
|
60
|
-
in TTTLS13::Message::Extension::ECHEncryptedExtensions
|
|
61
|
-
return Err.new('EncryptedExtensions "encrypted_client_hello" extension did not have "retry_configs"', message_stack) \
|
|
62
|
-
if ex.retry_configs.nil? || ex.retry_configs.empty?
|
|
63
|
-
|
|
64
|
-
Ok.new(nil)
|
|
65
|
-
in nil
|
|
66
|
-
Err.new('EncryptedExtensions did not include "encrypted_client_hello" extension', message_stack)
|
|
67
|
-
in TTTLS13::Message::Extension::UnknownExtension
|
|
68
|
-
# tttls1.3 deserializes the extension whose length field mismatches as UnknownExtension
|
|
69
|
-
Err.new('EncryptedExtensions "encrypted_client_hello" extension could not be decoded', message_stack)
|
|
70
|
-
end
|
|
71
|
-
end
|
|
72
52
|
end
|
|
73
53
|
end
|
|
74
54
|
end
|
data/lib/echspec/spec/7.1.1-2.rb
CHANGED
|
@@ -21,8 +21,16 @@ module EchSpec
|
|
|
21
21
|
method(:validate_2nd_ch_missing_ech)
|
|
22
22
|
),
|
|
23
23
|
SpecCase.new(
|
|
24
|
-
'MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is empty.',
|
|
24
|
+
'MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" enc is not empty.',
|
|
25
25
|
method(:validate_2nd_ch_unchanged_ech)
|
|
26
|
+
),
|
|
27
|
+
SpecCase.new(
|
|
28
|
+
'MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" config_id is changed.',
|
|
29
|
+
method(:validate_2nd_ch_changed_config_id)
|
|
30
|
+
),
|
|
31
|
+
SpecCase.new(
|
|
32
|
+
'MUST abort with an "illegal_parameter" alert, if 2nd ClientHelloOuter "encrypted_client_hello" cipher_suite is changed.',
|
|
33
|
+
method(:validate_2nd_ch_changed_cipher_suite)
|
|
26
34
|
)
|
|
27
35
|
]
|
|
28
36
|
)
|
|
@@ -76,6 +84,54 @@ module EchSpec
|
|
|
76
84
|
end
|
|
77
85
|
end
|
|
78
86
|
|
|
87
|
+
# @param hostname [String]
|
|
88
|
+
# @param port [Integer]
|
|
89
|
+
# @param ech_config [ECHConfig]
|
|
90
|
+
#
|
|
91
|
+
# @return [EchSpec::Ok | Err]
|
|
92
|
+
def self.validate_2nd_ch_changed_config_id(hostname, port, ech_config)
|
|
93
|
+
Spec7_1_1_2.new.do_validate_2nd_ch_changed_config_id(hostname, port, ech_config)
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# @param hostname [String]
|
|
97
|
+
# @param port [Integer]
|
|
98
|
+
# @param ech_config [ECHConfig]
|
|
99
|
+
#
|
|
100
|
+
# @return [EchSpec::Ok | Err]
|
|
101
|
+
def do_validate_2nd_ch_changed_config_id(hostname, port, ech_config)
|
|
102
|
+
with_socket(hostname, port) do |socket|
|
|
103
|
+
recv = send_2nd_ch_changed_config_id(socket, hostname, ech_config)
|
|
104
|
+
return Err.new('did not send expected alert: illegal_parameter', message_stack) \
|
|
105
|
+
unless Spec.expect_alert(recv, :illegal_parameter)
|
|
106
|
+
|
|
107
|
+
Ok.new(nil)
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
# @param hostname [String]
|
|
112
|
+
# @param port [Integer]
|
|
113
|
+
# @param ech_config [ECHConfig]
|
|
114
|
+
#
|
|
115
|
+
# @return [EchSpec::Ok | Err]
|
|
116
|
+
def self.validate_2nd_ch_changed_cipher_suite(hostname, port, ech_config)
|
|
117
|
+
Spec7_1_1_2.new.do_validate_2nd_ch_changed_cipher_suite(hostname, port, ech_config)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# @param hostname [String]
|
|
121
|
+
# @param port [Integer]
|
|
122
|
+
# @param ech_config [ECHConfig]
|
|
123
|
+
#
|
|
124
|
+
# @return [EchSpec::Ok | Err]
|
|
125
|
+
def do_validate_2nd_ch_changed_cipher_suite(hostname, port, ech_config)
|
|
126
|
+
with_socket(hostname, port) do |socket|
|
|
127
|
+
recv = send_2nd_ch_changed_cipher_suite(socket, hostname, ech_config)
|
|
128
|
+
return Err.new('did not send expected alert: illegal_parameter', message_stack) \
|
|
129
|
+
unless Spec.expect_alert(recv, :illegal_parameter)
|
|
130
|
+
|
|
131
|
+
Ok.new(nil)
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
|
|
79
135
|
def send_2nd_ch_missing_ech(socket, hostname, ech_config)
|
|
80
136
|
conn, _inner1, ch1, hrr, = TLS13Client.recv_hrr(socket, hostname, ech_config, @stack)
|
|
81
137
|
# send 2nd ClientHello without ech
|
|
@@ -98,12 +154,7 @@ module EchSpec
|
|
|
98
154
|
)
|
|
99
155
|
@stack << ch
|
|
100
156
|
|
|
101
|
-
|
|
102
|
-
@stack << recv
|
|
103
|
-
|
|
104
|
-
recv, = conn.recv_message(TTTLS13::Cryptograph::Passer.new) \
|
|
105
|
-
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
106
|
-
recv
|
|
157
|
+
conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
107
158
|
end
|
|
108
159
|
|
|
109
160
|
def send_2nd_ch_unchanged_ech(socket, hostname, ech_config)
|
|
@@ -130,13 +181,80 @@ module EchSpec
|
|
|
130
181
|
@stack << inner1
|
|
131
182
|
@stack << ch
|
|
132
183
|
|
|
133
|
-
|
|
134
|
-
|
|
184
|
+
conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def send_2nd_ch_changed_config_id(socket, hostname, ech_config)
|
|
188
|
+
conn, inner1, ch1, hrr, = TLS13Client.recv_hrr(socket, hostname, ech_config, @stack)
|
|
189
|
+
# send 2nd ClientHello with changed config_id
|
|
190
|
+
ech1 = ch1.extensions[TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO]
|
|
191
|
+
new_exs = TLS13Client.gen_newch_extensions(ch1, hrr)
|
|
192
|
+
new_exs[TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO] =
|
|
193
|
+
TTTLS13::Message::Extension::ECHClientHello.new_outer(
|
|
194
|
+
cipher_suite: ech1.cipher_suite,
|
|
195
|
+
config_id: (ech1.config_id + 1) % 256,
|
|
196
|
+
enc: '',
|
|
197
|
+
payload: ech1.payload
|
|
198
|
+
)
|
|
199
|
+
ch = TTTLS13::Message::ClientHello.new(
|
|
200
|
+
legacy_version: ch1.legacy_version,
|
|
201
|
+
random: ch1.random,
|
|
202
|
+
legacy_session_id: ch1.legacy_session_id,
|
|
203
|
+
cipher_suites: ch1.cipher_suites,
|
|
204
|
+
legacy_compression_methods: ch1.legacy_compression_methods,
|
|
205
|
+
extensions: new_exs
|
|
206
|
+
)
|
|
207
|
+
conn.send_record(
|
|
208
|
+
TTTLS13::Message::Record.new(
|
|
209
|
+
type: TTTLS13::Message::ContentType::HANDSHAKE,
|
|
210
|
+
messages: [ch],
|
|
211
|
+
cipher: TTTLS13::Cryptograph::Passer.new
|
|
212
|
+
)
|
|
213
|
+
)
|
|
214
|
+
@stack << inner1
|
|
215
|
+
@stack << ch
|
|
216
|
+
|
|
217
|
+
conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
# rubocop: disable Metrics/MethodLength
|
|
221
|
+
def send_2nd_ch_changed_cipher_suite(socket, hostname, ech_config)
|
|
222
|
+
conn, inner1, ch1, hrr, = TLS13Client.recv_hrr(socket, hostname, ech_config, @stack)
|
|
223
|
+
# send 2nd ClientHello with changed cipher_suite
|
|
224
|
+
ech1 = ch1.extensions[TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO]
|
|
225
|
+
aead_id = ech1.cipher_suite.aead_id.uint16 == HPKE::AES_128_GCM ? HPKE::AES_256_GCM : HPKE::AES_128_GCM
|
|
226
|
+
new_exs = TLS13Client.gen_newch_extensions(ch1, hrr)
|
|
227
|
+
new_exs[TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO] =
|
|
228
|
+
TTTLS13::Message::Extension::ECHClientHello.new_outer(
|
|
229
|
+
cipher_suite: ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite.new(
|
|
230
|
+
ech1.cipher_suite.kdf_id,
|
|
231
|
+
ECHConfig::ECHConfigContents::HpkeKeyConfig::HpkeSymmetricCipherSuite::HpkeAeadId.new(aead_id)
|
|
232
|
+
),
|
|
233
|
+
config_id: ech1.config_id,
|
|
234
|
+
enc: '',
|
|
235
|
+
payload: ech1.payload
|
|
236
|
+
)
|
|
237
|
+
ch = TTTLS13::Message::ClientHello.new(
|
|
238
|
+
legacy_version: ch1.legacy_version,
|
|
239
|
+
random: ch1.random,
|
|
240
|
+
legacy_session_id: ch1.legacy_session_id,
|
|
241
|
+
cipher_suites: ch1.cipher_suites,
|
|
242
|
+
legacy_compression_methods: ch1.legacy_compression_methods,
|
|
243
|
+
extensions: new_exs
|
|
244
|
+
)
|
|
245
|
+
conn.send_record(
|
|
246
|
+
TTTLS13::Message::Record.new(
|
|
247
|
+
type: TTTLS13::Message::ContentType::HANDSHAKE,
|
|
248
|
+
messages: [ch],
|
|
249
|
+
cipher: TTTLS13::Cryptograph::Passer.new
|
|
250
|
+
)
|
|
251
|
+
)
|
|
252
|
+
@stack << inner1
|
|
253
|
+
@stack << ch
|
|
135
254
|
|
|
136
|
-
|
|
137
|
-
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
138
|
-
recv
|
|
255
|
+
conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
139
256
|
end
|
|
257
|
+
# rubocop: enable Metrics/MethodLength
|
|
140
258
|
end
|
|
141
259
|
end
|
|
142
260
|
end
|
data/lib/echspec/spec/7.1.1-5.rb
CHANGED
|
@@ -48,16 +48,15 @@ module EchSpec
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
def send_2nd_ch_with_undecryptable_ech(socket, hostname, ech_config)
|
|
51
|
-
conn,
|
|
51
|
+
conn, inner1, _ch1, hrr, ech_state = TLS13Client.recv_hrr(socket, hostname, ech_config, @stack)
|
|
52
52
|
# send 2nd ClientHello with undecryptable ech
|
|
53
|
-
new_exs = TLS13Client.gen_newch_extensions(ch1, hrr)
|
|
54
53
|
inner = TTTLS13::Message::ClientHello.new(
|
|
55
|
-
legacy_version:
|
|
56
|
-
random:
|
|
57
|
-
legacy_session_id:
|
|
58
|
-
cipher_suites:
|
|
59
|
-
legacy_compression_methods:
|
|
60
|
-
extensions:
|
|
54
|
+
legacy_version: inner1.legacy_version,
|
|
55
|
+
random: inner1.random,
|
|
56
|
+
legacy_session_id: inner1.legacy_session_id,
|
|
57
|
+
cipher_suites: inner1.cipher_suites,
|
|
58
|
+
legacy_compression_methods: inner1.legacy_compression_methods,
|
|
59
|
+
extensions: TLS13Client.gen_newch_extensions(inner1, hrr)
|
|
61
60
|
)
|
|
62
61
|
ech_state.ctx.increment_seq # invalidly increment of the sequence number
|
|
63
62
|
ch, inner = TTTLS13::Ech.offer_new_ech(inner, ech_state)
|
|
@@ -71,12 +70,7 @@ module EchSpec
|
|
|
71
70
|
@stack << inner
|
|
72
71
|
@stack << ch
|
|
73
72
|
|
|
74
|
-
|
|
75
|
-
@stack << recv
|
|
76
|
-
|
|
77
|
-
recv, = conn.recv_message(TTTLS13::Cryptograph::Passer.new) \
|
|
78
|
-
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
79
|
-
recv
|
|
73
|
+
conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
80
74
|
end
|
|
81
75
|
end
|
|
82
76
|
end
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
module EchSpec
|
|
2
|
+
module Spec
|
|
3
|
+
class Spec7_1_1_7 < WithSocket
|
|
4
|
+
# If the client-facing server rejected ECH, or if the first ClientHello
|
|
5
|
+
# did not include an "encrypted_client_hello" extension, the client-
|
|
6
|
+
# facing server proceeds with the connection as usual. The server does
|
|
7
|
+
# not decrypt the second ClientHello's ECHClientHello.payload value, if
|
|
8
|
+
# there is one. Moreover, if the server is configured with any
|
|
9
|
+
# ECHConfigs, it MUST include the "encrypted_client_hello" extension in
|
|
10
|
+
# its EncryptedExtensions with the "retry_configs" field set to one or
|
|
11
|
+
# more ECHConfig structures with up-to-date keys, as described in
|
|
12
|
+
# Section 7.1.
|
|
13
|
+
#
|
|
14
|
+
# https://datatracker.ietf.org/doc/html/rfc9849#section-7.1.1-7
|
|
15
|
+
|
|
16
|
+
# @return [EchSpec::SpecGroup]
|
|
17
|
+
def self.spec_group
|
|
18
|
+
SpecGroup.new(
|
|
19
|
+
'7.1.1-7',
|
|
20
|
+
[
|
|
21
|
+
SpecCase.new(
|
|
22
|
+
'MUST include the "encrypted_client_hello" extension in its EncryptedExtensions with the "retry_configs" field set to one or more ECHConfig, if it rejected ECH with HelloRetryRequest.',
|
|
23
|
+
method(:validate_ee_retry_configs_after_hrr)
|
|
24
|
+
)
|
|
25
|
+
]
|
|
26
|
+
)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# @param hostname [String]
|
|
30
|
+
# @param port [Integer]
|
|
31
|
+
# @param _ [ECHConfig]
|
|
32
|
+
#
|
|
33
|
+
# @return [EchSpec::Ok | Err]
|
|
34
|
+
def self.validate_ee_retry_configs_after_hrr(hostname, port, _)
|
|
35
|
+
Spec7_1_1_7.new.do_validate_ee_retry_configs_after_hrr(hostname, port)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# @param hostname [String]
|
|
39
|
+
# @param port [Integer]
|
|
40
|
+
#
|
|
41
|
+
# @return [EchSpec::Ok | Err]
|
|
42
|
+
def do_validate_ee_retry_configs_after_hrr(hostname, port)
|
|
43
|
+
with_socket(hostname, port) do |socket|
|
|
44
|
+
recv = send_2nd_ch_with_greased_ech(socket, hostname)
|
|
45
|
+
validate_ee_ech(recv)
|
|
46
|
+
rescue ECHConfig::DecodeError
|
|
47
|
+
Err.new('EncryptedExtensions "encrypted_client_hello" extension could not be decoded', message_stack)
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
# rubocop: disable Metrics/AbcSize
|
|
52
|
+
# rubocop: disable Metrics/MethodLength
|
|
53
|
+
def send_2nd_ch_with_greased_ech(socket, hostname)
|
|
54
|
+
# send 1st ClientHello with greased ech
|
|
55
|
+
conn = TLS13Client::Connection.new(socket, :client)
|
|
56
|
+
inner_ech = TTTLS13::Message::Extension::ECHClientHello.new_inner
|
|
57
|
+
exs, = TLS13Client.gen_ch_extensions(hostname)
|
|
58
|
+
# for HRR
|
|
59
|
+
key_share = TTTLS13::Message::Extension::KeyShare.new(
|
|
60
|
+
msg_type: TTTLS13::Message::HandshakeType::CLIENT_HELLO,
|
|
61
|
+
key_share_entry: [] # empty client_shares vector
|
|
62
|
+
)
|
|
63
|
+
exs[TTTLS13::Message::ExtensionType::KEY_SHARE] = key_share
|
|
64
|
+
inner = TTTLS13::Message::ClientHello.new(
|
|
65
|
+
cipher_suites: TTTLS13::CipherSuites.new(
|
|
66
|
+
[
|
|
67
|
+
TTTLS13::CipherSuite::TLS_AES_256_GCM_SHA384,
|
|
68
|
+
TTTLS13::CipherSuite::TLS_CHACHA20_POLY1305_SHA256,
|
|
69
|
+
TTTLS13::CipherSuite::TLS_AES_128_GCM_SHA256
|
|
70
|
+
]
|
|
71
|
+
),
|
|
72
|
+
extensions: exs.merge(
|
|
73
|
+
TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => inner_ech
|
|
74
|
+
)
|
|
75
|
+
)
|
|
76
|
+
@stack << inner
|
|
77
|
+
|
|
78
|
+
ch1 = TTTLS13::Ech.new_greased_ch(inner, TTTLS13::Ech.new_grease_ech)
|
|
79
|
+
conn.send_record(
|
|
80
|
+
TTTLS13::Message::Record.new(
|
|
81
|
+
type: TTTLS13::Message::ContentType::HANDSHAKE,
|
|
82
|
+
messages: [ch1],
|
|
83
|
+
cipher: TTTLS13::Cryptograph::Passer.new
|
|
84
|
+
)
|
|
85
|
+
)
|
|
86
|
+
@stack << ch1
|
|
87
|
+
|
|
88
|
+
# receive HelloRetryRequest
|
|
89
|
+
hrr, = conn.recv_message(TTTLS13::Cryptograph::Passer.new)
|
|
90
|
+
@stack << hrr
|
|
91
|
+
raise Error::BeforeTargetSituationError, 'did not send expected handshake message: HelloRetryRequest' \
|
|
92
|
+
unless hrr.is_a?(TTTLS13::Message::ServerHello) && hrr.hrr?
|
|
93
|
+
raise Error::BeforeTargetSituationError, 'HelloRetryRequest did not include "key_share" extension' \
|
|
94
|
+
unless hrr.extensions.include?(TTTLS13::Message::ExtensionType::KEY_SHARE)
|
|
95
|
+
|
|
96
|
+
# send 2nd ClientHello; the greased ech is copied from 1st ClientHello
|
|
97
|
+
new_exs = TLS13Client.gen_newch_extensions(ch1, hrr)
|
|
98
|
+
group = hrr.extensions[TTTLS13::Message::ExtensionType::KEY_SHARE].key_share_entry.first.group
|
|
99
|
+
key_share, shared_secret = TTTLS13::Message::Extension::KeyShare.gen_ch_key_share([group])
|
|
100
|
+
new_exs[TTTLS13::Message::ExtensionType::KEY_SHARE] = key_share
|
|
101
|
+
ch = TTTLS13::Message::ClientHello.new(
|
|
102
|
+
legacy_version: ch1.legacy_version,
|
|
103
|
+
random: ch1.random,
|
|
104
|
+
legacy_session_id: ch1.legacy_session_id,
|
|
105
|
+
cipher_suites: ch1.cipher_suites,
|
|
106
|
+
legacy_compression_methods: ch1.legacy_compression_methods,
|
|
107
|
+
extensions: new_exs
|
|
108
|
+
)
|
|
109
|
+
conn.send_record(
|
|
110
|
+
TTTLS13::Message::Record.new(
|
|
111
|
+
type: TTTLS13::Message::ContentType::HANDSHAKE,
|
|
112
|
+
messages: [ch],
|
|
113
|
+
cipher: TTTLS13::Cryptograph::Passer.new
|
|
114
|
+
)
|
|
115
|
+
)
|
|
116
|
+
@stack << ch
|
|
117
|
+
|
|
118
|
+
# receive ServerHello
|
|
119
|
+
recv = conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
120
|
+
raise Error::BeforeTargetSituationError, 'not received ServerHello' \
|
|
121
|
+
unless recv.is_a?(TTTLS13::Message::ServerHello) && !recv.hrr?
|
|
122
|
+
|
|
123
|
+
# receive EncryptedExtensions
|
|
124
|
+
sh = recv
|
|
125
|
+
transcript = TTTLS13::Transcript.new
|
|
126
|
+
transcript[TTTLS13::CH1] = [ch1, ch1.serialize]
|
|
127
|
+
transcript[TTTLS13::HRR] = [hrr, hrr.serialize]
|
|
128
|
+
transcript[TTTLS13::CH] = [ch, ch.serialize]
|
|
129
|
+
transcript[TTTLS13::SH] = [sh, sh.serialize]
|
|
130
|
+
kse = sh.extensions[TTTLS13::Message::ExtensionType::KEY_SHARE].key_share_entry.first
|
|
131
|
+
key_schedule = TTTLS13::KeySchedule.new(
|
|
132
|
+
psk: nil,
|
|
133
|
+
shared_secret: shared_secret.build(kse.group, kse.key_exchange),
|
|
134
|
+
cipher_suite: sh.cipher_suite,
|
|
135
|
+
transcript:
|
|
136
|
+
)
|
|
137
|
+
hs_rcipher = TTTLS13::Endpoint.gen_cipher(
|
|
138
|
+
sh.cipher_suite,
|
|
139
|
+
key_schedule.server_handshake_write_key,
|
|
140
|
+
key_schedule.server_handshake_write_iv
|
|
141
|
+
)
|
|
142
|
+
recv = conn.recv_message_skipping_ccs(hs_rcipher, @stack)
|
|
143
|
+
raise Error::BeforeTargetSituationError, 'not received EncryptedExtensions' \
|
|
144
|
+
unless recv.is_a?(TTTLS13::Message::EncryptedExtensions)
|
|
145
|
+
|
|
146
|
+
recv
|
|
147
|
+
end
|
|
148
|
+
# rubocop: enable Metrics/AbcSize
|
|
149
|
+
# rubocop: enable Metrics/MethodLength
|
|
150
|
+
end
|
|
151
|
+
end
|
|
152
|
+
end
|
data/lib/echspec/spec/7.2-1.rb
CHANGED
|
@@ -94,10 +94,7 @@ module EchSpec
|
|
|
94
94
|
@stack << inner2
|
|
95
95
|
@stack << ch
|
|
96
96
|
|
|
97
|
-
recv
|
|
98
|
-
recv, = conn.recv_message(TTTLS13::Cryptograph::Passer.new) \
|
|
99
|
-
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
100
|
-
@stack << recv
|
|
97
|
+
recv = conn.recv_message_skipping_ccs(TTTLS13::Cryptograph::Passer.new, @stack)
|
|
101
98
|
return [recv, nil] unless recv.is_a?(TTTLS13::Message::ServerHello) && !recv.hrr?
|
|
102
99
|
|
|
103
100
|
transcript[TTTLS13::CH] = [inner2, inner2.serialize]
|
data/lib/echspec/spec.rb
CHANGED
|
@@ -78,6 +78,26 @@ module EchSpec
|
|
|
78
78
|
def message_stack
|
|
79
79
|
@stack.marshal
|
|
80
80
|
end
|
|
81
|
+
|
|
82
|
+
# @param ee [TTTLS13::Message::EncryptedExtensions]
|
|
83
|
+
#
|
|
84
|
+
# @return [EchSpec::Ok | Err]
|
|
85
|
+
def validate_ee_ech(ee)
|
|
86
|
+
# Extensions#[] returns nil for UnknownExtension, so use super_fetch.
|
|
87
|
+
ex = ee.extensions.super_fetch(TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO, nil)
|
|
88
|
+
case ex
|
|
89
|
+
in TTTLS13::Message::Extension::ECHEncryptedExtensions
|
|
90
|
+
return Err.new('EncryptedExtensions "encrypted_client_hello" extension did not have "retry_configs"', message_stack) \
|
|
91
|
+
if ex.retry_configs.nil? || ex.retry_configs.empty?
|
|
92
|
+
|
|
93
|
+
Ok.new(nil)
|
|
94
|
+
in nil
|
|
95
|
+
Err.new('EncryptedExtensions did not include "encrypted_client_hello" extension', message_stack)
|
|
96
|
+
in TTTLS13::Message::Extension::UnknownExtension
|
|
97
|
+
# tttls1.3 deserializes the extension whose length field mismatches as UnknownExtension
|
|
98
|
+
Err.new('EncryptedExtensions "encrypted_client_hello" extension could not be decoded', message_stack)
|
|
99
|
+
end
|
|
100
|
+
end
|
|
81
101
|
end
|
|
82
102
|
end
|
|
83
103
|
end
|
|
@@ -179,7 +199,7 @@ module EchSpec
|
|
|
179
199
|
groups = [Spec5_11, Spec5_1_9, Spec5_1_10]
|
|
180
200
|
|
|
181
201
|
# https://datatracker.ietf.org/doc/html/rfc9849#section-7
|
|
182
|
-
groups += [
|
|
202
|
+
groups += [Spec7_3, Spec7_1_11, Spec7_1_14_2_1, Spec7_1_1_2, Spec7_1_1_5, Spec7_1_1_7, Spec7_2_1]
|
|
183
203
|
|
|
184
204
|
groups.map(&:spec_group)
|
|
185
205
|
end
|
data/lib/echspec/tls13_client.rb
CHANGED
|
@@ -26,6 +26,20 @@ module EchSpec
|
|
|
26
26
|
|
|
27
27
|
[message, orig_msg]
|
|
28
28
|
end
|
|
29
|
+
|
|
30
|
+
# @param cipher [TTTLS13::Cryptograph::$Object]
|
|
31
|
+
# @param stack [EchSpec::Log::MessageStack]
|
|
32
|
+
#
|
|
33
|
+
# @return [TTTLS13::Message::$Object]
|
|
34
|
+
def recv_message_skipping_ccs(cipher, stack)
|
|
35
|
+
recv, = recv_message(cipher)
|
|
36
|
+
stack << recv
|
|
37
|
+
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
38
|
+
recv, = recv_message(cipher)
|
|
39
|
+
stack << recv
|
|
40
|
+
end
|
|
41
|
+
recv
|
|
42
|
+
end
|
|
29
43
|
end
|
|
30
44
|
|
|
31
45
|
class << self
|
|
@@ -98,16 +112,14 @@ module EchSpec
|
|
|
98
112
|
|
|
99
113
|
# @param socket [TCPSocket]
|
|
100
114
|
# @param hostname [String]
|
|
101
|
-
# @param stack [EchSpec::Log::MessageStack
|
|
115
|
+
# @param stack [EchSpec::Log::MessageStack]
|
|
102
116
|
#
|
|
103
117
|
# @raise [EchSpec::Error::BeforeTargetSituationError]
|
|
104
118
|
#
|
|
105
119
|
# @return [TTTLS13::Message::EncryptedExtensions]
|
|
106
120
|
# rubocop: disable Metrics/AbcSize
|
|
107
|
-
# rubocop: disable Metrics/CyclomaticComplexity
|
|
108
121
|
# rubocop: disable Metrics/MethodLength
|
|
109
|
-
|
|
110
|
-
def send_ch_with_greased_ech(socket, hostname, stack = nil)
|
|
122
|
+
def send_ch_with_greased_ech(socket, hostname, stack)
|
|
111
123
|
conn = TLS13Client::Connection.new(socket, :client)
|
|
112
124
|
inner_ech = TTTLS13::Message::Extension::ECHClientHello.new_inner
|
|
113
125
|
exs, shared_secret = TLS13Client.gen_ch_extensions(hostname)
|
|
@@ -123,7 +135,7 @@ module EchSpec
|
|
|
123
135
|
TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => inner_ech
|
|
124
136
|
)
|
|
125
137
|
)
|
|
126
|
-
stack << inner
|
|
138
|
+
stack << inner
|
|
127
139
|
|
|
128
140
|
ch = TTTLS13::Ech.new_greased_ch(inner, TTTLS13::Ech.new_grease_ech)
|
|
129
141
|
conn.send_record(
|
|
@@ -133,10 +145,10 @@ module EchSpec
|
|
|
133
145
|
cipher: TTTLS13::Cryptograph::Passer.new
|
|
134
146
|
)
|
|
135
147
|
)
|
|
136
|
-
stack << ch
|
|
148
|
+
stack << ch
|
|
137
149
|
|
|
138
150
|
recv, = conn.recv_message(TTTLS13::Cryptograph::Passer.new)
|
|
139
|
-
stack << recv
|
|
151
|
+
stack << recv
|
|
140
152
|
raise Error::BeforeTargetSituationError, 'not received ServerHello' \
|
|
141
153
|
unless recv.is_a?(TTTLS13::Message::ServerHello) && !recv.hrr?
|
|
142
154
|
|
|
@@ -157,23 +169,15 @@ module EchSpec
|
|
|
157
169
|
key_schedule.server_handshake_write_key,
|
|
158
170
|
key_schedule.server_handshake_write_iv
|
|
159
171
|
)
|
|
160
|
-
recv
|
|
161
|
-
stack << recv if stack
|
|
162
|
-
if recv.is_a?(TTTLS13::Message::ChangeCipherSpec)
|
|
163
|
-
recv, = conn.recv_message(hs_rcipher)
|
|
164
|
-
stack << recv if stack
|
|
165
|
-
end
|
|
166
|
-
|
|
172
|
+
recv = conn.recv_message_skipping_ccs(hs_rcipher, stack)
|
|
167
173
|
raise Error::BeforeTargetSituationError, 'not received EncryptedExtensions' \
|
|
168
174
|
unless recv.is_a?(TTTLS13::Message::EncryptedExtensions)
|
|
169
175
|
|
|
170
176
|
recv
|
|
171
177
|
end
|
|
178
|
+
|
|
172
179
|
# rubocop: enable Metrics/AbcSize
|
|
173
|
-
# rubocop: enable Metrics/CyclomaticComplexity
|
|
174
180
|
# rubocop: enable Metrics/MethodLength
|
|
175
|
-
# rubocop: enable Metrics/PerceivedComplexity
|
|
176
|
-
|
|
177
181
|
# @param conf [ECHConfig::ECHConfigContents::HpkeKeyConfig]
|
|
178
182
|
#
|
|
179
183
|
# @return [Boolean]
|
data/lib/echspec/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: echspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.9
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thekuwayama
|
|
@@ -114,11 +114,12 @@ files:
|
|
|
114
114
|
- lib/echspec/spec/5-11.rb
|
|
115
115
|
- lib/echspec/spec/5.1-10.rb
|
|
116
116
|
- lib/echspec/spec/5.1-9.rb
|
|
117
|
-
- lib/echspec/spec/7-
|
|
117
|
+
- lib/echspec/spec/7-3.rb
|
|
118
118
|
- lib/echspec/spec/7.1-11.rb
|
|
119
119
|
- lib/echspec/spec/7.1-14.2.1.rb
|
|
120
120
|
- lib/echspec/spec/7.1.1-2.rb
|
|
121
121
|
- lib/echspec/spec/7.1.1-5.rb
|
|
122
|
+
- lib/echspec/spec/7.1.1-7.rb
|
|
122
123
|
- lib/echspec/spec/7.2-1.rb
|
|
123
124
|
- lib/echspec/spec/9.rb
|
|
124
125
|
- lib/echspec/spec_case.rb
|