Botan 2.1.0 Crypto and TLS for C++11

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | List of all members
Botan::TLS::Protocol_Version Class Reference

`#include <tls_version.h>`

## 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
uint8_t | major_version () const
uint8_t | 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 (uint8_t major, uint8_t 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

enum Botan::TLS::Protocol_Version::Version_Code

Enumerator
TLS_V10 |
TLS_V11 |
TLS_V12 |
DTLS_V10 |
DTLS_V12 |

Definition at line 24 of file tls_version.h.

24 {
25 TLS_V10 = 0x0301,
26 TLS_V11 = 0x0302,
27 TLS_V12 = 0x0303,
28
29 DTLS_V10 = 0xFEFF,
30 DTLS_V12 = 0xFEFD
31 };
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::DTLS_V10
Definition: tls_version.h:29
Botan::TLS::Protocol_Version::TLS_V11
Definition: tls_version.h:26
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27
Botan::TLS::Protocol_Version::TLS_V10
Definition: tls_version.h:25

## Constructor & Destructor Documentation

Botan::TLS::Protocol_Version::Protocol_Version | ( |  | ) |
| inline

Definition at line 49 of file tls_version.h.

49 : m_version(0) {}

Botan::TLS::Protocol_Version::Protocol_Version | ( | Version_Code | named_version | ) |
| inline

Parameters

  named_version | a specific named version of the protocol

Definition at line 54 of file tls_version.h.

54 :
55 m_version(static_cast<uint16_t>(named_version)) {}

Botan::TLS::Protocol_Version::Protocol_Version | ( | uint8_t | major,
|  | uint8_t | minor
| ) |  |
| inline

Parameters

  major | the major version
  minor | the minor version

Definition at line 61 of file tls_version.h.

61 :
62 m_version((static_cast<uint16_t>(major) << 8) | minor) {}

## Member Function Documentation

bool Botan::TLS::Protocol_Version::is_datagram_protocol | ( |  | ) | const

Returns
  true iff this is a DTLS version

Definition at line 34 of file tls_version.cpp.

References major_version().

Referenced by Botan::TLS::Client_Hello::Client_Hello(), Botan::TLS::Channel::create_handshake_state(), operator>(), Botan::TLS::Policy::send_fallback_scsv(), Botan::TLS::Server_Hello::Server_Hello(), Botan::TLS::Client_Hello::update_hello_cookie(), and Botan::TLS::write_record().

35 {
36 return major_version() == 254;
37 }
Botan::TLS::Protocol_Version::major_version
uint8_t major_version() const
Definition: tls_version.h:77

bool Botan::TLS::Protocol_Version::known_version | ( |  | ) | const

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.

53 {
54 return (m_version == Protocol_Version::TLS_V10 ||
55 m_version == Protocol_Version::TLS_V11 ||
56 m_version == Protocol_Version::TLS_V12 ||
57 m_version == Protocol_Version::DTLS_V10 ||
58 m_version == Protocol_Version::DTLS_V12);
59 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::DTLS_V10
Definition: tls_version.h:29
Botan::TLS::Protocol_Version::TLS_V11
Definition: tls_version.h:26
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27
Botan::TLS::Protocol_Version::TLS_V10
Definition: tls_version.h:25

static Protocol_Version Botan::TLS::Protocol_Version::latest_dtls_version | ( |  | ) |
| inline static

Returns
  latest known DTLS version

Definition at line 44 of file tls_version.h.

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

45 {
46 return Protocol_Version(DTLS_V12);
47 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::Protocol_Version
Protocol_Version()
Definition: tls_version.h:49

static Protocol_Version Botan::TLS::Protocol_Version::latest_tls_version | ( |  | ) |
| inline static

Returns
  latest known TLS version

Definition at line 36 of file tls_version.h.

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

37 {
38 return Protocol_Version(TLS_V12);
39 }
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27
Botan::TLS::Protocol_Version::Protocol_Version
Protocol_Version()
Definition: tls_version.h:49

uint8_t Botan::TLS::Protocol_Version::major_version | ( |  | ) | const
| inline

Returns
  major version of the protocol version

Definition at line 77 of file tls_version.h.

References Botan::get_byte().

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Session::DER_encode(), Botan::TLS::Connection_Cipher_State::format_ad(), is_datagram_protocol(), Botan::TLS::Hello_Verify_Request::serialize(), to_string(), and Botan::TLS::write_record().

77 { return get_byte(0, m_version); }
Botan::get_byte
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:47

uint8_t Botan::TLS::Protocol_Version::minor_version | ( |  | ) | const
| inline

Returns
  minor version of the protocol version

Definition at line 82 of file tls_version.h.

References Botan::get_byte().

Referenced by Botan::TLS::Client_Key_Exchange::Client_Key_Exchange(), Botan::TLS::Session::DER_encode(), Botan::TLS::Connection_Cipher_State::format_ad(), Botan::TLS::Hello_Verify_Request::serialize(), to_string(), and Botan::TLS::write_record().

82 { return get_byte(1, m_version); }
Botan::get_byte
uint8_t get_byte(size_t byte_num, T input)
Definition: loadstor.h:47

bool Botan::TLS::Protocol_Version::operator!= | ( | const Protocol_Version & | other | ) | const
| inline

Returns
  if this version is not equal to other

Definition at line 122 of file tls_version.h.

123 {
124 return (m_version != other.m_version);
125 }

bool Botan::TLS::Protocol_Version::operator== | ( | const Protocol_Version & | other | ) | const
| inline

Returns
  if this version is equal to other

Definition at line 114 of file tls_version.h.

115 {
116 return (m_version == other.m_version);
117 }

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().

40 {
41 if(this->is_datagram_protocol() != other.is_datagram_protocol())
42 throw TLS_Exception(Alert::PROTOCOL_VERSION,
43 "Version comparing " + to_string() +
44 " with " + other.to_string());
45
46 if(this->is_datagram_protocol())
47 return m_version < other.m_version; // goes backwards
48
49 return m_version > other.m_version;
50 }
Botan::TLS::Protocol_Version::to_string
std::string to_string() const
Definition: tls_version.cpp:16
Botan::TLS::Alert::PROTOCOL_VERSION
Definition: tls_alert.h:47
Botan::TLS::Protocol_Version::is_datagram_protocol
bool is_datagram_protocol() const
Definition: tls_version.cpp:34

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 135 of file tls_version.h.

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

bool Botan::TLS::Protocol_Version::supports_aead_modes | ( |  | ) | const

Definition at line 81 of file tls_version.cpp.

References DTLS_V12, and TLS_V12.

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

82 {
83 return (m_version == Protocol_Version::TLS_V12 ||
84 m_version == Protocol_Version::DTLS_V12);
85 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27

bool Botan::TLS::Protocol_Version::supports_ciphersuite_specific_prf | ( |  | ) | const

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().

76 {
77 return (m_version == Protocol_Version::TLS_V12 ||
78 m_version == Protocol_Version::DTLS_V12);
79 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27

bool Botan::TLS::Protocol_Version::supports_explicit_cbc_ivs | ( |  | ) | const

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().

68 {
69 return (m_version == Protocol_Version::TLS_V11 ||
70 m_version == Protocol_Version::TLS_V12 ||
71 m_version == Protocol_Version::DTLS_V10 ||
72 m_version == Protocol_Version::DTLS_V12);
73 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::DTLS_V10
Definition: tls_version.h:29
Botan::TLS::Protocol_Version::TLS_V11
Definition: tls_version.h:26
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27

bool Botan::TLS::Protocol_Version::supports_negotiable_signature_algorithms | ( |  | ) | const

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_Req::Certificate_Req(), Botan::TLS::Certificate_Verify::Certificate_Verify(), Botan::TLS::Client_Hello::Client_Hello(), and Botan::TLS::Server_Key_Exchange::Server_Key_Exchange().

62 {
63 return (m_version == Protocol_Version::TLS_V12 ||
64 m_version == Protocol_Version::DTLS_V12);
65 }
Botan::TLS::Protocol_Version::DTLS_V12
Definition: tls_version.h:30
Botan::TLS::Protocol_Version::TLS_V12
Definition: tls_version.h:27

std::string Botan::TLS::Protocol_Version::to_string | ( |  | ) | const

Returns
  human-readable description of this version

Definition at line 16 of file tls_version.cpp.

References major_version(), Botan::CT::min(), minor_version(), and Botan::ASN1::to_string().

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

17 {
18 const uint8_t maj = major_version();
19 const uint8_t min = minor_version();
20
21 if(maj == 3 && min == 0)
22 return "SSL v3";
23
24 if(maj == 3 && min >= 1) // TLS v1.x
25 return "TLS v1." + std::to_string(min-1);
26
27 if(maj == 254) // DTLS 1.x
28 return "DTLS v1." + std::to_string(255 - min);
29
30 // Some very new or very old protocol (or bogus data)
31 return "Unknown " + std::to_string(maj) + "." + std::to_string(min);
32 }
Botan::TLS::Protocol_Version::minor_version
uint8_t minor_version() const
Definition: tls_version.h:82
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::TLS::Protocol_Version::major_version
uint8_t major_version() const
Definition: tls_version.h:77
Botan::CT::min
T min(T a, T b)
Definition: ct_utils.h:180

bool Botan::TLS::Protocol_Version::valid | ( |  | ) | const
| inline

Returns
  true if this is a valid protocol version

Definition at line 67 of file tls_version.h.

67 { return (m_version != 0); }

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

- src/lib/tls/tls_version.h
- src/lib/tls/tls_version.cpp