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

#include <tls_extensions.h>

Inheritance diagram for Botan::TLS::Supported_Point_Formats:
Botan::TLS::Extension

Public Types

enum  ECPointFormat : uint8_t { UNCOMPRESSED = 0, ANSIX962_COMPRESSED_PRIME = 1, ANSIX962_COMPRESSED_CHAR2 = 2 }
 

Public Member Functions

bool empty () const override
 
bool prefers_compressed ()
 
std::vector< uint8_t > serialize (Connection_Side whoami) const override
 
 Supported_Point_Formats (bool prefer_compressed)
 
 Supported_Point_Formats (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 Point Formats Extension (RFC 4492)

Definition at line 269 of file tls_extensions.h.

Member Enumeration Documentation

◆ ECPointFormat

Enumerator
UNCOMPRESSED 
ANSIX962_COMPRESSED_PRIME 
ANSIX962_COMPRESSED_CHAR2 

Definition at line 272 of file tls_extensions.h.

Constructor & Destructor Documentation

◆ Supported_Point_Formats() [1/2]

Botan::TLS::Supported_Point_Formats::Supported_Point_Formats ( bool  prefer_compressed)
inlineexplicit

Definition at line 285 of file tls_extensions.h.

285  :
286  m_prefers_compressed(prefer_compressed) {}

◆ Supported_Point_Formats() [2/2]

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

Definition at line 388 of file tls_extensions.cpp.

References ANSIX962_COMPRESSED_PRIME, Botan::TLS::TLS_Data_Reader::discard_next(), Botan::TLS::TLS_Data_Reader::get_byte(), and UNCOMPRESSED.

390  {
391  uint8_t len = reader.get_byte();
392 
393  if(len + 1 != extension_size)
394  throw Decoding_Error("Inconsistent length field in supported point formats list");
395 
396  for(size_t i = 0; i != len; ++i)
397  {
398  uint8_t format = reader.get_byte();
399 
400  if(static_cast<ECPointFormat>(format) == UNCOMPRESSED)
401  {
402  m_prefers_compressed = false;
403  reader.discard_next(len-i-1);
404  return;
405  }
406  else if(static_cast<ECPointFormat>(format) == ANSIX962_COMPRESSED_PRIME)
407  {
408  m_prefers_compressed = true;
409  reader.discard_next(len-i-1);
410  return;
411  }
412 
413  // ignore ANSIX962_COMPRESSED_CHAR2, we don't support these curves
414  }
415  }

Member Function Documentation

◆ empty()

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

Implements Botan::TLS::Extension.

Definition at line 291 of file tls_extensions.h.

291 { return false; }

◆ prefers_compressed()

bool Botan::TLS::Supported_Point_Formats::prefers_compressed ( )
inline

Definition at line 293 of file tls_extensions.h.

293 { return m_prefers_compressed; }

◆ serialize()

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

Implements Botan::TLS::Extension.

Definition at line 375 of file tls_extensions.cpp.

References ANSIX962_COMPRESSED_PRIME, and UNCOMPRESSED.

376  {
377  // if this extension is sent, it MUST include uncompressed (RFC 4492, section 5.1)
378  if(m_prefers_compressed)
379  {
380  return std::vector<uint8_t>{2, ANSIX962_COMPRESSED_PRIME, UNCOMPRESSED};
381  }
382  else
383  {
384  return std::vector<uint8_t>{1, UNCOMPRESSED};
385  }
386  }

◆ static_type()

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

◆ type()

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

Implements Botan::TLS::Extension.

Definition at line 281 of file tls_extensions.h.

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

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