Incremental TLS/SSL Handshake parser. More...

#include <Handshake.h>

Collaboration diagram for Security::HandshakeParser:

Public Types

enum  ParserState {
  atHelloNone = 0 ,
  atHelloStarted ,
  atHelloReceived ,
  atHelloDoneReceived ,
  atNstReceived ,
  atCcsReceived ,
  atFinishReceived
}
 The parsing states. More...
 
enum  MessageSource {
  fromClient = 0 ,
  fromServer
}
 the originator of the TLS handshake being parsed More...
 

Public Member Functions

 HandshakeParser (MessageSource)
 
bool parseHello (const SBuf &data)
 

Public Attributes

TlsDetails::Pointer details
 TLS handshake meta info. Never nil. More...
 
ParserState state
 current parsing state. More...
 
bool resumingSession
 True if this is a resuming session. More...
 
MessageSource messageSource
 whether we are parsing Server or Client TLS handshake messages More...
 

Private Member Functions

bool isSslv2Record (const SBuf &raw) const
 
void parseRecord ()
 
void parseModernRecord ()
 parses a single TLS Record Layer frame More...
 
void parseVersion2Record ()
 
void parseMessages ()
 parses one or more "higher-level protocol" frames of currentContentType More...
 
void parseChangeCipherCpecMessage ()
 
void parseAlertMessage ()
 
void parseHandshakeMessage ()
 
void parseApplicationDataMessage ()
 
void skipMessage (const char *msgType)
 
bool parseRecordVersion2Try ()
 
void parseVersion2HandshakeMessage (const SBuf &raw)
 
void parseClientHelloHandshakeMessage (const SBuf &raw)
 
void parseServerHelloHandshakeMessage (const SBuf &raw)
 RFC 5246 Section 7.4.1.3. Server Hello. More...
 
bool parseCompressionMethods (const SBuf &raw)
 
void parseExtensions (const SBuf &raw)
 
SBuf parseSniExtension (const SBuf &extensionData) const
 
void parseSupportedVersionsExtension (const SBuf &extensionData) const
 RFC 8446 Section 4.2.1: SupportedVersions extension. More...
 
void parseCiphers (const SBuf &raw)
 
void parseV23Ciphers (const SBuf &raw)
 
void parseServerCertificates (const SBuf &raw)
 

Private Attributes

unsigned int currentContentType
 The current TLS/SSL record content type. More...
 
const char * done
 not nil if we got what we were looking for More...
 
SBuf fragments
 concatenated TLSPlaintext.fragments of TLSPlaintext.type More...
 
Parser::BinaryTokenizer tkRecords
 TLS record layer (parsing uninterpreted data) More...
 
Parser::BinaryTokenizer tkMessages
 TLS message layer (parsing fragments) More...
 
YesNoNone expectingModernRecords
 Whether to use TLS parser or a V2 compatible parser. More...
 

Detailed Description

Definition at line 60 of file Handshake.h.

Member Enumeration Documentation

◆ MessageSource

Enumerator
fromClient 
fromServer 

Definition at line 67 of file Handshake.h.

◆ ParserState

Enumerator
atHelloNone 
atHelloStarted 
atHelloReceived 
atHelloDoneReceived 
atNstReceived 
atCcsReceived 
atFinishReceived 

Definition at line 64 of file Handshake.h.

Constructor & Destructor Documentation

◆ HandshakeParser()

Security::HandshakeParser::HandshakeParser ( MessageSource  source)
explicit

Definition at line 219 of file Handshake.cc.

Member Function Documentation

◆ isSslv2Record()

bool Security::HandshakeParser::isSslv2Record ( const SBuf raw) const
private

RFC 5246. Appendix E.2. Compatibility with SSL 2.0 And draft-hickman-netscape-ssl-00. Section 4.1. SSL Record Header Format

Definition at line 244 of file Handshake.cc.

References head, Parser::BinaryTokenizer::uint16(), and Parser::BinaryTokenizer::uint8().

