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

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::SRTP_Protection_Profiles:
Botan::TLS::Extension

Public Member Functions

bool empty () const override
 
const std::vector< uint16_t > & profiles () const
 
std::vector< uint8_t > serialize (Connection_Side whoami) const override
 
 SRTP_Protection_Profiles (const std::vector< uint16_t > &pp)
 
 SRTP_Protection_Profiles (uint16_t pp)
 
 SRTP_Protection_Profiles (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

Used to indicate SRTP algorithms for DTLS (RFC 5764)

Definition at line 328 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ SRTP_Protection_Profiles() [1/3]

Botan::TLS::SRTP_Protection_Profiles::SRTP_Protection_Profiles ( const std::vector< uint16_t > &  pp)
inlineexplicit

Definition at line 342 of file tls_extensions.h.

342 : m_pp(pp) {}

◆ SRTP_Protection_Profiles() [2/3]

Botan::TLS::SRTP_Protection_Profiles::SRTP_Protection_Profiles ( uint16_t  pp)
inlineexplicit

Definition at line 344 of file tls_extensions.h.

344 : m_pp(1, pp) {}

◆ SRTP_Protection_Profiles() [3/3]

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

Definition at line 461 of file tls_extensions.cpp.

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

462  : m_pp(reader.get_range<uint16_t>(2, 0, 65535))
463  {
464  const std::vector<uint8_t> mki = reader.get_range<uint8_t>(1, 0, 255);
465 
466  if(m_pp.size() * 2 + mki.size() + 3 != extension_size)
467  throw Decoding_Error("Bad encoding for SRTP protection extension");
468 
469  if(!mki.empty())
470  throw Decoding_Error("Unhandled non-empty MKI for SRTP protection extension");
471  }

Member Function Documentation

◆ empty()

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

Implements Botan::TLS::Extension.

Definition at line 340 of file tls_extensions.h.

340 { return m_pp.empty(); }

◆ profiles()

const std::vector<uint16_t>& Botan::TLS::SRTP_Protection_Profiles::profiles ( ) const
inline

Definition at line 336 of file tls_extensions.h.

336 { return m_pp; }

◆ serialize()

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

Implements Botan::TLS::Extension.

Definition at line 473 of file tls_extensions.cpp.

References Botan::get_byte().

474  {
475  std::vector<uint8_t> buf;
476 
477  const uint16_t pp_len = static_cast<uint16_t>(m_pp.size() * 2);
478  buf.push_back(get_byte(0, pp_len));
479  buf.push_back(get_byte(1, pp_len));
480 
481  for(uint16_t pp : m_pp)
482  {
483  buf.push_back(get_byte(0, pp));
484  buf.push_back(get_byte(1, pp));
485  }
486 
487  buf.push_back(0); // srtp_mki, always empty here
488 
489  return buf;
490  }
constexpr uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:41

◆ static_type()

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

Definition at line 331 of file tls_extensions.h.

References Botan::TLS::TLSEXT_USE_SRTP.

◆ type()

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

Implements Botan::TLS::Extension.

Definition at line 334 of file tls_extensions.h.

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

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