lib/tttls1.3/message/extensions.rb
# NOTE:
# deserialize_extension ignores unparsable extension.
# Received unparsable binary, returns nil, doesn't raise
# ErrorAlerts :decode_error.
#
# @param binary [String]
# @param extension_type [TTTLS13::Message::ExtensionType]
# @param msg_type [TTTLS13::Message::HandshakeType]
#
# @raise [TTTLS13::Error::ErrorAlerts]
#
# @return [TTTLS13::Message::Extension::$Object, nil]
# rubocop: disable Metrics/CyclomaticComplexity
# rubocop: disable Metrics/MethodLength
deserialize_extension ignores unparsable extension.
Received unparsable binary, returns nil, doesn't raise
ErrorAlerts :decode_error.
deserialize_extension ignores unparsable extension . Received unparsable binary returns nil doesn ' t raise ErrorAlerts : decode_error .
def deserialize_extension(binary, extension_type, msg_type)
          raise Error::ErrorAlerts, :internal_error if binary.nil?
          case extension_type
          when ExtensionType::SERVER_NAME
            Extension::ServerName.deserialize(binary)
          when ExtensionType::STATUS_REQUEST
            if msg_type == HandshakeType::CLIENT_HELLO
              return Extension::OCSPStatusRequest.deserialize(binary)
            end
            if msg_type == HandshakeType::CERTIFICATE
              return Extension::OCSPResponse.deserialize(binary)
            end
            Extension::UnknownExtension.deserialize(binary, extension_type)
          when ExtensionType::SUPPORTED_GROUPS
            Extension::SupportedGroups.deserialize(binary)
          when ExtensionType::SIGNATURE_ALGORITHMS
            Extension::SignatureAlgorithms.deserialize(binary)
          when ExtensionType::APPLICATION_LAYER_PROTOCOL_NEGOTIATION
            Extension::Alpn.deserialize(binary)
          when ExtensionType::RECORD_SIZE_LIMIT
            Extension::RecordSizeLimit.deserialize(binary)
          when ExtensionType::PRE_SHARED_KEY
            Extension::PreSharedKey.deserialize(binary, msg_type)
          when ExtensionType::EARLY_DATA
            Extension::EarlyDataIndication.deserialize(binary, msg_type)
          when ExtensionType::SUPPORTED_VERSIONS
            Extension::SupportedVersions.deserialize(binary, msg_type)
          when ExtensionType::COOKIE
            Extension::Cookie.deserialize(binary)
          when ExtensionType::PSK_KEY_EXCHANGE_MODES
            Extension::PskKeyExchangeModes.deserialize(binary)
          when ExtensionType::SIGNATURE_ALGORITHMS_CERT
            Extension::SignatureAlgorithmsCert.deserialize(binary)
          when ExtensionType::KEY_SHARE
            Extension::KeyShare.deserialize(binary, msg_type)
          else
            Extension::UnknownExtension.deserialize(binary, extension_type)
          end
        end
def deserialize_extension ( binary , extension_type , msg_type ) raise Error :: ErrorAlerts , :internal_error if binary . nil? case extension_type when ExtensionType :: SERVER_NAME Extension :: ServerName . deserialize ( binary ) when ExtensionType :: STATUS_REQUEST if msg_type == HandshakeType :: CLIENT_HELLO return Extension :: OCSPStatusRequest . deserialize ( binary ) end if msg_type == HandshakeType :: CERTIFICATE return Extension :: OCSPResponse . deserialize ( binary ) end Extension :: UnknownExtension . deserialize ( binary , extension_type ) when ExtensionType :: SUPPORTED_GROUPS Extension :: SupportedGroups . deserialize ( binary ) when ExtensionType :: SIGNATURE_ALGORITHMS Extension :: SignatureAlgorithms . deserialize ( binary ) when ExtensionType :: APPLICATION_LAYER_PROTOCOL_NEGOTIATION Extension :: Alpn . deserialize ( binary ) when ExtensionType :: RECORD_SIZE_LIMIT Extension :: RecordSizeLimit . deserialize ( binary ) when ExtensionType :: PRE_SHARED_KEY Extension :: PreSharedKey . deserialize ( binary , msg_type ) when ExtensionType :: EARLY_DATA Extension :: EarlyDataIndication . deserialize ( binary , msg_type ) when ExtensionType :: SUPPORTED_VERSIONS Extension :: SupportedVersions . deserialize ( binary , msg_type ) when ExtensionType :: COOKIE Extension :: Cookie . deserialize ( binary ) when ExtensionType :: PSK_KEY_EXCHANGE_MODES Extension :: PskKeyExchangeModes . deserialize ( binary ) when ExtensionType :: SIGNATURE_ALGORITHMS_CERT Extension :: SignatureAlgorithmsCert . deserialize ( binary ) when ExtensionType :: KEY_SHARE Extension :: KeyShare . deserialize ( binary , msg_type ) else Extension :: UnknownExtension . deserialize ( binary , extension_type ) end end
NOTE:
deserialize_extension ignores unparsable extension.
NOTE : deserialize_extension ignores unparsable extension .
disable Metrics/CyclomaticComplexity rubocop: disable Metrics/MethodLength
disable Metrics / CyclomaticComplexity rubocop : disable Metrics / MethodLength
TTTLS13::Message::Extension::$Object, nil
None
binary
extension_type
msg_type
None