Botan
3.14.1
Crypto and TLS for C&
src
lib
tls
tls_alert.h
Go to the documentation of this file.
1
/*
2
* Alert Message
3
* (C) 2004-2006,2011,2012 Jack Lloyd
4
*
5
* Botan is released under the Simplified BSD License (see license.txt)
6
*/
7
8
#ifndef BOTAN_TLS_ALERT_H_
9
#define BOTAN_TLS_ALERT_H_
10
11
#include <botan/secmem.h>
12
#include <string>
13
14
namespace
Botan::TLS
{
15
16
/**
17
* Type codes for TLS alerts
18
*
19
* The enumeration value matches the wire encoding
20
*/
21
enum class
AlertType
: uint16_t {
22
CloseNotify
= 0,
23
UnexpectedMessage
= 10,
24
BadRecordMac
= 20,
25
DecryptionFailed
= 21,
// Not specified in TLS 1.3 (RFC 9846)
26
RecordOverflow
= 22,
27
DecompressionFailure
= 30,
// Not specified in TLS 1.3 (RFC 9846)
28
HandshakeFailure
= 40,
29
NoCertificate
= 41,
// SSLv3 only
30
BadCertificate
= 42,
31
UnsupportedCertificate
= 43,
32
CertificateRevoked
= 44,
33
CertificateExpired
= 45,
34
CertificateUnknown
= 46,
35
IllegalParameter
= 47,
36
UnknownCA
= 48,
37
AccessDenied
= 49,
38
DecodeError
= 50,
39
DecryptError
= 51,
40
ExportRestriction
= 60,
// Not specified in TLS 1.3 (RFC 9846)
41
ProtocolVersion
= 70,
42
InsufficientSecurity
= 71,
43
InternalError
= 80,
44
InappropriateFallback
= 86,
45
UserCanceled
= 90,
46
NoRenegotiation
= 100,
// Not specified in TLS 1.3 (RFC 9846)
47
MissingExtension
= 109,
48
UnsupportedExtension
= 110,
49
CertificateUnobtainable
= 111,
// Not specified in TLS 1.3 (RFC 9846)
50
UnrecognizedName
= 112,
51
BadCertificateStatusResponse
= 113,
52
BadCertificateHashValue
= 114,
// Not specified in TLS 1.3 (RFC 9846)
53
UnknownPSKIdentity
= 115,
54
CertificateRequired
= 116,
55
GeneralError
= 117,
56
NoApplicationProtocol
= 120,
57
58
// pseudo alert values
59
None
= 256,
60
61
// Compat enum variants, will be removed in a future major release
62
// TODO(Botan4): remove these
63
CLOSE_NOTIFY
BOTAN_DEPRECATED
(
"Use CloseNotify"
) =
CloseNotify
,
64
NO_APPLICATION_PROTOCOL
BOTAN_DEPRECATED
(
"Use NoApplicationProtocol"
) =
NoApplicationProtocol
,
65
PROTOCOL_VERSION
BOTAN_DEPRECATED
(
"Use ProtocolVersion"
) =
ProtocolVersion
,
66
};
67
68
/**
69
* SSL/TLS Alert Message
70
*/
71
class
BOTAN_PUBLIC_API
(2, 0)
Alert
final {
72
public
:
73
typedef
AlertType
Type
;
74
using
enum
AlertType
;
75
76
/**
77
* @return true iff this alert is non-empty and has a type that can be encoded
78
*/
79
bool
is_valid
()
const
{
80
// Values greater than 255 are used for pseudo alert types that
81
// cannot actually be sent on the wire
82
return
static_cast<
uint16_t
>
(m_type_code) <= 255;
83
}
84
85
/**
86
* Return true if this alert is fatal. A fatal alert causes the connection
87
* to be immediately disconnected. Otherwise, the alert is a warning and
88
* the connection remains valid.
89
*
90
* Note:
91
* RFC 8446 6.
92
* In TLS 1.3, the severity is implicit in the type of alert being sent,
93
* and the "level" field can safely be ignored.
94
* Everything is considered fatal except for UserCanceled and CloseNotify (RFC 8446 6.1)
95
*
96
* @return if this alert is fatal or not
97
*/
98
bool
is_fatal
()
const
{
return
m_fatal; }
99
100
/**
101
* Returns the type of the alert as an enum
102
*
103
* @return type of alert
104
*/
105
Type
type
()
const
{
return
m_type_code; }
106
107
/**
108
* Returns the type of the alert as a string
109
*
110
* @return type of alert
111
*/
112
std::string type_string()
const
;
113
114
/**
115
* Serialize an alert
116
*/
117
std::vector<uint8_t> serialize()
const
;
118
119
/**
120
* Deserialize an Alert message
121
* @param buf the serialized alert
122
*/
123
explicit
Alert
(
const
secure_vector<uint8_t>
& buf);
124
125
/**
126
* Create a new Alert
127
* @param type_code the type of alert
128
* @param fatal specifies if this is a fatal alert
129
*/
130
Alert
(
Type
type_code,
bool
fatal =
false
) :
// NOLINT(*-explicit-conversions,*-explicit-constructor)
131
m_fatal(fatal), m_type_code(type_code) {}
132
133
Alert
() : m_fatal(false), m_type_code(
AlertType
::None) {}
134
135
private
:
136
bool
m_fatal;
137
Type m_type_code;
138
};
139
140
}
// namespace Botan::TLS
141
142
#endif
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition
api.h:21
BOTAN_DEPRECATED
#define BOTAN_DEPRECATED(msg)
Definition
api.h:73
Botan::TLS::Alert
Definition
tls_alert.h:71
Botan::TLS::Alert::is_valid
bool is_valid() const
Definition
tls_alert.h:79
Botan::TLS::Alert::Type
AlertType Type
Definition
tls_alert.h:73
Botan::TLS::Alert::Alert
Alert()
Definition
tls_alert.h:133
Botan::TLS::Alert::Alert
Alert(Type type_code, bool fatal=false)
Definition
tls_alert.h:130
Botan::TLS::Alert::Alert
Alert(const secure_vector< uint8_t > &buf)
Definition
tls_alert.cpp:14
Botan::TLS::Alert::is_fatal
bool is_fatal() const
Definition
tls_alert.h:98
Botan::TLS::Alert::type
Type type() const
Definition
tls_alert.h:105
Botan::TLS
Definition
asio_context.cpp:17
Botan::TLS::AlertType
AlertType
Definition
tls_alert.h:21
Botan::TLS::AlertType::UnrecognizedName
@ UnrecognizedName
Definition
tls_alert.h:50
Botan::TLS::AlertType::InappropriateFallback
@ InappropriateFallback
Definition
tls_alert.h:44
Botan::TLS::AlertType::BadCertificateHashValue
@ BadCertificateHashValue
Definition
tls_alert.h:52
Botan::TLS::AlertType::BadRecordMac
@ BadRecordMac
Definition
tls_alert.h:24
Botan::TLS::AlertType::UnknownCA
@ UnknownCA
Definition
tls_alert.h:36
Botan::TLS::AlertType::DecompressionFailure
@ DecompressionFailure
Definition
tls_alert.h:27
Botan::TLS::AlertType::DecodeError
@ DecodeError
Definition
tls_alert.h:38
Botan::TLS::AlertType::CertificateExpired
@ CertificateExpired
Definition
tls_alert.h:33
Botan::TLS::AlertType::NoCertificate
@ NoCertificate
Definition
tls_alert.h:29
Botan::TLS::AlertType::NoRenegotiation
@ NoRenegotiation
Definition
tls_alert.h:46
Botan::TLS::AlertType::None
@ None
Definition
tls_alert.h:59
Botan::TLS::AlertType::PROTOCOL_VERSION
@ PROTOCOL_VERSION
Definition
tls_alert.h:65
Botan::TLS::AlertType::CLOSE_NOTIFY
@ CLOSE_NOTIFY
Definition
tls_alert.h:63
Botan::TLS::AlertType::UnsupportedExtension
@ UnsupportedExtension
Definition
tls_alert.h:48
Botan::TLS::AlertType::CertificateRevoked
@ CertificateRevoked
Definition
tls_alert.h:32
Botan::TLS::AlertType::InternalError
@ InternalError
Definition
tls_alert.h:43
Botan::TLS::AlertType::CertificateUnknown
@ CertificateUnknown
Definition
tls_alert.h:34
Botan::TLS::AlertType::GeneralError
@ GeneralError
Definition
tls_alert.h:55
Botan::TLS::AlertType::NoApplicationProtocol
@ NoApplicationProtocol
Definition
tls_alert.h:56
Botan::TLS::AlertType::ExportRestriction
@ ExportRestriction
Definition
tls_alert.h:40
Botan::TLS::AlertType::UnsupportedCertificate
@ UnsupportedCertificate
Definition
tls_alert.h:31
Botan::TLS::AlertType::BadCertificateStatusResponse
@ BadCertificateStatusResponse
Definition
tls_alert.h:51
Botan::TLS::AlertType::ProtocolVersion
@ ProtocolVersion
Definition
tls_alert.h:41
Botan::TLS::AlertType::NO_APPLICATION_PROTOCOL
@ NO_APPLICATION_PROTOCOL
Definition
tls_alert.h:64
Botan::TLS::AlertType::IllegalParameter
@ IllegalParameter
Definition
tls_alert.h:35
Botan::TLS::AlertType::UnexpectedMessage
@ UnexpectedMessage
Definition
tls_alert.h:23
Botan::TLS::AlertType::CloseNotify
@ CloseNotify
Definition
tls_alert.h:22
Botan::TLS::AlertType::DecryptError
@ DecryptError
Definition
tls_alert.h:39
Botan::TLS::AlertType::AccessDenied
@ AccessDenied
Definition
tls_alert.h:37
Botan::TLS::AlertType::RecordOverflow
@ RecordOverflow
Definition
tls_alert.h:26
Botan::TLS::AlertType::DecryptionFailed
@ DecryptionFailed
Definition
tls_alert.h:25
Botan::TLS::AlertType::UserCanceled
@ UserCanceled
Definition
tls_alert.h:45
Botan::TLS::AlertType::CertificateRequired
@ CertificateRequired
Definition
tls_alert.h:54
Botan::TLS::AlertType::HandshakeFailure
@ HandshakeFailure
Definition
tls_alert.h:28
Botan::TLS::AlertType::UnknownPSKIdentity
@ UnknownPSKIdentity
Definition
tls_alert.h:53
Botan::TLS::AlertType::InsufficientSecurity
@ InsufficientSecurity
Definition
tls_alert.h:42
Botan::TLS::AlertType::BadCertificate
@ BadCertificate
Definition
tls_alert.h:30
Botan::TLS::AlertType::MissingExtension
@ MissingExtension
Definition
tls_alert.h:47
Botan::TLS::AlertType::CertificateUnobtainable
@ CertificateUnobtainable
Definition
tls_alert.h:49
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition
secmem.h:128
Generated by
1.16.1