Class: TTTLS13::Message::Extension::Alpn
- Inherits:
-
Object
- Object
- TTTLS13::Message::Extension::Alpn
- Defined in:
- lib/tttls1.3/message/extension/alpn.rb
Instance Attribute Summary collapse
-
#extension_type ⇒ Object
readonly
Returns the value of attribute extension_type.
-
#protocol_name_list ⇒ Object
readonly
Returns the value of attribute protocol_name_list.
Class Method Summary collapse
-
.deserialize(binary) ⇒ TTTLS13::Message::Extension::Alpn?
rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/PerceivedComplexity.
Instance Method Summary collapse
Constructor Details
#initialize(protocol_name_list) ⇒ Alpn
20 21 22 23 24 25 26 |
# File 'lib/tttls1.3/message/extension/alpn.rb', line 20 def initialize(protocol_name_list) @extension_type \ = ExtensionType::APPLICATION_LAYER_PROTOCOL_NEGOTIATION @protocol_name_list = protocol_name_list || [] raise Error::ErrorAlerts, :internal_error \ if @protocol_name_list.empty? end |
Instance Attribute Details
#extension_type ⇒ Object (readonly)
Returns the value of attribute extension_type.
9 10 11 |
# File 'lib/tttls1.3/message/extension/alpn.rb', line 9 def extension_type @extension_type end |
#protocol_name_list ⇒ Object (readonly)
Returns the value of attribute protocol_name_list.
10 11 12 |
# File 'lib/tttls1.3/message/extension/alpn.rb', line 10 def protocol_name_list @protocol_name_list end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::Extension::Alpn?
rubocop: disable Metrics/CyclomaticComplexity rubocop: disable Metrics/PerceivedComplexity
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/tttls1.3/message/extension/alpn.rb', line 42 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error if binary.nil? return nil if binary.length < 2 pnlist_len = Convert.bin2i(binary.slice(0, 2)) i = 2 protocol_name_list = [] while i < pnlist_len + 2 return nil if i + 1 > binary.length pn_len = Convert.bin2i(binary.slice(i, 1)) i += 1 return nil if i + pn_len > binary.length protocol_name_list << binary.slice(i, pn_len) i += pn_len end return nil unless i == binary.length && pnlist_len + 2 == binary.length Alpn.new(protocol_name_list) end |
Instance Method Details
#serialize ⇒ String
29 30 31 32 33 |
# File 'lib/tttls1.3/message/extension/alpn.rb', line 29 def serialize binary = @protocol_name_list.map(&:prefix_uint8_length).join @extension_type + binary.prefix_uint16_length.prefix_uint16_length end |