Botan  2.7.0
Crypto and TLS for C++11
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:
Botan::TLS::Extension

Public Member Functions

std::vector< Group_Paramsdh_groups () const
 
std::vector< Group_Paramsec_groups () const
 
bool empty () const override
 
std::vector< uint8_t > serialize () 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 233 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 298 of file tls_extensions.cpp.

298  : m_groups(groups)
299  {
300  }

◆ Supported_Groups() [2/2]

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

Definition at line 345 of file tls_extensions.cpp.

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

347  {
348  const uint16_t len = reader.get_uint16_t();
349 
350  if(len + 2 != extension_size)
351  throw Decoding_Error("Inconsistent length field in supported groups list");
352 
353  if(len % 2 == 1)
354  throw Decoding_Error("Supported groups list of strange size");
355 
356  for(size_t i = 0; i != len / 2; ++i)
357  {
358  const uint16_t id = reader.get_uint16_t();
359  m_groups.push_back(static_cast<Group_Params>(id));
360  }
361  }

Member Function Documentation

◆ dh_groups()

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

Definition at line 313 of file tls_extensions.cpp.

References Botan::TLS::group_param_is_dh().

314  {
315  std::vector<Group_Params> dh;
316  for(auto g : m_groups)
317  {
318  if(group_param_is_dh(g) == true)
319  dh.push_back(g);
320  }
321  return dh;
322  }
bool group_param_is_dh(Group_Params group)
Definition: tls_algos.cpp:118

◆ ec_groups()

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

Definition at line 302 of file tls_extensions.cpp.

References Botan::TLS::group_param_is_dh().

303  {
304  std::vector<Group_Params> ec;
305  for(auto g : m_groups)
306  {
307  if(group_param_is_dh(g) == false)
308  ec.push_back(g);
309  }
310  return ec;
311  }
bool group_param_is_dh(Group_Params group)
Definition: tls_algos.cpp:118

◆ empty()

bool Botan::TLS::Supported_Groups::empty ( ) const
inlineoverridevirtual
Returns
if we should encode this extension or not

Implements Botan::TLS::Extension.

Definition at line 251 of file tls_extensions.h.

251 { return m_groups.empty(); }

◆ serialize()

std::vector< uint8_t > Botan::TLS::Supported_Groups::serialize ( ) const
overridevirtual
Returns
serialized binary for the extension

Implements Botan::TLS::Extension.

Definition at line 324 of file tls_extensions.cpp.

References Botan::get_byte().

325  {
326  std::vector<uint8_t> buf(2);
327 
328  for(auto g : m_groups)
329  {
330  const uint16_t id = static_cast<uint16_t>(g);
331 
332  if(id > 0)
333  {
334  buf.push_back(get_byte(0, id));
335  buf.push_back(get_byte(1, id));
336  }
337  }
338 
339  buf[0] = get_byte(0, static_cast<uint16_t>(buf.size()-2));
340  buf[1] = get_byte(1, static_cast<uint16_t>(buf.size()-2));
341 
342  return buf;
343  }
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:39

◆ static_type()

static Handshake_Extension_Type Botan::TLS::Supported_Groups::static_type ( )
inlinestatic

◆ type()

Handshake_Extension_Type Botan::TLS::Supported_Groups::type ( ) const
inlineoverridevirtual
Returns
code number of the extension

Implements Botan::TLS::Extension.

Definition at line 239 of file tls_extensions.h.

References static_type().

239 { return static_type(); }
static Handshake_Extension_Type static_type()

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