Botan 2.19.2
Crypto and TLS for C&
tls_version.cpp
Go to the documentation of this file.
1/*
2* TLS Protocol Version Management
3* (C) 2012 Jack Lloyd
4*
5* Botan is released under the Simplified BSD License (see license.txt)
6*/
7
8#include <botan/tls_version.h>
9#include <botan/tls_exceptn.h>
10
11namespace Botan {
12
13namespace TLS {
14
15std::string Protocol_Version::to_string() const
16 {
17 const uint8_t maj = major_version();
18 const uint8_t min = minor_version();
19
20 if(maj == 3 && min == 0)
21 return "SSL v3";
22
23 if(maj == 3 && min >= 1) // TLS v1.x
24 return "TLS v1." + std::to_string(min-1);
25
26 if(maj == 254) // DTLS 1.x
27 return "DTLS v1." + std::to_string(255 - min);
28
29 // Some very new or very old protocol (or bogus data)
30 return "Unknown " + std::to_string(maj) + "." + std::to_string(min);
31 }
32
34 {
35 return major_version() > 250;
36 }
37
39 {
40 if(this->is_datagram_protocol() != other.is_datagram_protocol())
42 "Version comparing " + to_string() +
43 " with " + other.to_string());
44
45 if(this->is_datagram_protocol())
46 return m_version < other.m_version; // goes backwards
47
48 return m_version > other.m_version;
49 }
50
52 {
53 return (m_version == Protocol_Version::TLS_V10 ||
54 m_version == Protocol_Version::TLS_V11 ||
55 m_version == Protocol_Version::TLS_V12 ||
56 m_version == Protocol_Version::DTLS_V10 ||
57 m_version == Protocol_Version::DTLS_V12);
58 }
59
61 {
62 return (m_version != Protocol_Version::TLS_V10 &&
63 m_version != Protocol_Version::TLS_V11 &&
64 m_version != Protocol_Version::DTLS_V10);
65 }
66
68 {
69 return (m_version != Protocol_Version::TLS_V10);
70 }
71
73 {
74 return (m_version != Protocol_Version::TLS_V10 &&
75 m_version != Protocol_Version::TLS_V11 &&
76 m_version != Protocol_Version::DTLS_V10);
77 }
78
80 {
81 return (m_version != Protocol_Version::TLS_V10 &&
82 m_version != Protocol_Version::TLS_V11 &&
83 m_version != Protocol_Version::DTLS_V10);
84 }
85
86}
87
88}
bool operator>(const Protocol_Version &other) const
Definition: tls_version.cpp:38
bool supports_negotiable_signature_algorithms() const
Definition: tls_version.cpp:60
std::string to_string() const
Definition: tls_version.cpp:15
bool supports_explicit_cbc_ivs() const
Definition: tls_version.cpp:67
bool supports_ciphersuite_specific_prf() const
Definition: tls_version.cpp:72
uint8_t major_version() const
Definition: tls_version.h:79
uint8_t minor_version() const
Definition: tls_version.h:84
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:213
Definition: alg_id.cpp:13