Class: TTTLS13::Message::Extension::ECHClientHello
- Inherits:
-
Object
- Object
- TTTLS13::Message::Extension::ECHClientHello
- Defined in:
- lib/tttls1.3/message/extension/ech.rb
Overview
NOTE:
struct {
ECHClientHelloType type;
select (ECHClientHello.type) {
case outer:
HpkeSymmetricCipherSuite cipher_suite;
uint8 config_id;
opaque enc<0..2^16-1>;
opaque payload<1..2^16-1>;
case inner:
Empty;
};
} ECHClientHello;
Instance Attribute Summary collapse
-
#cipher_suite ⇒ Object
Returns the value of attribute cipher_suite.
-
#config_id ⇒ Object
Returns the value of attribute config_id.
-
#enc ⇒ Object
Returns the value of attribute enc.
-
#extension_type ⇒ Object
Returns the value of attribute extension_type.
-
#payload ⇒ Object
Returns the value of attribute payload.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .deserialize(binary) ⇒ TTTLS13::Message::Extensions::ECHClientHello
- .new_inner ⇒ TTTLS13::Message::Extensions::ECHClientHello
- .new_outer(cipher_suite:, config_id:, enc:, payload:) ⇒ TTTLS13::Message::Extensions::ECHClientHello
Instance Method Summary collapse
-
#initialize(type:, cipher_suite: nil, config_id: nil, enc: nil, payload: nil) ⇒ ECHClientHello
constructor
A new instance of ECHClientHello.
- #serialize ⇒ String
Constructor Details
#initialize(type:, cipher_suite: nil, config_id: nil, enc: nil, payload: nil) ⇒ ECHClientHello
Returns a new instance of ECHClientHello.
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 41 def initialize(type:, cipher_suite: nil, config_id: nil, enc: nil, payload: nil) @extension_type = ExtensionType::ENCRYPTED_CLIENT_HELLO @type = type @cipher_suite = cipher_suite raise Error::ErrorAlerts, :internal_error \ if @type == ECHClientHelloType::OUTER && \ !@cipher_suite.is_a?(HpkeSymmetricCipherSuite) @config_id = config_id @enc = enc @payload = payload end |
Instance Attribute Details
#cipher_suite ⇒ Object
Returns the value of attribute cipher_suite.
31 32 33 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 31 def cipher_suite @cipher_suite end |
#config_id ⇒ Object
Returns the value of attribute config_id.
32 33 34 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 32 def config_id @config_id end |
#enc ⇒ Object
Returns the value of attribute enc.
33 34 35 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 33 def enc @enc end |
#extension_type ⇒ Object
Returns the value of attribute extension_type.
29 30 31 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 29 def extension_type @extension_type end |
#payload ⇒ Object
Returns the value of attribute payload.
34 35 36 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 34 def payload @payload end |
#type ⇒ Object
Returns the value of attribute type.
30 31 32 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 30 def type @type end |
Class Method Details
.deserialize(binary) ⇒ TTTLS13::Message::Extensions::ECHClientHello
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 80 def self.deserialize(binary) raise Error::ErrorAlerts, :internal_error \ if binary.nil? || binary.empty? case binary[0] when ECHClientHelloType::OUTER return deserialize_outer_ech(binary[1..]) when ECHClientHelloType::INNER return deserialize_inner_ech(binary[1..]) end raise Error::ErrorAlerts, :internal_error end |
.new_inner ⇒ TTTLS13::Message::Extensions::ECHClientHello
149 150 151 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 149 def self.new_inner ECHClientHello.new(type: ECHClientHelloType::INNER) end |
.new_outer(cipher_suite:, config_id:, enc:, payload:) ⇒ TTTLS13::Message::Extensions::ECHClientHello
159 160 161 162 163 164 165 166 167 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 159 def self.new_outer(cipher_suite:, config_id:, enc:, payload:) ECHClientHello.new( type: ECHClientHelloType::OUTER, cipher_suite: cipher_suite, config_id: config_id, enc: enc, payload: payload ) end |
Instance Method Details
#serialize ⇒ String
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/tttls1.3/message/extension/ech.rb', line 61 def serialize case @type when ECHClientHelloType::OUTER binary = @type + @cipher_suite.encode + @config_id.to_uint8 \ + @enc.prefix_uint16_length + @payload.prefix_uint16_length when ECHClientHelloType::INNER binary = @type else raise Error::ErrorAlerts, :internal_error end @extension_type + binary.prefix_uint16_length end |