Botan  2.6.0
Crypto and TLS for C++11
Public Member Functions | Static Public Member Functions | List of all members
Botan::TLS::Signature_Algorithms Class Referencefinal

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::Signature_Algorithms:
Botan::TLS::Extension

Public Member Functions

bool empty () const override
 
std::vector< uint8_t > serialize () const override
 
 Signature_Algorithms (const std::vector< Signature_Scheme > &schemes)
 
 Signature_Algorithms (TLS_Data_Reader &reader, uint16_t extension_size)
 
const std::vector< Signature_Scheme > & supported_schemes () const
 
Handshake_Extension_Type type () const override
 

Static Public Member Functions

static Handshake_Extension_Type static_type ()
 

Detailed Description

Signature Algorithms Extension for TLS 1.2 (RFC 5246)

Definition at line 295 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ Signature_Algorithms() [1/2]

Botan::TLS::Signature_Algorithms::Signature_Algorithms ( const std::vector< Signature_Scheme > &  schemes)
inlineexplicit

Definition at line 309 of file tls_extensions.h.

309  :
310  m_schemes(schemes) {}

◆ Signature_Algorithms() [2/2]

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

Definition at line 425 of file tls_extensions.cpp.

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

427  {
428  uint16_t len = reader.get_uint16_t();
429 
430  if(len + 2 != extension_size || len % 2 == 1 || len == 0)
431  {
432  throw Decoding_Error("Bad encoding on signature algorithms extension");
433  }
434 
435  while(len)
436  {
437  const uint16_t scheme_code = reader.get_uint16_t();
438  m_schemes.push_back(static_cast<Signature_Scheme>(scheme_code));
439  len -= 2;
440  }
441  }

Member Function Documentation

◆ empty()

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

Implements Botan::TLS::Extension.

Definition at line 307 of file tls_extensions.h.

307 { return m_schemes.empty(); }

◆ serialize()

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

Implements Botan::TLS::Extension.

Definition at line 405 of file tls_extensions.cpp.

References Botan::get_byte().

406  {
407  std::vector<uint8_t> buf;
408 
409  const uint16_t len = m_schemes.size() * 2;
410 
411  buf.push_back(get_byte(0, len));
412  buf.push_back(get_byte(1, len));
413 
414  for(Signature_Scheme scheme : m_schemes)
415  {
416  const uint16_t scheme_code = static_cast<uint16_t>(scheme);
417 
418  buf.push_back(get_byte(0, scheme_code));
419  buf.push_back(get_byte(1, scheme_code));
420  }
421 
422  return buf;
423  }
Signature_Scheme
Definition: tls_algos.h:84
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:39

◆ static_type()

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

◆ supported_schemes()

const std::vector<Signature_Scheme>& Botan::TLS::Signature_Algorithms::supported_schemes ( ) const
inline

Definition at line 303 of file tls_extensions.h.

303 { return m_schemes; }

◆ type()

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

Implements Botan::TLS::Extension.

Definition at line 301 of file tls_extensions.h.

References static_type().

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

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