Class: TTTLS13::Message::NewSessionTicket
- Inherits:
-
Object
- Object
- TTTLS13::Message::NewSessionTicket
- Defined in:
- lib/tttls1.3/message/new_session_ticket.rb
Instance Attribute Summary collapse
-
#extensions ⇒ Object
readonly
Returns the value of attribute extensions.
-
#msg_type ⇒ Object
readonly
Returns the value of attribute msg_type.
-
#ticket ⇒ Object
readonly
Returns the value of attribute ticket.
-
#ticket_age_add ⇒ Object
readonly
Returns the value of attribute ticket_age_add.
-
#ticket_lifetime ⇒ Object
readonly
Returns the value of attribute ticket_lifetime.
-
#ticket_nonce ⇒ Object
readonly
Returns the value of attribute ticket_nonce.
-
#timestamp ⇒ Object
readonly
Returns the value of attribute timestamp.
Class Method Summary collapse
-
.deserialize(binary) ⇒ TTTLS13::Message::NewSessionTicket
rubocop: disable Metrics/AbcSize.
Instance Method Summary collapse
- #appearable_extensions? ⇒ Boolean
-
#initialize(ticket_lifetime:, ticket_age_add:, ticket_nonce:, ticket:, extensions: Extensions.new) ⇒ NewSessionTicket
constructor
A new instance of NewSessionTicket.
- #serialize ⇒ String
Constructor Details
#initialize(ticket_lifetime:, ticket_age_add:, ticket_nonce:, ticket:, extensions: Extensions.new) ⇒ NewSessionTicket
Returns a new instance of NewSessionTicket.
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 29 def initialize(ticket_lifetime:, ticket_age_add:, ticket_nonce:, ticket:, extensions: Extensions.new) @msg_type = HandshakeType::NEW_SESSION_TICKET @ticket_lifetime = ticket_lifetime @ticket_age_add = ticket_age_add raise Error::ErrorAlerts, :internal_error \ unless ticket_age_add.length == 4 @ticket_nonce = ticket_nonce @ticket = ticket @extensions = extensions || Extensions.new @timestamp = Time.now.to_i end |
Instance Attribute Details
#extensions ⇒ Object (readonly)
Returns the value of attribute extensions.
19 20 21 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 19 def extensions @extensions end |
#msg_type ⇒ Object (readonly)
Returns the value of attribute msg_type.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def msg_type @msg_type end |
#ticket ⇒ Object (readonly)
Returns the value of attribute ticket.
18 19 20 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 18 def ticket @ticket end |
#ticket_age_add ⇒ Object (readonly)
Returns the value of attribute ticket_age_add.
16 17 18 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 16 def ticket_age_add @ticket_age_add end |
#ticket_lifetime ⇒ Object (readonly)
Returns the value of attribute ticket_lifetime.
15 16 17 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 15 def ticket_lifetime @ticket_lifetime end |
#ticket_nonce ⇒ Object (readonly)
Returns the value of attribute ticket_nonce.
17 18 19 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 17 def ticket_nonce @ticket_nonce end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
20 21 22 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 20 def @timestamp end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::NewSessionTicket
rubocop: disable Metrics/AbcSize
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 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 61 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error if binary.nil? raise Error::ErrorAlerts, :decode_error if binary.length < 13 raise Error::ErrorAlerts, :internal_error \ unless binary[0] == HandshakeType::NEW_SESSION_TICKET msg_len = Convert.bin2i(binary.slice(1, 3)) ticket_lifetime = Convert.bin2i(binary.slice(4, 4)) ticket_age_add = binary.slice(8, 4) tn_len = Convert.bin2i(binary[12]) ticket_nonce = binary.slice(13, tn_len) i = 13 + tn_len ticket_len = Convert.bin2i(binary.slice(i, 2)) i += 2 ticket = binary.slice(i, ticket_len) i += ticket_len exs_len = Convert.bin2i(binary.slice(i, 2)) i += 2 exs_bin = binary.slice(i, exs_len) extensions = Extensions.deserialize(exs_bin, HandshakeType::NEW_SESSION_TICKET) i += exs_len raise Error::ErrorAlerts, :decode_error unless i == msg_len + 4 && i == binary.length NewSessionTicket.new(ticket_lifetime: ticket_lifetime, ticket_age_add: ticket_age_add, ticket_nonce: ticket_nonce, ticket: ticket, extensions: extensions) end |
Instance Method Details
#appearable_extensions? ⇒ Boolean
95 96 97 98 99 100 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 95 def appearable_extensions? exs = @extensions.keys - APPEARABLE_NST_EXTENSIONS return true if exs.empty? !(exs - DEFINED_EXTENSIONS).empty? end |
#serialize ⇒ String
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 44 def serialize binary = '' binary += @ticket_lifetime.to_uint32 binary += @ticket_age_add binary += @ticket_nonce.prefix_uint8_length binary += @ticket.prefix_uint16_length binary += @extensions.serialize @msg_type + binary.prefix_uint24_length end |