Represents a SSL/TLS extension. This is a base class that can represent any type of extension. Inherited classes may contain parsing logic for specific extensions. This class provides capabilities such as getting the extension type, length and viewing the extension data as raw (byte array)
| pcpp::SSLExtension::SSLExtension |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen |
|
) |
| |
Constructs an SSLExtension that interprets the provided data as the raw bytes of the extension.
The memory span defined by data and dataLen can be larger than the actual extension data. If so, only the bytes corresponding to the extension header (type and length fields) + [length] bytes of extension data will be parsed. The rest of the span will be ignored.
The above behaviour allows variable length extensions to be parsed, as SSL extensions are laid out sequentially in memory on a payload.
- Parameters
-
| [in] | data | The raw data for the extension. |
| [in] | dataLen | The length of the data in bytes. |
- Exceptions
-
| std::invalid_argument | if data is nullptr or if dataLen is smaller than the size of the extension header (type and length fields). |
template<typename T , typename std::enable_if_t< std::is_base_of< SSLExtension, T >::value, bool > = true>
| static std::unique_ptr<T> pcpp::SSLExtension::tryCreateExtension |
( |
uint8_t * |
data, |
|
|
size_t |
dataLen |
|
) |
| |
|
inlinestatic |
A static method that tries to create an instance of a specific extension type.
The factory method handles potential buffer overflows by validating that the data length of the span is sufficient to contain the extension header (type and length fields) and the extension data as specified in the length field.
- Template Parameters
-
| T | The type of the extension to create. This type must be a class that inherits from SSLExtension. |
- Parameters
-
| data | Pointer to the raw data of the extension. |
| dataLen | Max length of the span to be parsed. |
- Returns
- The extension instance if the data buffer is valid, nullptr otherwise.