Class: EchSpec::Spec::Spec7_5
- Inherits:
-
WithSocket
- Object
- WithSocket
- EchSpec::Spec::Spec7_5
- Defined in:
- lib/echspec/spec/7-5.rb
Defined Under Namespace
Classes: IllegalEchClientHello
Class Method Summary collapse
- .spec_group ⇒ EchSpec::SpecGroup
- .validate_illegal_inner_ech_type(hostname, port, ech_config) ⇒ EchSpec::Ok | Err
- .validate_illegal_outer_ech_type(hostname, port, ech_config) ⇒ EchSpec::Ok | Err
Instance Method Summary collapse
- #do_validate_illegal_ech_type(hostname, port, ech_config, method) ⇒ EchSpec::Ok | Err
- #send_ch_illegal_inner_ech_type(socket, hostname, ech_config) ⇒ TTTLS13::Message::Record
-
#send_ch_illegal_outer_ech_type(socket, hostname, ech_config) ⇒ TTTLS13::Message::Record
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
Methods inherited from WithSocket
#initialize, #message_stack, #with_socket
Constructor Details
This class inherits a constructor from EchSpec::Spec::WithSocket
Class Method Details
.spec_group ⇒ EchSpec::SpecGroup
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/echspec/spec/7-5.rb', line 10 def self.spec_group SpecGroup.new( '7-5', [ SpecCase.new( 'MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloInner.', method(:validate_illegal_inner_ech_type) ), SpecCase.new( 'MUST abort with an "illegal_parameter" alert, if ECHClientHello.type is not a valid ECHClientHelloType in ClientHelloOuter.', method(:validate_illegal_outer_ech_type) ) ] ) end |
.validate_illegal_inner_ech_type(hostname, port, ech_config) ⇒ EchSpec::Ok | Err
31 32 33 34 35 36 37 38 |
# File 'lib/echspec/spec/7-5.rb', line 31 def self.validate_illegal_inner_ech_type(hostname, port, ech_config) Spec7_5.new.do_validate_illegal_ech_type( hostname, port, ech_config, :send_ch_illegal_inner_ech_type ) end |
.validate_illegal_outer_ech_type(hostname, port, ech_config) ⇒ EchSpec::Ok | Err
45 46 47 48 49 50 51 52 |
# File 'lib/echspec/spec/7-5.rb', line 45 def self.validate_illegal_outer_ech_type(hostname, port, ech_config) Spec7_5.new.do_validate_illegal_ech_type( hostname, port, ech_config, :send_ch_illegal_outer_ech_type ) end |
Instance Method Details
#do_validate_illegal_ech_type(hostname, port, ech_config, method) ⇒ EchSpec::Ok | Err
60 61 62 63 64 65 66 67 68 |
# File 'lib/echspec/spec/7-5.rb', line 60 def do_validate_illegal_ech_type(hostname, port, ech_config, method) with_socket(hostname, port) do |socket| recv = send(method, socket, hostname, ech_config) return Err.new('did not send expected alert: illegal_parameter', ) \ unless Spec.expect_alert(recv, :illegal_parameter) Ok.new(nil) end end |
#send_ch_illegal_inner_ech_type(socket, hostname, ech_config) ⇒ TTTLS13::Message::Record
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/echspec/spec/7-5.rb', line 75 def send_ch_illegal_inner_ech_type(socket, hostname, ech_config) conn = TLS13Client::Connection.new(socket, :client) inner_ech = IllegalEchClientHello.new_inner exs, = TLS13Client.gen_ch_extensions(hostname) inner = TTTLS13::Message::ClientHello.new( cipher_suites: TTTLS13::CipherSuites.new( [ TTTLS13::CipherSuite::TLS_AES_256_GCM_SHA384, TTTLS13::CipherSuite::TLS_CHACHA20_POLY1305_SHA256, TTTLS13::CipherSuite::TLS_AES_128_GCM_SHA256 ] ), extensions: exs.merge( TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => inner_ech ) ) selector = proc { |x| TLS13Client.select_ech_hpke_cipher_suite(x) } ch, inner, = TTTLS13::Ech.offer_ech(inner, ech_config, selector) conn.send_record( TTTLS13::Message::Record.new( type: TTTLS13::Message::ContentType::HANDSHAKE, messages: [ch], cipher: TTTLS13::Cryptograph::Passer.new ) ) @stack << inner @stack << ch recv, = conn.(TTTLS13::Cryptograph::Passer.new) @stack << recv recv end |
#send_ch_illegal_outer_ech_type(socket, hostname, ech_config) ⇒ TTTLS13::Message::Record
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/echspec/spec/7-5.rb', line 117 def send_ch_illegal_outer_ech_type(socket, hostname, ech_config) conn = TLS13Client::Connection.new(socket, :client) inner_ech = TTTLS13::Message::Extension::ECHClientHello.new_inner exs, = TLS13Client.gen_ch_extensions(hostname) inner = TTTLS13::Message::ClientHello.new( cipher_suites: TTTLS13::CipherSuites.new( [ TTTLS13::CipherSuite::TLS_AES_256_GCM_SHA384, TTTLS13::CipherSuite::TLS_CHACHA20_POLY1305_SHA256, TTTLS13::CipherSuite::TLS_AES_128_GCM_SHA256 ] ), extensions: exs.merge( TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => inner_ech ) ) @stack << inner # offer_ech selector = proc { |x| TLS13Client.select_ech_hpke_cipher_suite(x) } # for ech_outer_extensions replaced = \ inner.extensions.remove_and_replace!([]) # Encrypted ClientHello Configuration ech_state, enc = TTTLS13::Ech.encrypted_ech_config( ech_config, selector ) encoded = TTTLS13::Ech.encode_ch_inner(inner, ech_state.maximum_name_length, replaced) overhead_len = TTTLS13::Ech.aead_id2overhead_len( ech_state.cipher_suite.aead_id.uint16 ) # Encoding the ClientHelloInner aad_ech = IllegalEchClientHello.new_outer( cipher_suite: ech_state.cipher_suite, config_id: ech_state.config_id, enc:, payload: '0' * (encoded.length + overhead_len) ) aad = TTTLS13::Message::ClientHello.new( legacy_version: inner.legacy_version, legacy_session_id: inner.legacy_session_id, cipher_suites: inner.cipher_suites, legacy_compression_methods: inner.legacy_compression_methods, extensions: inner.extensions.merge( TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => aad_ech, TTTLS13::Message::ExtensionType::SERVER_NAME => \ TTTLS13::Message::Extension::ServerName.new(ech_state.public_name) ) ) # Authenticating the ClientHelloOuter # which does not include the Handshake structure's four byte header. outer_ech = IllegalEchClientHello.new_outer( cipher_suite: ech_state.cipher_suite, config_id: ech_state.config_id, enc:, payload: ech_state.ctx.seal(aad.serialize[4..], encoded) ) outer = TTTLS13::Message::ClientHello.new( legacy_version: aad.legacy_version, random: aad.random, legacy_session_id: aad.legacy_session_id, cipher_suites: aad.cipher_suites, legacy_compression_methods: aad.legacy_compression_methods, extensions: aad.extensions.merge( TTTLS13::Message::ExtensionType::ENCRYPTED_CLIENT_HELLO => outer_ech ) ) conn.send_record( TTTLS13::Message::Record.new( type: TTTLS13::Message::ContentType::HANDSHAKE, messages: [outer], cipher: TTTLS13::Cryptograph::Passer.new ) ) @stack << outer recv, = conn.(TTTLS13::Cryptograph::Passer.new) @stack << recv recv end |