Botan  1.11.15
Public Types | Public Member Functions | Static Public Member Functions
Botan::TLS::Protocol_Version Class Reference

#include <tls_version.h>

List of all members.

Public Types

enum  Version_Code {
  TLS_V10 = 0x0301, TLS_V11 = 0x0302, TLS_V12 = 0x0303, DTLS_V10 = 0xFEFF,
  DTLS_V12 = 0xFEFD
}

Public Member Functions

bool is_datagram_protocol () const
bool known_version () const
byte major_version () const
byte minor_version () const
bool operator!= (const Protocol_Version &other) const
bool operator== (const Protocol_Version &other) const
bool operator> (const Protocol_Version &other) const
bool operator>= (const Protocol_Version &other) const
 Protocol_Version ()
 Protocol_Version (Version_Code named_version)
 Protocol_Version (byte major, byte minor)
bool supports_aead_modes () const
bool supports_ciphersuite_specific_prf () const
bool supports_explicit_cbc_ivs () const
bool supports_negotiable_signature_algorithms () const
std::string to_string () const
bool valid () const

Static Public Member Functions

static Protocol_Version latest_dtls_version ()
static Protocol_Version latest_tls_version ()

Detailed Description

TLS Protocol Version

Definition at line 21 of file tls_version.h.


Member Enumeration Documentation

Enumerator:
TLS_V10 
TLS_V11 
TLS_V12 
DTLS_V10 
DTLS_V12 

Definition at line 24 of file tls_version.h.

                        {
         TLS_V10            = 0x0301,
         TLS_V11            = 0x0302,
         TLS_V12            = 0x0303,

         DTLS_V10           = 0xFEFF,
         DTLS_V12           = 0xFEFD
      };

Constructor & Destructor Documentation

Definition at line 43 of file tls_version.h.

: m_version(0) {}
Parameters:
named_versiona specific named version of the protocol

Definition at line 48 of file tls_version.h.

                                                   :
         m_version(static_cast<u16bit>(named_version)) {}
Botan::TLS::Protocol_Version::Protocol_Version ( byte  major,
byte  minor 
) [inline]
Parameters:
majorthe major version
minorthe minor version

Definition at line 55 of file tls_version.h.

                                               :
         m_version((static_cast<u16bit>(major) << 8) | minor) {}

Member Function Documentation

Returns:
true if this is a protocol version we know about

Definition at line 52 of file tls_version.cpp.

References DTLS_V10, DTLS_V12, TLS_V10, TLS_V11, and TLS_V12.

   {
   return (m_version == Protocol_Version::TLS_V10 ||
           m_version == Protocol_Version::TLS_V11 ||
           m_version == Protocol_Version::TLS_V12 ||
           m_version == Protocol_Version::DTLS_V10 ||
           m_version == Protocol_Version::DTLS_V12);
   }

Definition at line 38 of file tls_version.h.

Referenced by Botan::TLS::Policy::latest_supported_version().

         {
         return Protocol_Version(DTLS_V12);
         }

Definition at line 33 of file tls_version.h.

Referenced by Botan::TLS::Policy::latest_supported_version().

         {
         return Protocol_Version(TLS_V12);
         }
bool Botan::TLS::Protocol_Version::operator!= ( const Protocol_Version other) const [inline]
Returns:
if this version is not equal to other

Definition at line 116 of file tls_version.h.

         {
         return (m_version != other.m_version);
         }
bool Botan::TLS::Protocol_Version::operator== ( const Protocol_Version other) const [inline]
Returns:
if this version is equal to other

Definition at line 108 of file tls_version.h.

         {
         return (m_version == other.m_version);
         }
bool Botan::TLS::Protocol_Version::operator> ( const Protocol_Version other) const
Returns:
if this version is later than other

Definition at line 39 of file tls_version.cpp.

References is_datagram_protocol(), Botan::TLS::Alert::PROTOCOL_VERSION, and to_string().

   {
   if(this->is_datagram_protocol() != other.is_datagram_protocol())
      throw TLS_Exception(Alert::PROTOCOL_VERSION,
                          "Version comparing " + to_string() +
                          " with " + other.to_string());

   if(this->is_datagram_protocol())
      return m_version < other.m_version; // goes backwards

   return m_version > other.m_version;
   }
bool Botan::TLS::Protocol_Version::operator>= ( const Protocol_Version other) const [inline]
Returns:
if this version is later than or equal to other

Definition at line 129 of file tls_version.h.

         {
         return (*this == other || *this > other);
         }

Definition at line 81 of file tls_version.cpp.

References DTLS_V12, and TLS_V12.

Referenced by Botan::TLS::Policy::ciphersuite_list().

   {
   return (m_version == Protocol_Version::TLS_V12 ||
           m_version == Protocol_Version::DTLS_V12);
   }
Returns:
true if this version uses a ciphersuite specific PRF

Definition at line 75 of file tls_version.cpp.

References DTLS_V12, and TLS_V12.

Referenced by Botan::TLS::Handshake_Hash::final().

   {
   return (m_version == Protocol_Version::TLS_V12 ||
           m_version == Protocol_Version::DTLS_V12);
   }
Returns:
true if this version uses explicit IVs for block ciphers

Definition at line 67 of file tls_version.cpp.

References DTLS_V10, DTLS_V12, TLS_V11, and TLS_V12.

Referenced by Botan::TLS::Connection_Cipher_State::Connection_Cipher_State().

   {
   return (m_version == Protocol_Version::TLS_V11 ||
           m_version == Protocol_Version::TLS_V12 ||
           m_version == Protocol_Version::DTLS_V10 ||
           m_version == Protocol_Version::DTLS_V12);
   }
Returns:
true if this version supports negotiable signature algorithms

Definition at line 61 of file tls_version.cpp.

References DTLS_V12, and TLS_V12.

Referenced by Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::TLS::Client_Hello::Client_Hello(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().

   {
   return (m_version == Protocol_Version::TLS_V12 ||
           m_version == Protocol_Version::DTLS_V12);
   }
Returns:
human-readable description of this version

Definition at line 16 of file tls_version.cpp.

References major_version(), and minor_version().

Referenced by Botan::TLS::Channel::create_handshake_state(), and operator>().

   {
   const byte maj = major_version();
   const byte min = minor_version();

   if(maj == 3 && min == 0)
      return "SSL v3";

   if(maj == 3 && min >= 1) // TLS v1.x
      return "TLS v1." + std::to_string(min-1);

   if(maj == 254) // DTLS 1.x
      return "DTLS v1." + std::to_string(255 - min);

   // Some very new or very old protocol (or bogus data)
   return "Unknown " + std::to_string(maj) + "." + std::to_string(min);
   }
bool Botan::TLS::Protocol_Version::valid ( ) const [inline]
Returns:
true if this is a valid protocol version

Definition at line 61 of file tls_version.h.

{ return (m_version != 0); }

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