Botan 3.0.0
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
 
virtual bool is_implemented () const
 
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)
 
Extension_Code type () const override
 

Static Public Member Functions

static Extension_Code static_type ()
 

Detailed Description

Supported Point Formats Extension (RFC 4492)

Definition at line 285 of file tls_extensions.h.

Member Enumeration Documentation

◆ ECPointFormat

Enumerator
UNCOMPRESSED 
ANSIX962_COMPRESSED_PRIME 
ANSIX962_COMPRESSED_CHAR2 

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

301 :
302 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 480 of file tls_extensions.cpp.

482 {
483 uint8_t len = reader.get_byte();
484
485 if(len + 1 != extension_size)
486 throw Decoding_Error("Inconsistent length field in supported point formats list");
487
488 for(size_t i = 0; i != len; ++i)
489 {
490 uint8_t format = reader.get_byte();
491
492 if(static_cast<ECPointFormat>(format) == UNCOMPRESSED)
493 {
494 m_prefers_compressed = false;
495 reader.discard_next(len-i-1);
496 return;
497 }
498 else if(static_cast<ECPointFormat>(format) == ANSIX962_COMPRESSED_PRIME)
499 {
500 m_prefers_compressed = true;
501 reader.discard_next(len-i-1);
502 return;
503 }
504
505 // ignore ANSIX962_COMPRESSED_CHAR2, we don't support these curves
506 }
507 }

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

307{ return false; }

◆ is_implemented()

virtual bool Botan::TLS::Extension::is_implemented ( ) const
inlinevirtualinherited
Returns
true if this extension is known and implemented by Botan

Reimplemented in Botan::TLS::Unknown_Extension.

Definition at line 113 of file tls_extensions.h.

113{ return true; }

◆ prefers_compressed()

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

Definition at line 309 of file tls_extensions.h.

309{ 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 467 of file tls_extensions.cpp.

468 {
469 // if this extension is sent, it MUST include uncompressed (RFC 4492, section 5.1)
470 if(m_prefers_compressed)
471 {
472 return std::vector<uint8_t>{2, ANSIX962_COMPRESSED_PRIME, UNCOMPRESSED};
473 }
474 else
475 {
476 return std::vector<uint8_t>{1, UNCOMPRESSED};
477 }
478 }

References ANSIX962_COMPRESSED_PRIME, and UNCOMPRESSED.

◆ static_type()

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

Definition at line 294 of file tls_extensions.h.

◆ type()

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

Implements Botan::TLS::Extension.

Definition at line 297 of file tls_extensions.h.

297{ return static_type(); }
static Extension_Code static_type()

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