Botan  2.8.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 () 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 262 of file tls_extensions.h.

Member Enumeration Documentation

◆ ECPointFormat

Enumerator
UNCOMPRESSED 
ANSIX962_COMPRESSED_PRIME 
ANSIX962_COMPRESSED_CHAR2 

Definition at line 265 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 278 of file tls_extensions.h.

278  :
279  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 376 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.

378  {
379  uint8_t len = reader.get_byte();
380 
381  if(len + 1 != extension_size)
382  throw Decoding_Error("Inconsistent length field in supported point formats list");
383 
384  for(size_t i = 0; i != len; ++i)
385  {
386  uint8_t format = reader.get_byte();
387 
388  if(static_cast<ECPointFormat>(format) == UNCOMPRESSED)
389  {
390  m_prefers_compressed = false;
391  reader.discard_next(len-i-1);
392  return;
393  }
394  else if(static_cast<ECPointFormat>(format) == ANSIX962_COMPRESSED_PRIME)
395  {
396  m_prefers_compressed = true;
397  reader.discard_next(len-i-1);
398  return;
399  }
400 
401  // ignore ANSIX962_COMPRESSED_CHAR2, we don't support these curves
402  }
403  }

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

284 { return false; }

◆ prefers_compressed()

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

Definition at line 286 of file tls_extensions.h.

286 { return m_prefers_compressed; }

◆ serialize()

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

Implements Botan::TLS::Extension.

Definition at line 363 of file tls_extensions.cpp.

References ANSIX962_COMPRESSED_PRIME, and UNCOMPRESSED.

364  {
365  // if this extension is sent, it MUST include uncompressed (RFC 4492, section 5.1)
366  if(m_prefers_compressed)
367  {
368  return std::vector<uint8_t>{2, ANSIX962_COMPRESSED_PRIME, UNCOMPRESSED};
369  }
370  else
371  {
372  return std::vector<uint8_t>{1, UNCOMPRESSED};
373  }
374  }

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

References static_type().

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

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