Botan 2.19.1
Crypto and TLS for C&
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 (Connection_Side whoami) 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 302 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 316 of file tls_extensions.h.

316 :
317 m_schemes(schemes) {}

◆ Signature_Algorithms() [2/2]

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

Definition at line 441 of file tls_extensions.cpp.

443 {
444 uint16_t len = reader.get_uint16_t();
445
446 if(len + 2 != extension_size || len % 2 == 1 || len == 0)
447 {
448 throw Decoding_Error("Bad encoding on signature algorithms extension");
449 }
450
451 while(len)
452 {
453 const uint16_t scheme_code = reader.get_uint16_t();
454 m_schemes.push_back(static_cast<Signature_Scheme>(scheme_code));
455 len -= 2;
456 }
457 }
Signature_Scheme
Definition: tls_algos.h:86

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

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 314 of file tls_extensions.h.

314{ return m_schemes.empty(); }

◆ serialize()

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

Implements Botan::TLS::Extension.

Definition at line 419 of file tls_extensions.cpp.

420 {
421 BOTAN_ASSERT(m_schemes.size() < 256, "Too many signature schemes");
422
423 std::vector<uint8_t> buf;
424
425 const uint16_t len = static_cast<uint16_t>(m_schemes.size() * 2);
426
427 buf.push_back(get_byte(0, len));
428 buf.push_back(get_byte(1, len));
429
430 for(Signature_Scheme scheme : m_schemes)
431 {
432 const uint16_t scheme_code = static_cast<uint16_t>(scheme);
433
434 buf.push_back(get_byte(0, scheme_code));
435 buf.push_back(get_byte(1, scheme_code));
436 }
437
438 return buf;
439 }
#define BOTAN_ASSERT(expr, assertion_made)
Definition: assert.h:55
constexpr uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:41

References BOTAN_ASSERT, and Botan::get_byte().

◆ static_type()

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

Definition at line 305 of file tls_extensions.h.

@ TLSEXT_SIGNATURE_ALGORITHMS

References Botan::TLS::TLSEXT_SIGNATURE_ALGORITHMS.

◆ supported_schemes()

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

Definition at line 310 of file tls_extensions.h.

310{ 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 308 of file tls_extensions.h.

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

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