◆ parseAlertMessage()

void Security::HandshakeParser::parseAlertMessage ( )
private

◆ parseApplicationDataMessage()

void Security::HandshakeParser::parseApplicationDataMessage ( )
private

Definition at line 382 of file Handshake.cc.

References Security::ctApplicationData, and Must.

◆ parseChangeCipherCpecMessage()

void Security::HandshakeParser::parseChangeCipherCpecMessage ( )
private

Definition at line 314 of file Handshake.cc.

References Security::ctChangeCipherSpec, Must, and Security::Tls1p3orLater().

◆ parseCiphers()

void Security::HandshakeParser::parseCiphers ( const SBuf raw)
private

◆ parseClientHelloHandshakeMessage()

◆ parseCompressionMethods()

bool Security::HandshakeParser::parseCompressionMethods ( const SBuf raw)
private

◆ parseExtensions()

void Security::HandshakeParser::parseExtensions ( const SBuf raw)
private

◆ parseHandshakeMessage()

◆ parseHello()

bool Security::HandshakeParser::parseHello ( const SBuf data)

Parses the initial sequence of raw bytes sent by the TLS/SSL agent. Returns true upon successful completion (e.g., got HelloDone). Returns false if more data is needed. Throws on errors.

Definition at line 641 of file Handshake.cc.

References debugs.

Referenced by ConnStateData::parseTlsHandshake().

◆ parseMessages()

void Security::HandshakeParser::parseMessages ( )
private

◆ parseModernRecord()

void Security::HandshakeParser::parseModernRecord ( )
private

◆ parseRecord()

void Security::HandshakeParser::parseRecord ( )
private

Definition at line 254 of file Handshake.cc.

◆ parseRecordVersion2Try()

bool Security::HandshakeParser::parseRecordVersion2Try ( )
private

◆ parseServerCertificates()

void Security::HandshakeParser::parseServerCertificates ( const SBuf raw)
private

◆ parseServerHelloHandshakeMessage()

◆ parseSniExtension()

SBuf Security::HandshakeParser::parseSniExtension ( const SBuf extensionData) const
private

◆ parseSupportedVersionsExtension()

void Security::HandshakeParser::parseSupportedVersionsExtension ( const SBuf extensionData) const
private

◆ parseV23Ciphers()

void Security::HandshakeParser::parseV23Ciphers ( const SBuf raw)
private

◆ parseVersion2HandshakeMessage()

◆ parseVersion2Record()

void Security::HandshakeParser::parseVersion2Record ( )
private

◆ skipMessage()

void Security::HandshakeParser::skipMessage ( const char *  msgType)
private

Definition at line 632 of file Handshake.cc.

Member Data Documentation

◆ currentContentType

unsigned int Security::HandshakeParser::currentContentType
private

Definition at line 114 of file Handshake.h.

◆ details

TlsDetails::Pointer Security::HandshakeParser::details

◆ done

const char* Security::HandshakeParser::done
private

Definition at line 116 of file Handshake.h.

◆ expectingModernRecords

YesNoNone Security::HandshakeParser::expectingModernRecords
private

Definition at line 128 of file Handshake.h.

◆ fragments

SBuf Security::HandshakeParser::fragments
private

Definition at line 119 of file Handshake.h.

◆ messageSource

MessageSource Security::HandshakeParser::messageSource

Definition at line 84 of file Handshake.h.

◆ resumingSession

bool Security::HandshakeParser::resumingSession

Definition at line 81 of file Handshake.h.

◆ state

ParserState Security::HandshakeParser::state

Definition at line 79 of file Handshake.h.

◆ tkMessages

Parser::BinaryTokenizer Security::HandshakeParser::tkMessages
private

Definition at line 125 of file Handshake.h.

◆ tkRecords

Parser::BinaryTokenizer Security::HandshakeParser::tkRecords
private

Definition at line 122 of file Handshake.h.


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors