Botan 2.19.5 Crypto and TLS for C&

Public Member Functions | Static Public Member Functions | List of all members
Botan::TLS::Supported_Groups Class Referencefinal

`#include <tls_extensions.h>`

Inheritance diagram for Botan::TLS::Supported_Groups:

## Public Member Functions
std::vector< Group_Params > | dh_groups () const
std::vector< Group_Params > | ec_groups () const
bool | empty () const override
std::vector< uint8_t > | serialize (Connection_Side whoami) const override
| Supported_Groups (const std::vector< Group_Params > &groups)
| Supported_Groups (TLS_Data_Reader &reader, uint16_t extension_size)
Handshake_Extension_Type | type () const override

## Static Public Member Functions
static Handshake_Extension_Type | static_type ()

## Detailed Description

Supported Groups Extension (RFC 7919)

Definition at line 240 of file tls_extensions.h.

## Constructor & Destructor Documentation

## ◆ Supported_Groups() [1/2]

Botan::TLS::Supported_Groups::Supported_Groups | ( | const std::vector< Group_Params > & | groups | ) |
| explicit

Definition at line 310 of file tls_extensions.cpp.

310 : m_groups(groups)
311 {
312 }

## ◆ Supported_Groups() [2/2]

Botan::TLS::Supported_Groups::Supported_Groups | ( | TLS_Data_Reader & | reader,
|  | uint16_t | extension_size
| ) |  |

Definition at line 357 of file tls_extensions.cpp.

359 {
360 const uint16_t len = reader.get_uint16_t();
361
362 if(len + 2 != extension_size)
363 throw Decoding_Error("Inconsistent length field in supported groups list");
364
365 if(len % 2 == 1)
366 throw Decoding_Error("Supported groups list of strange size");
367
368 const size_t elems = len / 2;
369
370 for(size_t i = 0; i != elems; ++i)
371 {
372 const uint16_t id = reader.get_uint16_t();
373 m_groups.push_back(static_cast<Group_Params>(id));
374 }
375 }
Botan::TLS::Group_Params
Group_Params
Definition: tls_algos.h:123

References Botan::TLS::TLS_Data_Reader::get_uint16_t().

## Member Function Documentation

## ◆ dh_groups()

std::vector< Group_Params > Botan::TLS::Supported_Groups::dh_groups | ( |  | ) | const

Definition at line 325 of file tls_extensions.cpp.

326 {
327 std::vector<Group_Params> dh;
328 for(auto g : m_groups)
329 {
330 if(group_param_is_dh(g) == true)
331 dh.push_back(g);
332 }
333 return dh;
334 }
Botan::TLS::group_param_is_dh
bool group_param_is_dh(Group_Params group)
Definition: tls_algos.cpp:118

References Botan::TLS::group_param_is_dh().

## ◆ ec_groups()

std::vector< Group_Params > Botan::TLS::Supported_Groups::ec_groups | ( |  | ) | const

Definition at line 314 of file tls_extensions.cpp.

315 {
316 std::vector<Group_Params> ec;
317 for(auto g : m_groups)
318 {
319 if(group_param_is_dh(g) == false)
320 ec.push_back(g);
321 }
322 return ec;
323 }

References Botan::TLS::group_param_is_dh().

## ◆ empty()

bool Botan::TLS::Supported_Groups::empty | ( |  | ) | const
| inline override virtual

Returns
  if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 258 of file tls_extensions.h.

258{ return m_groups.empty(); }

## ◆ serialize()

std::vector< uint8_t > Botan::TLS::Supported_Groups::serialize | ( | Connection_Side | whoami | ) | const
| override virtual

Returns
  serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 336 of file tls_extensions.cpp.

337 {
338 std::vector<uint8_t> buf(2);
339
340 for(auto g : m_groups)
341 {
342 const uint16_t id = static_cast<uint16_t>(g);
343
344 if(id > 0)
345 {
346 buf.push_back(get_byte(0, id));
347 buf.push_back(get_byte(1, id));
348 }
349 }
350
351 buf[0] = get_byte(0, static_cast<uint16_t>(buf.size()-2));
352 buf[1] = get_byte(1, static_cast<uint16_t>(buf.size()-2));
353
354 return buf;
355 }
Botan::get_byte
constexpr uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:41

References Botan::get_byte().

## ◆ static_type()

static Handshake_Extension_Type Botan::TLS::Supported_Groups::static_type | ( |  | ) |
| inline static

Definition at line 243 of file tls_extensions.h.

244 { return TLSEXT_SUPPORTED_GROUPS; }
Botan::TLS::TLSEXT_SUPPORTED_GROUPS
@ TLSEXT_SUPPORTED_GROUPS
Definition: tls_extensions.h:37

References Botan::TLS::TLSEXT_SUPPORTED_GROUPS.

## ◆ type()

Handshake_Extension_Type Botan::TLS::Supported_Groups::type | ( |  | ) | const
| inline override virtual

Returns
  code number of the extension

Implements Botan::TLS::Extension.

Definition at line 246 of file tls_extensions.h.

246{ return static_type(); }
Botan::TLS::Supported_Groups::static_type
static Handshake_Extension_Type static_type()
Definition: tls_extensions.h:243

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

- src/lib/tls/tls_extensions.h
- src/lib/tls/tls_extensions.cpp