Botan
3.6.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
{
22
CloseNotify
= 0,
23
UnexpectedMessage
= 10,
24
BadRecordMac
= 20,
25
DecryptionFailed
= 21,
26
RecordOverflow
= 22,
27
DecompressionFailure
= 30,
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,
41
ProtocolVersion
= 70,
42
InsufficientSecurity
= 71,
43
InternalError
= 80,
44
InappropriateFallback
= 86,
45
UserCanceled
= 90,
46
NoRenegotiation
= 100,
47
MissingExtension
= 109,
// RFC 8446
48
UnsupportedExtension
= 110,
49
CertificateUnobtainable
= 111,
50
UnrecognizedName
= 112,
51
BadCertificateStatusResponse
= 113,
52
BadCertificateHashValue
= 114,
53
UnknownPSKIdentity
= 115,
54
CertificateRequired
= 116,
// RFC 8446
55
NoApplicationProtocol
= 120,
// RFC 7301
56
57
// pseudo alert values
58
None
= 256,
59
60
// Compat enum variants, will be removed in a future major release
61
CLOSE_NOTIFY
BOTAN_DEPRECATED
(
"Use CloseNotify"
) =
CloseNotify
,
62
NO_APPLICATION_PROTOCOL
BOTAN_DEPRECATED
(
"Use NoApplicationProtocol"
) =
NoApplicationProtocol
,
63
PROTOCOL_VERSION
BOTAN_DEPRECATED
(
"Use ProtocolVersion"
) =
ProtocolVersion
,
64
};
65
66
/**
67
* SSL/TLS Alert Message
68
*/
69
class
BOTAN_PUBLIC_API
(2, 0)
Alert
final
{
70
public
:
71
typedef
AlertType
Type
;
72
using
enum
AlertType
;
73
74
/**
75
* @return true iff this alert is non-empty
76
*/
77
bool
is_valid
()
const
{
return
(m_type_code != AlertType::None); }
78
79
/**
80
* Return true if this alert is fatal. A fatal alert causes the connection
81
* to be immediately disconnected. Otherwise, the alert is a warning and
82
* the connection remains valid.
83
*
84
* Note:
85
* RFC 8446 6.
86
* In TLS 1.3, the severity is implicit in the type of alert being sent,
87
* and the "level" field can safely be ignored.
88
* Everything is considered fatal except for UserCanceled and CloseNotify (RFC 8446 6.1)
89
*
90
* @return if this alert is fatal or not
91
*/
92
bool
is_fatal
()
const
{
return
m_fatal; }
93
94
/**
95
* Returns the type of the alert as an enum
96
*
97
* @return type of alert
98
*/
99
Type
type
()
const
{
return
m_type_code; }
100
101
/**
102
* Returns the type of the alert as a string
103
*
104
* @return type of alert
105
*/
106
std::string type_string()
const
;
107
108
/**
109
* Serialize an alert
110
*/
111
std::vector<uint8_t> serialize()
const
;
112
113
/**
114
* Deserialize an Alert message
115
* @param buf the serialized alert
116
*/
117
explicit
Alert
(
const
secure_vector<uint8_t>
& buf);
118
119
/**
120
* Create a new Alert
121
* @param type_code the type of alert
122
* @param fatal specifies if this is a fatal alert
123
*/
124
Alert
(
Type
type_code,
bool
fatal =
false
) : m_fatal(fatal), m_type_code(type_code) {}
125
126
Alert
() : m_fatal(false), m_type_code(
AlertType
::None) {}
127
128
private
:
129
bool
m_fatal;
130
Type m_type_code;
131
};
132
133
}
// namespace Botan::TLS
134
135
#endif
Botan::TLS::Alert
Definition
tls_alert.h:69
Botan::TLS::Alert::is_valid
bool is_valid() const
Definition
tls_alert.h:77
Botan::TLS::Alert::Alert
Alert()
Definition
tls_alert.h:126
Botan::TLS::Alert::Alert
Alert(Type type_code, bool fatal=false)
Definition
tls_alert.h:124
Botan::TLS::Alert::Type
AlertType Type
Definition
tls_alert.h:71
Botan::TLS::Alert::is_fatal
bool is_fatal() const
Definition
tls_alert.h:92
Botan::TLS::Alert::type
Type type() const
Definition
tls_alert.h:99
final
int(* final)(unsigned char *, CTX *)
Definition
commoncrypto_hash.cpp:29
BOTAN_PUBLIC_API
#define BOTAN_PUBLIC_API(maj, min)
Definition
compiler.h:31
BOTAN_DEPRECATED
#define BOTAN_DEPRECATED(msg)
Definition
compiler.h:125
Botan::TLS
Definition
asio_context.cpp:17
Botan::TLS::AlertType
AlertType
Definition
tls_alert.h:21
Botan::TLS::AlertType::UnrecognizedName
@ UnrecognizedName
Botan::TLS::AlertType::InappropriateFallback
@ InappropriateFallback
Botan::TLS::AlertType::BadCertificateHashValue
@ BadCertificateHashValue
Botan::TLS::AlertType::BadRecordMac
@ BadRecordMac
Botan::TLS::AlertType::UnknownCA
@ UnknownCA
Botan::TLS::AlertType::DecompressionFailure
@ DecompressionFailure
Botan::TLS::AlertType::DecodeError
@ DecodeError
Botan::TLS::AlertType::CertificateExpired
@ CertificateExpired
Botan::TLS::AlertType::NoCertificate
@ NoCertificate
Botan::TLS::AlertType::NoRenegotiation
@ NoRenegotiation
Botan::TLS::AlertType::None
@ None
Botan::TLS::AlertType::PROTOCOL_VERSION
@ PROTOCOL_VERSION
Botan::TLS::AlertType::CLOSE_NOTIFY
@ CLOSE_NOTIFY
Botan::TLS::AlertType::UnsupportedExtension
@ UnsupportedExtension
Botan::TLS::AlertType::CertificateRevoked
@ CertificateRevoked
Botan::TLS::AlertType::InternalError
@ InternalError
Botan::TLS::AlertType::CertificateUnknown
@ CertificateUnknown
Botan::TLS::AlertType::NoApplicationProtocol
@ NoApplicationProtocol
Botan::TLS::AlertType::ExportRestriction
@ ExportRestriction
Botan::TLS::AlertType::UnsupportedCertificate
@ UnsupportedCertificate
Botan::TLS::AlertType::BadCertificateStatusResponse
@ BadCertificateStatusResponse
Botan::TLS::AlertType::ProtocolVersion
@ ProtocolVersion
Botan::TLS::AlertType::NO_APPLICATION_PROTOCOL
@ NO_APPLICATION_PROTOCOL
Botan::TLS::AlertType::IllegalParameter
@ IllegalParameter
Botan::TLS::AlertType::UnexpectedMessage
@ UnexpectedMessage
Botan::TLS::AlertType::CloseNotify
@ CloseNotify
Botan::TLS::AlertType::DecryptError
@ DecryptError
Botan::TLS::AlertType::AccessDenied
@ AccessDenied
Botan::TLS::AlertType::RecordOverflow
@ RecordOverflow
Botan::TLS::AlertType::DecryptionFailed
@ DecryptionFailed
Botan::TLS::AlertType::UserCanceled
@ UserCanceled
Botan::TLS::AlertType::CertificateRequired
@ CertificateRequired
Botan::TLS::AlertType::HandshakeFailure
@ HandshakeFailure
Botan::TLS::AlertType::UnknownPSKIdentity
@ UnknownPSKIdentity
Botan::TLS::AlertType::InsufficientSecurity
@ InsufficientSecurity
Botan::TLS::AlertType::BadCertificate
@ BadCertificate
Botan::TLS::AlertType::MissingExtension
@ MissingExtension
Botan::TLS::AlertType::CertificateUnobtainable
@ CertificateUnobtainable
Botan::secure_vector
std::vector< T, secure_allocator< T > > secure_vector
Definition
secmem.h:61
Generated by
1.12.0