Class: TTTLS13::Message::ClientHello
- Inherits:
-
Object
- Object
- TTTLS13::Message::ClientHello
- Defined in:
- lib/tttls1.3/message/client_hello.rb
Instance Attribute Summary collapse
-
#cipher_suites ⇒ Object
readonly
Returns the value of attribute cipher_suites.
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#legacy_compression_methods ⇒ Object
readonly
Returns the value of attribute legacy_compression_methods.
-
#legacy_session_id ⇒ Object
readonly
Returns the value of attribute legacy_session_id.
-
#legacy_version ⇒ Object
readonly
Returns the value of attribute legacy_version.
-
#msg_type ⇒ Object
readonly
Returns the value of attribute msg_type.
-
#random ⇒ Object
readonly
Returns the value of attribute random.
Class Method Summary collapse
-
.deserialize(binary) ⇒ TTTLS13::Message::ClientHello
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength.
Instance Method Summary collapse
-
#initialize(legacy_version: ProtocolVersion::TLS_1_2, random: OpenSSL::Random.random_bytes(32), legacy_session_id: OpenSSL::Random.random_bytes(32), cipher_suites:, legacy_compression_methods: ["\x00"], extensions: Extensions.new) ⇒ ClientHello
constructor
rubocop: disable Metrics/ParameterLists.
- #serialize ⇒ String
Constructor Details
#initialize(legacy_version: ProtocolVersion::TLS_1_2, random: OpenSSL::Random.random_bytes(32), legacy_session_id: OpenSSL::Random.random_bytes(32), cipher_suites:, legacy_compression_methods: ["\x00"], extensions: Extensions.new) ⇒ ClientHello
rubocop: disable Metrics/ParameterLists
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/tttls1.3/message/client_hello.rb', line 23 def initialize(legacy_version: ProtocolVersion::TLS_1_2, random: OpenSSL::Random.random_bytes(32), legacy_session_id: OpenSSL::Random.random_bytes(32), cipher_suites:, legacy_compression_methods: ["\x00"], extensions: Extensions.new) @msg_type = HandshakeType::CLIENT_HELLO @legacy_version = legacy_version @random = random @legacy_session_id = legacy_session_id @cipher_suites = cipher_suites @legacy_compression_methods = legacy_compression_methods @extensions = extensions end |
Instance Attribute Details
#cipher_suites ⇒ Object (readonly)
Returns the value of attribute cipher_suites.
12 13 14 |
# File 'lib/tttls1.3/message/client_hello.rb', line 12 def cipher_suites @cipher_suites end |
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
14 15 16 |
# File 'lib/tttls1.3/message/client_hello.rb', line 14 def extensions @extensions end |
#legacy_compression_methods ⇒ Object (readonly)
Returns the value of attribute legacy_compression_methods.
13 14 15 |
# File 'lib/tttls1.3/message/client_hello.rb', line 13 def legacy_compression_methods @legacy_compression_methods end |
#legacy_session_id ⇒ Object (readonly)
Returns the value of attribute legacy_session_id.
11 12 13 |
# File 'lib/tttls1.3/message/client_hello.rb', line 11 def legacy_session_id @legacy_session_id end |
#legacy_version ⇒ Object (readonly)
Returns the value of attribute legacy_version.
9 10 11 |
# File 'lib/tttls1.3/message/client_hello.rb', line 9 def legacy_version @legacy_version end |
#msg_type ⇒ Object (readonly)
Returns the value of attribute msg_type.
8 9 10 |
# File 'lib/tttls1.3/message/client_hello.rb', line 8 def msg_type @msg_type end |
#random ⇒ Object (readonly)
Returns the value of attribute random.
10 11 12 |
# File 'lib/tttls1.3/message/client_hello.rb', line 10 def random @random end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::ClientHello
rubocop: disable Metrics/AbcSize rubocop: disable Metrics/MethodLength
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/tttls1.3/message/client_hello.rb', line 59 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error if binary.nil? raise Error::ErrorAlerts, :decode_error if binary.length < 39 raise Error::ErrorAlerts, :internal_error \ unless binary[0] == HandshakeType::CLIENT_HELLO msg_len = Convert.bin2i(binary.slice(1, 3)) legacy_version = binary.slice(4, 2) random = binary.slice(6, 32) lsid_len = Convert.bin2i(binary[38]) legacy_session_id = binary.slice(39, lsid_len) i = 39 + lsid_len cs_len = Convert.bin2i(binary.slice(i, 2)) i += 2 cs_bin = binary.slice(i, cs_len) cipher_suites = CipherSuites.deserialize(cs_bin) i += cs_len cm_len = Convert.bin2i(binary[i]) i += 1 legacy_compression_methods = binary.slice(i, cm_len).split('') i += cm_len exs_len = Convert.bin2i(binary.slice(i, 2)) i += 2 exs_bin = binary.slice(i, exs_len) extensions = Extensions.deserialize(exs_bin, HandshakeType::CLIENT_HELLO) i += exs_len raise Error::ErrorAlerts, :decode_error unless i == msg_len + 4 && i == binary.length ClientHello.new(legacy_version: legacy_version, random: random, legacy_session_id: legacy_session_id, cipher_suites: cipher_suites, legacy_compression_methods: legacy_compression_methods, extensions: extensions) end |
Instance Method Details
#serialize ⇒ String
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/tttls1.3/message/client_hello.rb', line 40 def serialize binary = '' binary += @legacy_version binary += @random binary += @legacy_session_id.prefix_uint8_length binary += @cipher_suites.serialize binary += @legacy_compression_methods.join.prefix_uint8_length binary += @extensions.serialize @msg_type + binary.prefix_uint24_length end |