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 | List of all members
Botan::TLS::Alert Class Reference

`#include <tls_alert.h>`

## Public Types
enum | Type { CLOSE_NOTIFY = 0, UNEXPECTED_MESSAGE = 10, BAD_RECORD_MAC = 20, DECRYPTION_FAILED = 21, RECORD_OVERFLOW = 22, DECOMPRESSION_FAILURE = 30, HANDSHAKE_FAILURE = 40, NO_CERTIFICATE = 41, BAD_CERTIFICATE = 42, UNSUPPORTED_CERTIFICATE = 43, CERTIFICATE_REVOKED = 44, CERTIFICATE_EXPIRED = 45, CERTIFICATE_UNKNOWN = 46, ILLEGAL_PARAMETER = 47, UNKNOWN_CA = 48, ACCESS_DENIED = 49, DECODE_ERROR = 50, DECRYPT_ERROR = 51, EXPORT_RESTRICTION = 60, PROTOCOL_VERSION = 70, INSUFFICIENT_SECURITY = 71, INTERNAL_ERROR = 80, INAPPROPRIATE_FALLBACK = 86, USER_CANCELED = 90, NO_RENEGOTIATION = 100, UNSUPPORTED_EXTENSION = 110, CERTIFICATE_UNOBTAINABLE = 111, UNRECOGNIZED_NAME = 112, BAD_CERTIFICATE_STATUS_RESPONSE = 113, BAD_CERTIFICATE_HASH_VALUE = 114, UNKNOWN_PSK_IDENTITY = 115, NO_APPLICATION_PROTOCOL = 120, NULL_ALERT = 256 }

## Public Member Functions
| Alert (const secure_vector< uint8_t > &buf)
| Alert (Type type_code, bool fatal=false)
| Alert ()
bool | is_fatal () const
bool | is_valid () const
std::vector< uint8_t > | serialize () const
Type | type () const
std::string | type_string () const

## Detailed Description

SSL/TLS Alert Message

Definition at line 21 of file tls_alert.h.

## Member Enumeration Documentation

enum Botan::TLS::Alert::Type

Type codes for TLS alerts

Enumerator
CLOSE_NOTIFY |
UNEXPECTED_MESSAGE |
BAD_RECORD_MAC |
DECRYPTION_FAILED |
RECORD_OVERFLOW |
DECOMPRESSION_FAILURE |
HANDSHAKE_FAILURE |
NO_CERTIFICATE |
BAD_CERTIFICATE |
UNSUPPORTED_CERTIFICATE |
CERTIFICATE_REVOKED |
CERTIFICATE_EXPIRED |
CERTIFICATE_UNKNOWN |
ILLEGAL_PARAMETER |
UNKNOWN_CA |
ACCESS_DENIED |
DECODE_ERROR |
DECRYPT_ERROR |
EXPORT_RESTRICTION |
PROTOCOL_VERSION |
INSUFFICIENT_SECURITY |
INTERNAL_ERROR |
INAPPROPRIATE_FALLBACK |
USER_CANCELED |
NO_RENEGOTIATION |
UNSUPPORTED_EXTENSION |
CERTIFICATE_UNOBTAINABLE |
UNRECOGNIZED_NAME |
BAD_CERTIFICATE_STATUS_RESPONSE |
BAD_CERTIFICATE_HASH_VALUE |
UNKNOWN_PSK_IDENTITY |
NO_APPLICATION_PROTOCOL |
NULL_ALERT |

Definition at line 27 of file tls_alert.h.

27 {
28 CLOSE_NOTIFY = 0,
29 UNEXPECTED_MESSAGE = 10,
30 BAD_RECORD_MAC = 20,
31 DECRYPTION_FAILED = 21,
32 RECORD_OVERFLOW = 22,
33 DECOMPRESSION_FAILURE = 30,
34 HANDSHAKE_FAILURE = 40,
35 NO_CERTIFICATE = 41, // SSLv3 only
36 BAD_CERTIFICATE = 42,
37 UNSUPPORTED_CERTIFICATE = 43,
38 CERTIFICATE_REVOKED = 44,
39 CERTIFICATE_EXPIRED = 45,
40 CERTIFICATE_UNKNOWN = 46,
41 ILLEGAL_PARAMETER = 47,
42 UNKNOWN_CA = 48,
43 ACCESS_DENIED = 49,
44 DECODE_ERROR = 50,
45 DECRYPT_ERROR = 51,
46 EXPORT_RESTRICTION = 60,
47 PROTOCOL_VERSION = 70,
48 INSUFFICIENT_SECURITY = 71,
49 INTERNAL_ERROR = 80,
50 INAPPROPRIATE_FALLBACK = 86,
51 USER_CANCELED = 90,
52 NO_RENEGOTIATION = 100,
53 UNSUPPORTED_EXTENSION = 110,
54 CERTIFICATE_UNOBTAINABLE = 111,
55 UNRECOGNIZED_NAME = 112,
56 BAD_CERTIFICATE_STATUS_RESPONSE = 113,
57 BAD_CERTIFICATE_HASH_VALUE = 114,
58 UNKNOWN_PSK_IDENTITY = 115,
59
60 NO_APPLICATION_PROTOCOL = 120, // RFC 7301
61
62 // pseudo alert values
63 NULL_ALERT = 256
64 };
Botan::TLS::Alert::NULL_ALERT
Definition: tls_alert.h:63
Botan::TLS::Alert::BAD_CERTIFICATE_HASH_VALUE
Definition: tls_alert.h:57
Botan::TLS::Alert::UNRECOGNIZED_NAME
Definition: tls_alert.h:55
Botan::TLS::Alert::INAPPROPRIATE_FALLBACK
Definition: tls_alert.h:50
Botan::TLS::Alert::INTERNAL_ERROR
Definition: tls_alert.h:49
Botan::TLS::Alert::UNSUPPORTED_EXTENSION
Definition: tls_alert.h:53
Botan::TLS::Alert::NO_CERTIFICATE
Definition: tls_alert.h:35
Botan::TLS::Alert::DECRYPT_ERROR
Definition: tls_alert.h:45
Botan::TLS::Alert::CERTIFICATE_EXPIRED
Definition: tls_alert.h:39
Botan::TLS::Alert::UNKNOWN_PSK_IDENTITY
Definition: tls_alert.h:58
Botan::TLS::Alert::BAD_CERTIFICATE_STATUS_RESPONSE
Definition: tls_alert.h:56
Botan::TLS::Alert::USER_CANCELED
Definition: tls_alert.h:51
Botan::TLS::Alert::BAD_CERTIFICATE
Definition: tls_alert.h:36
Botan::TLS::Alert::HANDSHAKE_FAILURE
Definition: tls_alert.h:34
Botan::TLS::Alert::UNKNOWN_CA
Definition: tls_alert.h:42
Botan::TLS::Alert::DECOMPRESSION_FAILURE
Definition: tls_alert.h:33
Botan::TLS::Alert::CERTIFICATE_UNKNOWN
Definition: tls_alert.h:40
Botan::TLS::Alert::DECODE_ERROR
Definition: tls_alert.h:44
Botan::TLS::Alert::INSUFFICIENT_SECURITY
Definition: tls_alert.h:48
Botan::TLS::Alert::ACCESS_DENIED
Definition: tls_alert.h:43
Botan::TLS::Alert::UNSUPPORTED_CERTIFICATE
Definition: tls_alert.h:37
Botan::TLS::Alert::CERTIFICATE_REVOKED
Definition: tls_alert.h:38
Botan::TLS::Alert::NO_APPLICATION_PROTOCOL
Definition: tls_alert.h:60
Botan::TLS::Alert::CERTIFICATE_UNOBTAINABLE
Definition: tls_alert.h:54
Botan::TLS::Alert::RECORD_OVERFLOW
Definition: tls_alert.h:32
Botan::TLS::Alert::EXPORT_RESTRICTION
Definition: tls_alert.h:46
Botan::TLS::Alert::CLOSE_NOTIFY
Definition: tls_alert.h:28
Botan::TLS::Alert::ILLEGAL_PARAMETER
Definition: tls_alert.h:41
Botan::TLS::Alert::NO_RENEGOTIATION
Definition: tls_alert.h:52
Botan::TLS::Alert::PROTOCOL_VERSION
Definition: tls_alert.h:47
Botan::TLS::Alert::DECRYPTION_FAILED
Definition: tls_alert.h:31
Botan::TLS::Alert::UNEXPECTED_MESSAGE
Definition: tls_alert.h:29
Botan::TLS::Alert::BAD_RECORD_MAC
Definition: tls_alert.h:30

## Constructor & Destructor Documentation

Botan::TLS::Alert::Alert | ( | const secure_vector< uint8_t > & | buf | ) |
| explicit

Deserialize an Alert message

Parameters

  buf | the serialized alert

Definition at line 15 of file tls_alert.cpp.

References Botan::ASN1::to_string().

16 {
17 if(buf.size() != 2)
18 throw Decoding_Error("Alert: Bad size " + std::to_string(buf.size()) +
19 " for alert message");
20
21 if(buf[0] == 1) m_fatal = false;
22 else if(buf[0] == 2) m_fatal = true;
23 else
24 throw Decoding_Error("Alert: Bad code for alert level");
25
26 const uint8_t dc = buf[1];
27
28 m_type_code = static_cast<Type>(dc);
29 }
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::TLS::Alert::Type
Type
Definition: tls_alert.h:27

Botan::TLS::Alert::Alert | ( | Type | type_code,
|  | bool | fatal = `false`
| ) |  |
| inline

Create a new Alert

Parameters

  type_code | the type of alert
  fatal | specifies if this is a fatal alert

Definition at line 102 of file tls_alert.h.

102 :
103 m_fatal(fatal), m_type_code(type_code) {}

Botan::TLS::Alert::Alert | ( |  | ) |
| inline

Definition at line 105 of file tls_alert.h.

105 : m_fatal(false), m_type_code(NULL_ALERT) {}
Botan::TLS::Alert::NULL_ALERT
Definition: tls_alert.h:63

## Member Function Documentation

bool Botan::TLS::Alert::is_fatal | ( |  | ) | const
| inline

Returns
  if this alert is a fatal one or not

Definition at line 74 of file tls_alert.h.

Referenced by Botan::TLS::Channel::send_alert(), and serialize().

74 { return m_fatal; }

bool Botan::TLS::Alert::is_valid | ( |  | ) | const
| inline

Returns
  true iff this alert is non-empty

Definition at line 69 of file tls_alert.h.

Referenced by Botan::TLS::Channel::send_alert().

69 { return (m_type_code != NULL_ALERT); }
Botan::TLS::Alert::NULL_ALERT
Definition: tls_alert.h:63

std::vector< uint8_t > Botan::TLS::Alert::serialize | ( |  | ) | const

Serialize an alert

Definition at line 31 of file tls_alert.cpp.

References is_fatal(), and type().

Referenced by Botan::TLS::Channel::send_alert().

32 {
33 return std::vector<uint8_t>({
34 static_cast<uint8_t>(is_fatal() ? 2 : 1),
35 static_cast<uint8_t>(type())
36 });
37 }
Botan::TLS::Alert::type
Type type() const
Definition: tls_alert.h:79
Botan::TLS::Alert::is_fatal
bool is_fatal() const
Definition: tls_alert.h:74

Type Botan::TLS::Alert::type | ( |  | ) | const
| inline

Returns
  type of alert

Definition at line 79 of file tls_alert.h.

Referenced by Botan::TLS::Channel::send_alert(), serialize(), and type_string().

79 { return m_type_code; }

std::string Botan::TLS::Alert::type_string | ( |  | ) | const

Returns
  type of alert

Definition at line 39 of file tls_alert.cpp.

References ACCESS_DENIED, BAD_CERTIFICATE, BAD_CERTIFICATE_HASH_VALUE, BAD_CERTIFICATE_STATUS_RESPONSE, BAD_RECORD_MAC, CERTIFICATE_EXPIRED, CERTIFICATE_REVOKED, CERTIFICATE_UNKNOWN, CERTIFICATE_UNOBTAINABLE, CLOSE_NOTIFY, DECODE_ERROR, DECOMPRESSION_FAILURE, DECRYPT_ERROR, DECRYPTION_FAILED, EXPORT_RESTRICTION, HANDSHAKE_FAILURE, ILLEGAL_PARAMETER, INAPPROPRIATE_FALLBACK, INSUFFICIENT_SECURITY, INTERNAL_ERROR, NO_APPLICATION_PROTOCOL, NO_CERTIFICATE, NO_RENEGOTIATION, NULL_ALERT, PROTOCOL_VERSION, RECORD_OVERFLOW, Botan::ASN1::to_string(), type(), UNEXPECTED_MESSAGE, UNKNOWN_CA, UNKNOWN_PSK_IDENTITY, UNRECOGNIZED_NAME, UNSUPPORTED_CERTIFICATE, UNSUPPORTED_EXTENSION, and USER_CANCELED.

40 {
41 switch(type())
42 {
43 case CLOSE_NOTIFY:
44 return "close_notify";
45 case UNEXPECTED_MESSAGE:
46 return "unexpected_message";
47 case BAD_RECORD_MAC:
48 return "bad_record_mac";
49 case DECRYPTION_FAILED:
50 return "decryption_failed";
51 case RECORD_OVERFLOW:
52 return "record_overflow";
53 case DECOMPRESSION_FAILURE:
54 return "decompression_failure";
55 case HANDSHAKE_FAILURE:
56 return "handshake_failure";
57 case NO_CERTIFICATE:
58 return "no_certificate";
59 case BAD_CERTIFICATE:
60 return "bad_certificate";
61 case UNSUPPORTED_CERTIFICATE:
62 return "unsupported_certificate";
63 case CERTIFICATE_REVOKED:
64 return "certificate_revoked";
65 case CERTIFICATE_EXPIRED:
66 return "certificate_expired";
67 case CERTIFICATE_UNKNOWN:
68 return "certificate_unknown";
69 case ILLEGAL_PARAMETER:
70 return "illegal_parameter";
71 case UNKNOWN_CA:
72 return "unknown_ca";
73 case ACCESS_DENIED:
74 return "access_denied";
75 case DECODE_ERROR:
76 return "decode_error";
77 case DECRYPT_ERROR:
78 return "decrypt_error";
79 case EXPORT_RESTRICTION:
80 return "export_restriction";
81 case PROTOCOL_VERSION:
82 return "protocol_version";
83 case INSUFFICIENT_SECURITY:
84 return "insufficient_security";
85 case INTERNAL_ERROR:
86 return "internal_error";
87 case INAPPROPRIATE_FALLBACK:
88 return "inappropriate_fallback";
89 case USER_CANCELED:
90 return "user_canceled";
91 case NO_RENEGOTIATION:
92 return "no_renegotiation";
93
94 case UNSUPPORTED_EXTENSION:
95 return "unsupported_extension";
96 case CERTIFICATE_UNOBTAINABLE:
97 return "certificate_unobtainable";
98 case UNRECOGNIZED_NAME:
99 return "unrecognized_name";
100 case BAD_CERTIFICATE_STATUS_RESPONSE:
101 return "bad_certificate_status_response";
102 case BAD_CERTIFICATE_HASH_VALUE:
103 return "bad_certificate_hash_value";
104 case UNKNOWN_PSK_IDENTITY:
105 return "unknown_psk_identity";
106 case NO_APPLICATION_PROTOCOL:
107 return "no_application_protocol";
108
109 case NULL_ALERT:
110 return "none";
111 }
112
113 /*
114 * This is effectively the default case for the switch above, but we
115 * leave it out so that when an alert type is added to the enum the
116 * compiler can warn us that it is not included in the switch
117 * statement.
118 */
119 return "unrecognized_alert_" + std::to_string(type());
120 }
Botan::TLS::Alert::NULL_ALERT
Definition: tls_alert.h:63
Botan::TLS::Alert::BAD_CERTIFICATE_HASH_VALUE
Definition: tls_alert.h:57
Botan::TLS::Alert::UNRECOGNIZED_NAME
Definition: tls_alert.h:55
Botan::TLS::Alert::INAPPROPRIATE_FALLBACK
Definition: tls_alert.h:50
Botan::TLS::Alert::INTERNAL_ERROR
Definition: tls_alert.h:49
Botan::TLS::Alert::UNSUPPORTED_EXTENSION
Definition: tls_alert.h:53
Botan::ASN1::to_string
std::string to_string(const BER_Object &obj)
Definition: asn1_obj.cpp:47
Botan::TLS::Alert::NO_CERTIFICATE
Definition: tls_alert.h:35
Botan::TLS::Alert::DECRYPT_ERROR
Definition: tls_alert.h:45
Botan::TLS::Alert::CERTIFICATE_EXPIRED
Definition: tls_alert.h:39
Botan::TLS::Alert::UNKNOWN_PSK_IDENTITY
Definition: tls_alert.h:58
Botan::TLS::Alert::BAD_CERTIFICATE_STATUS_RESPONSE
Definition: tls_alert.h:56
Botan::TLS::Alert::USER_CANCELED
Definition: tls_alert.h:51
Botan::TLS::Alert::BAD_CERTIFICATE
Definition: tls_alert.h:36
Botan::TLS::Alert::HANDSHAKE_FAILURE
Definition: tls_alert.h:34
Botan::TLS::Alert::UNKNOWN_CA
Definition: tls_alert.h:42
Botan::TLS::Alert::DECOMPRESSION_FAILURE
Definition: tls_alert.h:33
Botan::TLS::Alert::CERTIFICATE_UNKNOWN
Definition: tls_alert.h:40
Botan::TLS::Alert::DECODE_ERROR
Definition: tls_alert.h:44
Botan::TLS::Alert::INSUFFICIENT_SECURITY
Definition: tls_alert.h:48
Botan::TLS::Alert::ACCESS_DENIED
Definition: tls_alert.h:43
Botan::TLS::Alert::UNSUPPORTED_CERTIFICATE
Definition: tls_alert.h:37
Botan::TLS::Alert::CERTIFICATE_REVOKED
Definition: tls_alert.h:38
Botan::TLS::Alert::NO_APPLICATION_PROTOCOL
Definition: tls_alert.h:60
Botan::TLS::Alert::CERTIFICATE_UNOBTAINABLE
Definition: tls_alert.h:54
Botan::TLS::Alert::RECORD_OVERFLOW
Definition: tls_alert.h:32
Botan::TLS::Alert::EXPORT_RESTRICTION
Definition: tls_alert.h:46
Botan::TLS::Alert::type
Type type() const
Definition: tls_alert.h:79
Botan::TLS::Alert::CLOSE_NOTIFY
Definition: tls_alert.h:28
Botan::TLS::Alert::ILLEGAL_PARAMETER
Definition: tls_alert.h:41
Botan::TLS::Alert::NO_RENEGOTIATION
Definition: tls_alert.h:52
Botan::TLS::Alert::PROTOCOL_VERSION
Definition: tls_alert.h:47
Botan::TLS::Alert::DECRYPTION_FAILED
Definition: tls_alert.h:31
Botan::TLS::Alert::UNEXPECTED_MESSAGE
Definition: tls_alert.h:29
Botan::TLS::Alert::BAD_RECORD_MAC
Definition: tls_alert.h:30

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

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