Botan 2.19.1
Crypto and TLS for C&
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 390 of file tls_extensions.cpp.

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

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

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 377 of file tls_extensions.cpp.

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

References ANSIX962_COMPRESSED_PRIME, and UNCOMPRESSED.

◆ static_type()

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

Definition at line 278 of file tls_extensions.h.

279 { return TLSEXT_EC_POINT_FORMATS; }
@ TLSEXT_EC_POINT_FORMATS

References Botan::TLS::TLSEXT_EC_POINT_FORMATS.

◆ 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: