Class: TTTLS13::Message::Extension::EarlyDataIndication

Inherits:
Object
  • Object
show all
Defined in:
lib/tttls1.3/message/extension/early_data_indication.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(max_early_data_size = nil) ⇒ EarlyDataIndication

Returns a new instance of EarlyDataIndication.

Parameters:

  • max_early_data_size (Integer, nil) (defaults to: nil)

Raises:



15
16
17
18
19
20
# File 'lib/tttls1.3/message/extension/early_data_indication.rb', line 15

def initialize(max_early_data_size = nil)
  @extension_type = ExtensionType::EARLY_DATA
  @max_early_data_size = max_early_data_size
  raise Error::ErrorAlerts, :internal_error \
    unless @max_early_data_size.nil? || @max_early_data_size < 2**32
end

Instance Attribute Details

#extension_typeObject (readonly)

Returns the value of attribute extension_type.



9
10
11
# File 'lib/tttls1.3/message/extension/early_data_indication.rb', line 9

def extension_type
  @extension_type
end

#max_early_data_sizeObject (readonly)

Returns the value of attribute max_early_data_size.



10
11
12
# File 'lib/tttls1.3/message/extension/early_data_indication.rb', line 10

def max_early_data_size
  @max_early_data_size
end

Class Method Details

.deserialize(binary, msg_type) ⇒ TTTLS13::Message::Extensions::EarlyDataIndication?

Parameters:

Returns:

  • (TTTLS13::Message::Extensions::EarlyDataIndication, nil)

Raises:



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/tttls1.3/message/extension/early_data_indication.rb', line 37

def self.deserialize(binary, msg_type)
  raise Error::ErrorAlerts, :internal_error if binary.nil?

  case msg_type
  when HandshakeType::CLIENT_HELLO, HandshakeType::ENCRYPTED_EXTENSIONS
    return nil unless binary.empty?

    max_early_data_size = nil
  when HandshakeType::NEW_SESSION_TICKET
    return nil unless binary.length == 4

    max_early_data_size = Convert.bin2i(binary)
  else
    raise Error::ErrorAlerts, :internal_error
  end

  EarlyDataIndication.new(max_early_data_size)
end

Instance Method Details

#serializeString

Returns:

  • (String)


23
24
25
26
27
28
29
# File 'lib/tttls1.3/message/extension/early_data_indication.rb', line 23

def serialize
  binary = ''
  binary = @max_early_data_size.to_uint32 \
    unless @max_early_data_size.nil?

  @extension_type + binary.prefix_uint16_length
end