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.
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 23 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.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 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.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def ticket @ticket end |
#ticket_age_add ⇒ Object (readonly)
Returns the value of attribute ticket_age_add.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def ticket_age_add @ticket_age_add end |
#ticket_lifetime ⇒ Object (readonly)
Returns the value of attribute ticket_lifetime.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def ticket_lifetime @ticket_lifetime end |
#ticket_nonce ⇒ Object (readonly)
Returns the value of attribute ticket_nonce.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def ticket_nonce @ticket_nonce end |
#timestamp ⇒ Object (readonly)
Returns the value of attribute timestamp.
14 15 16 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 14 def @timestamp end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::NewSessionTicket
rubocop: disable Metrics/AbcSize
55 56 57 58 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 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 55 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_age_add:, ticket_nonce:, ticket:, extensions:) end |
Instance Method Details
#appearable_extensions? ⇒ Boolean
89 90 91 92 93 94 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 89 def appearable_extensions? exs = @extensions.keys - APPEARABLE_NST_EXTENSIONS return true if exs.empty? !(exs - DEFINED_EXTENSIONS).empty? end |
#serialize ⇒ String
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tttls1.3/message/new_session_ticket.rb', line 38 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 |